2011-11-24 01:48:54 -05:00
|
|
|
#ifndef _GAME_RENDER_ANIMATION_H
|
|
|
|
#define _GAME_RENDER_ANIMATION_H
|
2012-07-17 09:27:12 +02:00
|
|
|
|
2012-07-17 16:00:03 -07:00
|
|
|
#include <components/nifogre/ogre_nif_loader.hpp>
|
2012-01-06 02:27:10 -05:00
|
|
|
|
2013-01-06 17:05:48 -08:00
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
|
2013-01-16 11:01:08 -08:00
|
|
|
namespace MWMechanics
|
|
|
|
{
|
|
|
|
class CharacterController;
|
|
|
|
}
|
|
|
|
|
2013-01-05 21:12:08 -08:00
|
|
|
namespace MWRender
|
|
|
|
{
|
2011-12-11 22:40:00 -05:00
|
|
|
|
2013-01-05 21:12:08 -08:00
|
|
|
class Animation
|
|
|
|
{
|
2012-07-12 20:12:18 -07:00
|
|
|
protected:
|
2013-01-06 17:05:48 -08:00
|
|
|
MWWorld::Ptr mPtr;
|
2013-01-16 11:01:08 -08:00
|
|
|
MWMechanics::CharacterController *mController;
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2013-01-16 11:01:08 -08:00
|
|
|
Ogre::SceneNode* mInsert;
|
2012-07-17 16:00:03 -07:00
|
|
|
NifOgre::EntityList mEntityList;
|
2013-01-09 03:30:55 -08:00
|
|
|
std::map<std::string,NifOgre::TextKeyMap> mTextKeys;
|
2013-02-02 05:43:37 -08:00
|
|
|
Ogre::Node *mAccumRoot;
|
2013-01-06 21:18:48 -08:00
|
|
|
Ogre::Bone *mNonAccumRoot;
|
2013-01-18 14:25:32 -08:00
|
|
|
Ogre::Vector3 mAccumulate;
|
2013-01-06 21:18:48 -08:00
|
|
|
Ogre::Vector3 mLastPosition;
|
|
|
|
|
2013-02-05 16:29:51 -08:00
|
|
|
std::vector<Ogre::SkeletonPtr> mSkeletonSources;
|
|
|
|
|
2013-01-17 13:18:40 -08:00
|
|
|
NifOgre::TextKeyMap *mCurrentKeys;
|
|
|
|
NifOgre::TextKeyMap::const_iterator mNextKey;
|
2013-01-30 07:34:07 -08:00
|
|
|
Ogre::Animation *mCurrentAnim;
|
|
|
|
float mCurrentTime;
|
2013-02-23 05:15:10 -08:00
|
|
|
float mStopTime;
|
2013-01-29 00:43:42 -08:00
|
|
|
bool mPlaying;
|
2013-01-30 07:34:07 -08:00
|
|
|
bool mLooping;
|
2013-01-21 22:51:13 -08:00
|
|
|
|
2013-02-15 02:15:39 -08:00
|
|
|
float mAnimVelocity;
|
2013-01-18 21:40:47 -08:00
|
|
|
float mAnimSpeedMult;
|
2013-01-07 05:56:03 -08:00
|
|
|
|
2013-02-22 09:22:06 -08:00
|
|
|
void calcAnimVelocity();
|
|
|
|
|
2013-01-30 09:29:16 -08:00
|
|
|
/* Applies the given animation to the given skeleton instance, using the specified time. */
|
2013-01-30 07:04:18 -08:00
|
|
|
void applyAnimation(const Ogre::Animation *anim, float time, Ogre::SkeletonInstance *skel);
|
|
|
|
|
2013-01-30 09:29:16 -08:00
|
|
|
/* 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);
|
|
|
|
|
2013-01-18 17:05:58 -08:00
|
|
|
/* Updates the animation to the specified time, and returns the movement
|
|
|
|
* vector since the last update or reset. */
|
2013-01-18 16:21:29 -08:00
|
|
|
Ogre::Vector3 updatePosition(float time);
|
2012-04-23 15:27:03 +02:00
|
|
|
|
2013-02-23 05:15:10 -08:00
|
|
|
/* 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);
|
2012-07-24 13:51:48 -07:00
|
|
|
|
2013-02-23 14:39:01 -08:00
|
|
|
bool handleEvent(float time, const std::string &evt);
|
|
|
|
|
2013-02-23 03:34:03 -08:00
|
|
|
/* Specifies a list of skeleton names to use as animation sources. */
|
|
|
|
void setAnimationSources(const std::vector<std::string> &names);
|
|
|
|
|
|
|
|
/* Specifies a single skeleton name to use as an animation source. */
|
|
|
|
void setAnimationSource(const std::string &name)
|
|
|
|
{
|
|
|
|
std::vector<std::string> names(1, name);
|
|
|
|
setAnimationSources(names);
|
|
|
|
}
|
2013-02-03 01:38:42 -08:00
|
|
|
|
2013-01-04 23:19:48 -08:00
|
|
|
void createEntityList(Ogre::SceneNode *node, const std::string &model);
|
|
|
|
|
2012-07-12 20:12:18 -07:00
|
|
|
public:
|
2013-01-06 17:05:48 -08:00
|
|
|
Animation(const MWWorld::Ptr &ptr);
|
2012-07-12 20:12:18 -07:00
|
|
|
virtual ~Animation();
|
2012-07-20 00:53:12 -07:00
|
|
|
|
2013-01-16 11:01:08 -08:00
|
|
|
void setController(MWMechanics::CharacterController *controller);
|
2013-01-19 21:55:04 -08:00
|
|
|
|
2013-02-23 10:12:36 -08:00
|
|
|
void updatePtr(const MWWorld::Ptr &ptr);
|
|
|
|
|
2013-01-19 21:55:04 -08:00
|
|
|
bool hasAnimation(const std::string &anim);
|
2013-01-16 15:00:06 -08:00
|
|
|
|
2013-01-18 14:25:32 -08:00
|
|
|
// 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);
|
|
|
|
|
2013-02-15 02:15:39 -08:00
|
|
|
void setSpeed(float speed);
|
2013-01-18 21:40:47 -08:00
|
|
|
|
2013-02-19 04:01:33 -08:00
|
|
|
void setLooping(bool loop);
|
|
|
|
|
2013-02-23 05:15:10 -08:00
|
|
|
void play(const std::string &groupname, const std::string &start, const std::string &stop, bool loop);
|
2013-01-18 16:21:29 -08:00
|
|
|
virtual Ogre::Vector3 runAnimation(float timepassed);
|
2011-11-24 01:48:54 -05:00
|
|
|
};
|
2012-07-12 20:12:18 -07:00
|
|
|
|
2011-11-24 01:48:54 -05:00
|
|
|
}
|
2012-03-25 21:56:22 +02:00
|
|
|
#endif
|