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