2015-12-12 17:52:06 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
2020-11-18 23:11:56 +00:00
|
|
|
#include <osgAnimation/BasicAnimationManager>
|
2015-12-12 17:52:06 +00:00
|
|
|
#include <string>
|
|
|
|
|
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
|
|
|
|
2020-11-28 13:03:10 +00:00
|
|
|
namespace Resource
|
2020-11-18 23:11:56 +00:00
|
|
|
{
|
|
|
|
/// @brief extract animations to OpenMW's animation system
|
|
|
|
class RetrieveAnimationsVisitor : public osg::NodeVisitor
|
|
|
|
{
|
|
|
|
public:
|
2021-02-04 21:14:21 +00:00
|
|
|
RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target,
|
|
|
|
osg::ref_ptr<osgAnimation::BasicAnimationManager> animationManager, const std::string& normalized,
|
|
|
|
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:
|
2021-06-23 19:56:08 +00:00
|
|
|
std::string changeFileExtension(const std::string& file, const std::string& ext);
|
2021-02-04 21:14:21 +00:00
|
|
|
std::string parseTextKey(const std::string& line);
|
|
|
|
double parseTimeSignature(const std::string& line);
|
2022-09-22 18:26:05 +00:00
|
|
|
|
2020-11-18 23:11:56 +00:00
|
|
|
SceneUtil::KeyframeHolder& mTarget;
|
|
|
|
osg::ref_ptr<osgAnimation::BasicAnimationManager> mAnimationManager;
|
2021-02-04 21:14:21 +00:00
|
|
|
std::string mNormalized;
|
|
|
|
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:
|
2020-11-18 20:48:47 +00:00
|
|
|
KeyframeManager(const VFS::Manager* vfs, SceneManager* sceneManager);
|
2015-12-12 17:52:06 +00:00
|
|
|
~KeyframeManager();
|
|
|
|
|
|
|
|
/// 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;
|
2015-12-12 17:52:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|