OpenMW
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions
MWRender::Animation Class Reference

#include <animation.hpp>

List of all members.

Classes

class  AnimationValue
struct  AnimSource
struct  AnimState
class  EffectAnimationValue
struct  EffectParams
class  NullAnimationValue

Public Types

enum  Group {
  Group_LowerBody = 1<<0, Group_Torso = 1<<1, Group_LeftArm = 1<<2, Group_RightArm = 1<<3,
  Group_UpperBody = Group_Torso | Group_LeftArm | Group_RightArm, Group_All = Group_LowerBody | Group_UpperBody
}

Public Member Functions

 Animation (const MWWorld::Ptr &ptr, Ogre::SceneNode *node)
virtual ~Animation ()
void addEffect (const std::string &model, int effectId, bool loop=false, const std::string &bonename="", std::string texture="")
 Add an effect mesh attached to a bone or the insert scene node.
void removeEffect (int effectId)
void getLoopingEffects (std::vector< int > &out)
virtual void preRender (Ogre::Camera *camera)
 Prepare this animation for being rendered with camera (rotates billboard nodes)
virtual void setAlpha (float alpha)
void updatePtr (const MWWorld::Ptr &ptr)
bool hasAnimation (const std::string &anim)
void setAccumulation (const Ogre::Vector3 &accum)
void play (const std::string &groupname, int priority, int groups, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops)
bool isPlaying (const std::string &groupname) const
bool isPlaying (Group group) const
bool getInfo (const std::string &groupname, float *complete=NULL, float *speedmult=NULL) const
void disable (const std::string &groupname)
float getVelocity (const std::string &groupname) const
virtual Ogre::Vector3 runAnimation (float duration)
virtual void showWeapons (bool showWeapon)
virtual void showCarriedLeft (bool show)
void enableLights (bool enable)
Ogre::AxisAlignedBox getWorldBounds ()
void setCamera (Camera *cam)
Ogre::Node * getNode (const std::string &name)
Ogre::TagPoint * attachObjectToBone (const Ogre::String &bonename, Ogre::MovableObject *obj)
void detachObjectFromBone (Ogre::MovableObject *obj)

Protected Types

typedef std::vector
< Ogre::SharedPtr< AnimSource > > 
AnimSourceList
typedef std::map< std::string,
AnimState
AnimStateMap
typedef std::map
< Ogre::MovableObject
*, std::string > 
ObjectAttachMap

Protected Member Functions

void resetActiveGroups ()
void updateSkeletonInstance (const Ogre::SkeletonInstance *skelsrc, Ogre::SkeletonInstance *skel)
void updatePosition (float oldtime, float newtime, Ogre::Vector3 &position)
bool reset (AnimState &state, const NifOgre::TextKeyMap &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint)
void handleTextKey (AnimState &state, const std::string &groupname, const NifOgre::TextKeyMap::const_iterator &key)
void setObjectRoot (const std::string &model, bool baseonly)
void addAnimSource (const std::string &model)
void addExtraLight (Ogre::SceneManager *sceneMgr, NifOgre::ObjectScenePtr objlist, const ESM::Light *light)
void clearAnimSources ()
Ogre::Vector3 getEnchantmentColor (MWWorld::Ptr item)

Static Protected Member Functions

static size_t detectAnimGroup (const Ogre::Node *node)
static float calcAnimVelocity (const NifOgre::TextKeyMap &keys, NifOgre::NodeTargetValue< Ogre::Real > *nonaccumctrl, const Ogre::Vector3 &accum, const std::string &groupname)
static
NifOgre::TextKeyMap::const_iterator 
findGroupStart (const NifOgre::TextKeyMap &keys, const std::string &groupname)
static void setRenderProperties (NifOgre::ObjectScenePtr objlist, Ogre::uint32 visflags, Ogre::uint8 solidqueue, Ogre::uint8 transqueue, Ogre::Real dist=0.0f, bool enchantedGlow=false, Ogre::Vector3 *glowColor=NULL)

Protected Attributes

std::vector< EffectParamsmEffects
MWWorld::Ptr mPtr
CameramCamera
Ogre::SceneNode * mInsert
Ogre::Entity * mSkelBase
NifOgre::ObjectScenePtr mObjectRoot
AnimSourceList mAnimSources
Ogre::Node * mAccumRoot
Ogre::Node * mNonAccumRoot
NifOgre::NodeTargetValue
< Ogre::Real > * 
mNonAccumCtrl
Ogre::Vector3 mAccumulate
AnimStateMap mStates
Ogre::SharedPtr< AnimationValuemAnimationValuePtr [sNumGroups]
Ogre::SharedPtr
< NullAnimationValue
mNullAnimationValuePtr
ObjectAttachMap mAttachedObjects

Static Protected Attributes

static const size_t sNumGroups = 4

Private Member Functions

void updateEffects (float duration)

Member Typedef Documentation

typedef std::vector< Ogre::SharedPtr<AnimSource> > MWRender::Animation::AnimSourceList [protected]
typedef std::map<std::string,AnimState> MWRender::Animation::AnimStateMap [protected]
typedef std::map<Ogre::MovableObject*,std::string> MWRender::Animation::ObjectAttachMap [protected]

Member Enumeration Documentation

Enumerator:
Group_LowerBody 
Group_Torso 
Group_LeftArm 
Group_RightArm 
Group_UpperBody 
Group_All 

Constructor & Destructor Documentation

MWRender::Animation::Animation ( const MWWorld::Ptr ptr,
Ogre::SceneNode *  node 
)

Member Function Documentation

void MWRender::Animation::addAnimSource ( const std::string &  model) [protected]
void MWRender::Animation::addEffect ( const std::string &  model,
int  effectId,
bool  loop = false,
const std::string &  bonename = "",
std::string  texture = "" 
)

Add an effect mesh attached to a bone or the insert scene node.

Parameters:
model
effectIdAn ID for this effect. Note that adding the same ID again won't add another effect.
loopLoop the effect. If false, it is removed automatically after it finishes playing. If true, you need to remove it manually using removeEffect when the effect should end.
bonenameBone to attach to, or empty string to use the scene node instead
textureoverride the texture specified in the model's materials
Note:
Will not add an effect twice.
void MWRender::Animation::addExtraLight ( Ogre::SceneManager *  sceneMgr,
NifOgre::ObjectScenePtr  objlist,
const ESM::Light light 
) [protected]

Adds an additional light to the given object list using the specified ESM record.

Ogre::TagPoint * MWRender::Animation::attachObjectToBone ( const Ogre::String &  bonename,
Ogre::MovableObject *  obj 
)
float MWRender::Animation::calcAnimVelocity ( const NifOgre::TextKeyMap keys,
NifOgre::NodeTargetValue< Ogre::Real > *  nonaccumctrl,
const Ogre::Vector3 &  accum,
const std::string &  groupname 
) [static, protected]
void MWRender::Animation::detachObjectFromBone ( Ogre::MovableObject *  obj)
size_t MWRender::Animation::detectAnimGroup ( const Ogre::Node *  node) [static, protected]
void MWRender::Animation::disable ( const std::string &  groupname)

Disables the specified animation group;

Parameters:
groupnameAnimation group to disable.
void MWRender::Animation::enableLights ( bool  enable)
NifOgre::TextKeyMap::const_iterator MWRender::Animation::findGroupStart ( const NifOgre::TextKeyMap keys,
const std::string &  groupname 
) [static, protected]
Ogre::Vector3 MWRender::Animation::getEnchantmentColor ( MWWorld::Ptr  item) [protected]
bool MWRender::Animation::getInfo ( const std::string &  groupname,
float *  complete = NULL,
float *  speedmult = NULL 
) const

Gets info about the given animation group.

Parameters:
groupnameAnimation group to check.
completeStores completion amount (0 = at start key, 0.5 = half way between start and stop keys), etc.
speedmultStores the animation speed multiplier
Returns:
True if the animation is active, false otherwise.
void MWRender::Animation::getLoopingEffects ( std::vector< int > &  out)
Ogre::Node * MWRender::Animation::getNode ( const std::string &  name)
float MWRender::Animation::getVelocity ( const std::string &  groupname) const

Retrieves the velocity (in units per second) that the animation will move.

Ogre::AxisAlignedBox MWRender::Animation::getWorldBounds ( )
void MWRender::Animation::handleTextKey ( AnimState state,
const std::string &  groupname,
const NifOgre::TextKeyMap::const_iterator &  key 
) [protected]
bool MWRender::Animation::hasAnimation ( const std::string &  anim)
bool MWRender::Animation::isPlaying ( const std::string &  groupname) const

Returns true if the named animation group is playing.

bool MWRender::Animation::isPlaying ( Group  group) const
void MWRender::Animation::play ( const std::string &  groupname,
int  priority,
int  groups,
bool  autodisable,
float  speedmult,
const std::string &  start,
const std::string &  stop,
float  startpoint,
size_t  loops 
)

Plays an animation.

Parameters:
groupnameName of the animation group to play.
priorityPriority of the animation. The animation will play on bone groups that don't have another animation set of a higher priority.
groupsBone groups to play the animation on.
autodisableAutomatically disable the animation when it stops playing.
speedmultSpeed multiplier for the animation.
startKey marker from which to start.
stopKey marker to stop at.
startpointHow far in between the two markers to start. 0 starts at the start marker, 1 starts at the stop marker.
loopsHow many times to loop the animation. This will use the "loop start" and "loop stop" markers if they exist, otherwise it will use "start" and "stop".
void MWRender::Animation::preRender ( Ogre::Camera *  camera) [virtual]

Prepare this animation for being rendered with camera (rotates billboard nodes)

Reimplemented in MWRender::NpcAnimation.

void MWRender::Animation::removeEffect ( int  effectId)
bool MWRender::Animation::reset ( AnimState state,
const NifOgre::TextKeyMap keys,
const std::string &  groupname,
const std::string &  start,
const std::string &  stop,
float  startpoint 
) [protected]
Ogre::Vector3 MWRender::Animation::runAnimation ( float  duration) [virtual]

Reimplemented in MWRender::NpcAnimation.

void MWRender::Animation::setAccumulation ( const Ogre::Vector3 &  accum)
virtual void MWRender::Animation::setAlpha ( float  alpha) [inline, virtual]

Reimplemented in MWRender::NpcAnimation.

void MWRender::Animation::setCamera ( Camera cam) [inline]
void MWRender::Animation::setObjectRoot ( const std::string &  model,
bool  baseonly 
) [protected]
void MWRender::Animation::setRenderProperties ( NifOgre::ObjectScenePtr  objlist,
Ogre::uint32  visflags,
Ogre::uint8  solidqueue,
Ogre::uint8  transqueue,
Ogre::Real  dist = 0.0f,
bool  enchantedGlow = false,
Ogre::Vector3 *  glowColor = NULL 
) [static, protected]
virtual void MWRender::Animation::showCarriedLeft ( bool  show) [inline, virtual]

Reimplemented in MWRender::NpcAnimation.

void MWRender::Animation::showWeapons ( bool  showWeapon) [virtual]

Reimplemented in MWRender::NpcAnimation.

void MWRender::Animation::updateEffects ( float  duration) [private]
void MWRender::Animation::updatePosition ( float  oldtime,
float  newtime,
Ogre::Vector3 &  position 
) [protected]
void MWRender::Animation::updateSkeletonInstance ( const Ogre::SkeletonInstance *  skelsrc,
Ogre::SkeletonInstance *  skel 
) [protected]

Member Data Documentation

Ogre::Node* MWRender::Animation::mAccumRoot [protected]
Ogre::Vector3 MWRender::Animation::mAccumulate [protected]
std::vector<EffectParams> MWRender::Animation::mEffects [protected]
Ogre::SceneNode* MWRender::Animation::mInsert [protected]
Ogre::Node* MWRender::Animation::mNonAccumRoot [protected]
Ogre::Entity* MWRender::Animation::mSkelBase [protected]
const size_t MWRender::Animation::sNumGroups = 4 [static, protected]

The documentation for this class was generated from the following files: