mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-27 21:06:42 +00:00
Couple reasons for this: * This paves the way for allowing animations specified in other skeletons to be applied to the character (NPCs and certain creatures can have multiple animation sources, but Ogre is incredibly strict when it comes to sharing animations between skeletons). * It will allow for entities to be animated based on the character's skeleton, without having to duplicate the mesh for each skeleton it can be used on. This doesn't impact Ogre's ability to efficiently deform skinned meshes, nor does it get in the way of hardware skinning.
71 lines
2 KiB
C++
71 lines
2 KiB
C++
#ifndef _GAME_RENDER_ANIMATION_H
|
|
#define _GAME_RENDER_ANIMATION_H
|
|
|
|
#include <components/nifogre/ogre_nif_loader.hpp>
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
namespace MWMechanics
|
|
{
|
|
class CharacterController;
|
|
}
|
|
|
|
namespace MWRender
|
|
{
|
|
|
|
class Animation
|
|
{
|
|
protected:
|
|
MWWorld::Ptr mPtr;
|
|
MWMechanics::CharacterController *mController;
|
|
|
|
Ogre::SceneNode* mInsert;
|
|
NifOgre::EntityList mEntityList;
|
|
std::map<std::string,NifOgre::TextKeyMap> mTextKeys;
|
|
Ogre::Bone *mAccumRoot;
|
|
Ogre::Bone *mNonAccumRoot;
|
|
Ogre::Vector3 mAccumulate;
|
|
Ogre::Vector3 mStartPosition;
|
|
Ogre::Vector3 mLastPosition;
|
|
|
|
NifOgre::TextKeyMap *mCurrentKeys;
|
|
NifOgre::TextKeyMap::const_iterator mNextKey;
|
|
Ogre::AnimationState *mAnimState;
|
|
bool mPlaying;
|
|
|
|
float mAnimSpeedMult;
|
|
|
|
void applyAnimation(const Ogre::Animation *anim, float time, Ogre::SkeletonInstance *skel);
|
|
|
|
/* Updates the animation to the specified time, and returns the movement
|
|
* vector since the last update or reset. */
|
|
Ogre::Vector3 updatePosition(float time);
|
|
|
|
/* Resets the animation to the time of the specified marker, without moving
|
|
* anything. If the marker is not found, it resets to the beginning. */
|
|
void reset(const std::string &marker);
|
|
|
|
void createEntityList(Ogre::SceneNode *node, const std::string &model);
|
|
|
|
public:
|
|
Animation(const MWWorld::Ptr &ptr);
|
|
virtual ~Animation();
|
|
|
|
void setController(MWMechanics::CharacterController *controller);
|
|
|
|
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 setSpeedMult(float speedmult)
|
|
{ mAnimSpeedMult = speedmult; }
|
|
|
|
void play(const std::string &groupname, const std::string &start, bool loop);
|
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
|
};
|
|
|
|
}
|
|
#endif
|