1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-21 10:23:52 +00:00
openmw-tes3mp/apps/openmw/mwrender/animation.hpp

119 lines
3.6 KiB
C++
Raw Normal View History

#ifndef _GAME_RENDER_ANIMATION_H
#define _GAME_RENDER_ANIMATION_H
#include <OgreController.h>
#include <OgreVector3.h>
2013-02-24 21:52:23 +00:00
#include <components/nifogre/ogrenifloader.hpp>
2012-01-06 07:27:10 +00:00
#include "../mwworld/ptr.hpp"
namespace MWMechanics
{
class CharacterController;
}
namespace MWRender
{
class Animation
{
protected:
class AnimationValue : public Ogre::ControllerValue<Ogre::Real>
{
private:
Animation *mAnimation;
public:
AnimationValue(Animation *anim) : mAnimation(anim)
{ }
virtual Ogre::Real getValue() const
{
return mAnimation->mCurrentTime;
}
virtual void setValue(Ogre::Real value)
{
mAnimation->mCurrentTime = value;
}
};
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > mAnimationBaseValuePtr;
MWWorld::Ptr mPtr;
MWMechanics::CharacterController *mController;
Ogre::SceneNode *mInsert;
Ogre::Entity *mSkelBase;
std::vector<NifOgre::ObjectList> mObjectLists;
Ogre::Node *mAccumRoot;
Ogre::Bone *mNonAccumRoot;
Ogre::Vector3 mAccumulate;
Ogre::Vector3 mLastPosition;
2013-04-22 01:32:34 +00:00
std::string mCurrentGroup;
2013-04-07 21:56:23 +00:00
std::vector<Ogre::Controller<Ogre::Real> > *mCurrentControllers;
const NifOgre::TextKeyMap *mCurrentKeys;
NifOgre::TextKeyMap::const_iterator mStartKey;
NifOgre::TextKeyMap::const_iterator mStopKey;
NifOgre::TextKeyMap::const_iterator mNextKey;
float mCurrentTime;
bool mPlaying;
bool mLooping;
2013-01-22 06:51:13 +00:00
NifOgre::NodeTargetValue<Ogre::Real> *mNonAccumCtrl;
float mAnimVelocity;
float mAnimSpeedMult;
static float calcAnimVelocity(NifOgre::NodeTargetValue<Ogre::Real> *nonaccumctrl,
const std::string &groupname, const NifOgre::TextKeyMap *keys);
/* Updates a skeleton instance so that all bones matching the source skeleton (based on
* bone names) are positioned identically. */
void updateSkeletonInstance(const Ogre::SkeletonInstance *skelsrc, Ogre::SkeletonInstance *skel);
/* Updates the position of the accum root node for the current time, and
* returns the wanted movement vector from the previous update. */
Ogre::Vector3 updatePosition();
/* Resets the animation to the time of the specified start marker, without
* moving anything, and set the end time to the specified stop marker. If
* the marker is not found, it resets to the beginning or end respectively.
*/
void reset(const std::string &start, const std::string &stop=std::string());
bool handleEvent(float time, const std::string &evt);
void addObjectList(Ogre::SceneNode *node, const std::string &model, bool baseonly);
static void destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectList &objects);
static void setRenderProperties(const NifOgre::ObjectList &objlist, Ogre::uint32 visflags, Ogre::uint8 solidqueue, Ogre::uint8 transqueue);
public:
Animation(const MWWorld::Ptr &ptr);
virtual ~Animation();
void setController(MWMechanics::CharacterController *controller);
void updatePtr(const MWWorld::Ptr &ptr);
bool hasAnimation(const std::string &anim);
// Specifies the axis' to accumulate on. Non-accumulated axis will just
// move visually, but not affect the actual movement. Each x/y/z value
// should be on the scale of 0 to 1.
void setAccumulation(const Ogre::Vector3 &accum);
void setSpeed(float speed);
void setLooping(bool loop);
void play(const std::string &groupname, const std::string &start, const std::string &stop, bool loop);
virtual Ogre::Vector3 runAnimation(float timepassed);
Ogre::Node *getNode(const std::string &name);
};
}
#endif