1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-03 17:37:18 +00:00
OpenMW/components/resource/keyframemanager.hpp

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

71 lines
2.1 KiB
C++
Raw Normal View History

#ifndef OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
#define OPENMW_COMPONENTS_KEYFRAMEMANAGER_H
2024-05-02 23:07:47 +00:00
#include <string>
#include <osg/ref_ptr>
2020-11-18 23:11:56 +00:00
#include <osgAnimation/BasicAnimationManager>
#include <components/sceneutil/keyframe.hpp>
#include "resourcemanager.hpp"
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
}
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:
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
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:
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;
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:
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;
/// 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;
2024-01-17 17:10:42 +00:00
const ToUTF8::StatelessUtf8Encoder* mEncoder;
};
}
#endif