2015-12-12 17:52:06 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
|
|
|
|
|
2024-05-02 23:07:47 +00:00
|
|
|
#include <string>
|
|
|
|
|
2015-12-12 17:52:06 +00:00
|
|
|
#include <osg/ref_ptr>
|
2020-11-18 23:11:56 +00:00
|
|
|
#include <osgAnimation/BasicAnimationManager>
|
2015-12-12 17:52:06 +00:00
|
|
|
|
2020-11-18 20:48:47 +00:00
|
|
|
#include <components/sceneutil/keyframe.hpp>
|
2015-12-12 17:52:06 +00:00
|
|
|
|
2017-02-09 02:32:40 +00:00
|
|
|
#include "resourcemanager.hpp"
|
2015-12-12 17:52:06 +00:00
|
|
|
|
2024-01-16 19:56:58 +00:00
|
|
|
namespace ToUTF8
|
|
|
|
{
|
2024-01-17 17:10:42 +00:00
|
|
|
class StatelessUtf8Encoder;
|
2024-01-16 19:56:58 +00:00
|
|
|
}
|
|
|
|
|
2020-11-28 13:03:10 +00:00
|
|
|
namespace Resource
|
2020-11-18 23:11:56 +00:00
|
|
|
{
|
2022-12-30 22:33:35 +00:00
|
|
|
/// @brief extract animations from OSG formats to OpenMW's animation system
|
2020-11-18 23:11:56 +00:00
|
|
|
class RetrieveAnimationsVisitor : public osg::NodeVisitor
|
|
|
|
{
|
|
|
|
public:
|
2024-05-02 23:28:09 +00:00
|
|
|
explicit RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target,
|
|
|
|
osg::ref_ptr<osgAnimation::BasicAnimationManager> animationManager, VFS::Path::NormalizedView path,
|
|
|
|
const VFS::Manager& vfs);
|
2022-10-14 11:52:08 +00:00
|
|
|
|
2022-10-13 22:29:52 +00:00
|
|
|
bool belongsToLeftUpperExtremity(const std::string& name);
|
|
|
|
bool belongsToRightUpperExtremity(const std::string& name);
|
2022-10-14 11:31:03 +00:00
|
|
|
bool belongsToTorso(const std::string& name);
|
2021-02-04 21:14:21 +00:00
|
|
|
|
2022-10-13 22:29:52 +00:00
|
|
|
void addKeyframeController(const std::string& name, const osg::Node& node);
|
2020-11-18 23:11:56 +00:00
|
|
|
virtual void apply(osg::Node& node) override;
|
|
|
|
|
2022-09-22 18:26:05 +00:00
|
|
|
private:
|
2020-11-18 23:11:56 +00:00
|
|
|
SceneUtil::KeyframeHolder& mTarget;
|
|
|
|
osg::ref_ptr<osgAnimation::BasicAnimationManager> mAnimationManager;
|
2024-05-02 23:07:47 +00:00
|
|
|
VFS::Path::Normalized mPath;
|
2021-02-04 21:14:21 +00:00
|
|
|
const VFS::Manager* mVFS;
|
2020-11-18 23:11:56 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-12-12 17:52:06 +00:00
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
|
2020-11-18 20:48:47 +00:00
|
|
|
class SceneManager;
|
|
|
|
|
2015-12-12 17:52:06 +00:00
|
|
|
/// @brief Managing of keyframe resources
|
2016-02-05 23:15:12 +00:00
|
|
|
/// @note May be used from any thread.
|
2016-02-06 15:57:54 +00:00
|
|
|
class KeyframeManager : public ResourceManager
|
2015-12-12 17:52:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2024-01-16 19:56:58 +00:00
|
|
|
explicit KeyframeManager(const VFS::Manager* vfs, SceneManager* sceneManager, double expiryDelay,
|
2024-01-17 17:10:42 +00:00
|
|
|
const ToUTF8::StatelessUtf8Encoder* encoder);
|
2023-05-31 21:11:03 +00:00
|
|
|
~KeyframeManager() = default;
|
2015-12-12 17:52:06 +00:00
|
|
|
|
|
|
|
/// Retrieve a read-only keyframe resource by name (case-insensitive).
|
|
|
|
/// @note Throws an exception if the resource is not found.
|
2020-11-18 20:48:47 +00:00
|
|
|
osg::ref_ptr<const SceneUtil::KeyframeHolder> get(const std::string& name);
|
2017-02-22 01:18:18 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2020-11-18 20:48:47 +00:00
|
|
|
private:
|
|
|
|
SceneManager* mSceneManager;
|
2024-01-17 17:10:42 +00:00
|
|
|
const ToUTF8::StatelessUtf8Encoder* mEncoder;
|
2015-12-12 17:52:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|