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-04-11 02:58:17 +00:00
|
|
|
#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
|
|
|
|
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-04-05 17:13:54 +00:00
|
|
|
class AnimationValue : public Ogre::ControllerValue<Ogre::Real>
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
Animation *mAnimation;
|
2013-04-23 06:35:50 +00:00
|
|
|
size_t mIndex;
|
2013-04-05 17:13:54 +00:00
|
|
|
|
|
|
|
public:
|
2013-04-23 06:35:50 +00:00
|
|
|
AnimationValue(Animation *anim, size_t layeridx)
|
|
|
|
: mAnimation(anim), mIndex(layeridx)
|
2013-04-05 17:13:54 +00:00
|
|
|
{ }
|
|
|
|
|
2013-04-23 06:35:50 +00:00
|
|
|
virtual Ogre::Real getValue() const;
|
|
|
|
virtual void setValue(Ogre::Real value);
|
2013-04-05 17:13:54 +00:00
|
|
|
};
|
2013-04-21 00:13:27 +00:00
|
|
|
Ogre::SharedPtr<Ogre::ControllerValue<Ogre::Real> > mAnimationBaseValuePtr;
|
2013-04-05 17:13:54 +00:00
|
|
|
|
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-04-23 09:48:11 +00:00
|
|
|
struct ObjectInfo {
|
|
|
|
NifOgre::ObjectList mObjectList;
|
|
|
|
/* Bit-field specifying which animation layers this object list is
|
|
|
|
* explicitly animating on (1 = layer 0, 2 = layer 1, 4 = layer 2.
|
|
|
|
* etc).
|
|
|
|
*/
|
|
|
|
int mActiveLayers;
|
|
|
|
};
|
|
|
|
|
2013-04-14 23:56:35 +00:00
|
|
|
Ogre::SceneNode *mInsert;
|
|
|
|
Ogre::Entity *mSkelBase;
|
2013-04-23 09:48:11 +00:00
|
|
|
std::vector<ObjectInfo> mObjects;
|
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-04-22 11:10:46 +00:00
|
|
|
NifOgre::NodeTargetValue<Ogre::Real> *mNonAccumCtrl;
|
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-04-23 06:35:50 +00:00
|
|
|
static const size_t sMaxLayers = 1;
|
|
|
|
struct AnimLayer {
|
|
|
|
std::string mGroupName;
|
|
|
|
std::vector<Ogre::Controller<Ogre::Real> > *mControllers;
|
|
|
|
const NifOgre::TextKeyMap *mTextKeys;
|
|
|
|
NifOgre::TextKeyMap::const_iterator mStartKey;
|
|
|
|
NifOgre::TextKeyMap::const_iterator mLoopStartKey;
|
|
|
|
NifOgre::TextKeyMap::const_iterator mStopKey;
|
|
|
|
NifOgre::TextKeyMap::const_iterator mNextKey;
|
|
|
|
|
|
|
|
float mTime;
|
|
|
|
|
|
|
|
bool mPlaying;
|
|
|
|
bool mLooping;
|
|
|
|
|
|
|
|
AnimLayer();
|
|
|
|
} mLayer[sMaxLayers];
|
|
|
|
|
2013-04-23 03:41:54 +00:00
|
|
|
static float calcAnimVelocity(const NifOgre::TextKeyMap &keys,
|
|
|
|
NifOgre::NodeTargetValue<Ogre::Real> *nonaccumctrl,
|
|
|
|
const std::string &groupname);
|
2013-02-22 17:22:06 +00:00
|
|
|
|
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-04-07 23:21:45 +00:00
|
|
|
/* 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();
|
2012-04-23 13:27:03 +00:00
|
|
|
|
2013-04-23 03:59:55 +00:00
|
|
|
static NifOgre::TextKeyMap::const_iterator findGroupStart(const NifOgre::TextKeyMap &keys, const std::string &groupname);
|
|
|
|
|
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
|
2013-04-23 03:41:54 +00:00
|
|
|
* the marker is not found, or if the markers are the same, it returns
|
|
|
|
* false.
|
2013-02-23 13:15:10 +00:00
|
|
|
*/
|
2013-04-23 06:35:50 +00:00
|
|
|
bool reset(size_t layeridx, const NifOgre::TextKeyMap &keys, NifOgre::NodeTargetValue<Ogre::Real> *nonaccumctrl, const std::string &groupname, const std::string &start, const std::string &stop);
|
2012-07-24 20:51:48 +00:00
|
|
|
|
2013-04-23 06:35:50 +00:00
|
|
|
void doLoop(size_t layeridx);
|
2013-04-22 12:08:52 +00:00
|
|
|
|
2013-04-23 06:35:50 +00:00
|
|
|
bool handleTextKey(size_t layeridx, const NifOgre::TextKeyMap::const_iterator &key);
|
2013-02-23 22:39:01 +00:00
|
|
|
|
2013-04-16 01:55:28 +00:00
|
|
|
void addObjectList(Ogre::SceneNode *node, const std::string &model, bool baseonly);
|
2013-04-07 19:41:27 +00:00
|
|
|
static void destroyObjectList(Ogre::SceneManager *sceneMgr, NifOgre::ObjectList &objects);
|
2013-01-05 07:19:48 +00:00
|
|
|
|
2013-04-19 09:01:50 +00:00
|
|
|
static void setRenderProperties(const NifOgre::ObjectList &objlist, Ogre::uint32 visflags, Ogre::uint8 solidqueue, Ogre::uint8 transqueue);
|
|
|
|
|
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-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);
|
2013-04-08 12:48:52 +00:00
|
|
|
|
|
|
|
Ogre::Node *getNode(const std::string &name);
|
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
|