2015-12-12 18:52:06 +01:00
|
|
|
#ifndef OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
|
|
|
|
#define OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
|
|
|
|
|
|
|
|
#include <osg/ref_ptr>
|
2020-11-19 01:11:56 +02:00
|
|
|
#include <osgAnimation/BasicAnimationManager>
|
2015-12-12 18:52:06 +01:00
|
|
|
#include <string>
|
|
|
|
|
2020-11-18 22:48:47 +02:00
|
|
|
#include <components/sceneutil/keyframe.hpp>
|
2015-12-12 18:52:06 +01:00
|
|
|
|
2017-02-09 03:32:40 +01:00
|
|
|
#include "resourcemanager.hpp"
|
2015-12-12 18:52:06 +01:00
|
|
|
|
2020-11-28 15:03:10 +02:00
|
|
|
namespace Resource
|
2020-11-19 01:11:56 +02:00
|
|
|
{
|
|
|
|
/// @brief extract animations to OpenMW's animation system
|
|
|
|
class RetrieveAnimationsVisitor : public osg::NodeVisitor
|
|
|
|
{
|
|
|
|
public:
|
2021-02-04 23:14:21 +02:00
|
|
|
RetrieveAnimationsVisitor(SceneUtil::KeyframeHolder& target, osg::ref_ptr<osgAnimation::BasicAnimationManager> animationManager,
|
|
|
|
const std::string& normalized, const VFS::Manager* vfs);
|
2020-11-19 01:11:56 +02:00
|
|
|
|
2020-11-20 19:38:29 +02:00
|
|
|
virtual void apply(osg::Node& node) override;
|
2020-11-19 01:11:56 +02:00
|
|
|
|
|
|
|
private:
|
2021-02-04 23:14:21 +02:00
|
|
|
|
2021-06-23 21:56:08 +02:00
|
|
|
std::string changeFileExtension(const std::string& file, const std::string& ext);
|
2021-02-04 23:14:21 +02:00
|
|
|
std::string parseTextKey(const std::string& line);
|
|
|
|
double parseTimeSignature(const std::string& line);
|
|
|
|
|
2020-11-19 01:11:56 +02:00
|
|
|
SceneUtil::KeyframeHolder& mTarget;
|
|
|
|
osg::ref_ptr<osgAnimation::BasicAnimationManager> mAnimationManager;
|
2021-02-04 23:14:21 +02:00
|
|
|
std::string mNormalized;
|
|
|
|
const VFS::Manager* mVFS;
|
2020-11-19 01:11:56 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2015-12-12 18:52:06 +01:00
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
|
2020-11-18 22:48:47 +02:00
|
|
|
class SceneManager;
|
|
|
|
|
2015-12-12 18:52:06 +01:00
|
|
|
/// @brief Managing of keyframe resources
|
2016-02-06 00:15:12 +01:00
|
|
|
/// @note May be used from any thread.
|
2016-02-06 16:57:54 +01:00
|
|
|
class KeyframeManager : public ResourceManager
|
2015-12-12 18:52:06 +01:00
|
|
|
{
|
|
|
|
public:
|
2020-11-18 22:48:47 +02:00
|
|
|
KeyframeManager(const VFS::Manager* vfs, SceneManager* sceneManager);
|
2015-12-12 18:52:06 +01: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 22:48:47 +02:00
|
|
|
osg::ref_ptr<const SceneUtil::KeyframeHolder> get(const std::string& name);
|
2017-02-22 02:18:18 +01:00
|
|
|
|
2020-10-16 22:18:54 +04:00
|
|
|
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
|
2020-11-18 22:48:47 +02:00
|
|
|
private:
|
|
|
|
SceneManager* mSceneManager;
|
2015-12-12 18:52:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|