1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/apps/openmw/mwrender/rotatecontroller.hpp
2022-09-22 21:35:26 +03:00

41 lines
1.0 KiB
C++

#ifndef OPENMW_MWRENDER_ROTATECONTROLLER_H
#define OPENMW_MWRENDER_ROTATECONTROLLER_H
#include <components/sceneutil/nodecallback.hpp>
#include <osg/Quat>
namespace osg
{
class MatrixTransform;
}
namespace MWRender
{
/// Applies a rotation in \a relativeTo's space.
/// @note Assumes that the node being rotated has its "original" orientation set every frame by a different
/// controller. The rotation is then applied on top of that orientation.
class RotateController : public SceneUtil::NodeCallback<RotateController, osg::MatrixTransform*>
{
public:
RotateController(osg::Node* relativeTo);
void setEnabled(bool enabled);
void setOffset(const osg::Vec3f& offset);
void setRotate(const osg::Quat& rotate);
void operator()(osg::MatrixTransform* node, osg::NodeVisitor* nv);
protected:
osg::Quat getWorldOrientation(osg::Node* node);
bool mEnabled;
osg::Vec3f mOffset;
osg::Quat mRotate;
osg::Node* mRelativeTo;
};
}
#endif