1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/components/resource/keyframemanager.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.1 KiB
C++
Raw Normal View History

#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>
#include <string>
#include <components/sceneutil/keyframe.hpp>
#include "resourcemanager.hpp"
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:
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
bool belongsToLeftUpperExtremity(const std::string& name);
bool belongsToRightUpperExtremity(const std::string& name);
bool belongsToTorso(const std::string& name);
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:
std::string changeFileExtension(const std::string& file, const std::string& ext);
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;
std::string mNormalized;
const VFS::Manager* mVFS;
2020-11-18 23:11:56 +00:00
};
}
namespace Resource
{
class SceneManager;
/// @brief Managing of keyframe resources
/// @note May be used from any thread.
class KeyframeManager : public ResourceManager
{
public:
explicit KeyframeManager(const VFS::Manager* vfs, SceneManager* sceneManager, double expiryDelay);
2023-05-31 21:11:03 +00:00
~KeyframeManager() = default;
/// Retrieve a read-only keyframe resource by name (case-insensitive).
/// @note Throws an exception if the resource is not found.
osg::ref_ptr<const SceneUtil::KeyframeHolder> get(const std::string& name);
void reportStats(unsigned int frameNumber, osg::Stats* stats) const override;
2022-09-22 18:26:05 +00:00
private:
SceneManager* mSceneManager;
};
}
#endif