OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
MWRender::Animation Class Reference

#include <animation.hpp>

Inheritance diagram for MWRender::Animation:
Collaboration diagram for MWRender::Animation:

Classes

class  AnimationTime
 
struct  AnimPriority
 Holds an animation priority value for each BoneGroup. More...
 
struct  AnimSource
 
struct  AnimState
 
struct  EffectParams
 
class  NullAnimationTime
 
class  TextKeyListener
 

Public Types

enum  BoneGroup { BoneGroup_LowerBody = 0, BoneGroup_Torso, BoneGroup_LeftArm, BoneGroup_RightArm }
 
enum  BlendMask {
  BlendMask_LowerBody = 1<<0, BlendMask_Torso = 1<<1, BlendMask_LeftArm = 1<<2, BlendMask_RightArm = 1<<3,
  BlendMask_UpperBody = BlendMask_Torso | BlendMask_LeftArm | BlendMask_RightArm, BlendMask_All = BlendMask_LowerBody | BlendMask_UpperBody
}
 

Public Member Functions

void setTextKeyListener (TextKeyListener *listener)
 
 Animation (const MWWorld::Ptr &ptr, osg::ref_ptr< osg::Group > parentNode, Resource::ResourceSystem *resourceSystem)
 
virtual ~Animation ()
 
MWWorld::ConstPtr getPtr () const
 
void setActive (bool active)
 
osg::Group * getOrCreateObjectRoot ()
 
osg::Group * getObjectRoot ()
 
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. More...
 
void removeEffect (int effectId)
 
void getLoopingEffects (std::vector< int > &out) const
 
void addSpellCastGlow (const ESM::MagicEffect *effect, float glowDuration=1.5)
 
virtual void updatePtr (const MWWorld::Ptr &ptr)
 
bool hasAnimation (const std::string &anim) const
 
void setAccumulation (const osg::Vec3f &accum)
 
void play (const std::string &groupname, const AnimPriority &priority, int blendMask, bool autodisable, float speedmult, const std::string &start, const std::string &stop, float startpoint, size_t loops, bool loopfallback=false)
 
void adjustSpeedMult (const std::string &groupname, float speedmult)
 
bool isPlaying (const std::string &groupname) const
 
bool upperBodyReady () const
 Returns true if no important animations are currently playing on the upper body. More...
 
bool getInfo (const std::string &groupname, float *complete=NULL, float *speedmult=NULL) const
 
float getStartTime (const std::string &groupname) const
 Get the absolute position in the animation track of the first text key with the given group. More...
 
float getTextKeyTime (const std::string &textKey) const
 Get the absolute position in the animation track of the text key. More...
 
float getCurrentTime (const std::string &groupname) const
 Get the current absolute position in the animation track for the animation that is currently playing from the given group. More...
 
size_t getCurrentLoopCount (const std::string &groupname) const
 
void disable (const std::string &groupname)
 
float getVelocity (const std::string &groupname) const
 
virtual osg::Vec3f runAnimation (float duration)
 
void setLoopingEnabled (const std::string &groupname, bool enabled)
 
void updateEffects (float duration)
 This is typically called as part of runAnimation, but may be called manually if needed. More...
 
const osg::Node * getNode (const std::string &name) const
 
virtual void showWeapons (bool showWeapon)
 
virtual void showCarriedLeft (bool show)
 
virtual void setWeaponGroup (const std::string &group)
 
virtual void setVampire (bool vampire)
 
void setAlpha (float alpha)
 A value < 1 makes the animation translucent, 1.f = fully opaque. More...
 
virtual void setPitchFactor (float factor)
 
virtual void attachArrow ()
 
virtual void releaseArrow (float attackStrength)
 
virtual void enableHeadAnimation (bool enable)
 
virtual void setLightEffect (float effect)
 
virtual void setHeadPitch (float pitchRadians)
 
virtual void setHeadYaw (float yawRadians)
 
virtual float getHeadPitch () const
 
virtual float getHeadYaw () const
 
virtual void setAccurateAiming (bool enabled)
 

Static Public Attributes

static const size_t sNumBlendMasks = 4
 

Protected Types

typedef std::map< std::string,
AnimState
AnimStateMap
 
typedef std::vector
< boost::shared_ptr
< AnimSource > > 
AnimSourceList
 
typedef std::multimap
< osg::ref_ptr< osg::Node >
, osg::ref_ptr
< osg::NodeCallback > > 
ControllerMap
 
typedef std::map< std::string,
osg::ref_ptr
< osg::MatrixTransform > > 
NodeMap
 

Protected Member Functions

const NodeMapgetNodeMap () const
 
void resetActiveGroups ()
 
size_t detectBlendMask (const osg::Node *node) const
 
void updatePosition (float oldtime, float newtime, osg::Vec3f &position)
 
bool reset (AnimState &state, const std::multimap< float, std::string > &keys, const std::string &groupname, const std::string &start, const std::string &stop, float startpoint, bool loopfallback)
 
void handleTextKey (AnimState &state, const std::string &groupname, const std::multimap< float, std::string >::const_iterator &key, const std::multimap< float, std::string > &map)
 
void setObjectRoot (const std::string &model, bool forceskeleton, bool baseonly, bool isCreature)
 
void addAnimSource (const std::string &model)
 
void addExtraLight (osg::ref_ptr< osg::Group > parent, const ESM::Light *light)
 
void clearAnimSources ()
 
virtual void addControllers ()
 
osg::Vec4f getEnchantmentColor (const MWWorld::ConstPtr &item) const
 
void addGlow (osg::ref_ptr< osg::Node > node, osg::Vec4f glowColor, float glowDuration=-1)
 
virtual void setRenderBin ()
 Set the render bin for this animation's object root. May be customized by subclasses. More...
 

Protected Attributes

AnimStateMap mStates
 
AnimSourceList mAnimSources
 
osg::ref_ptr< osg::Group > mInsert
 
osg::ref_ptr< osg::Group > mObjectRoot
 
SceneUtil::SkeletonmSkeleton
 
osg::ref_ptr< osg::Node > mAccumRoot
 
osg::ref_ptr
< NifOsg::KeyframeController
mAccumCtrl
 
osg::ref_ptr
< ResetAccumRootCallback
mResetAccumRootCallback
 
ControllerMap mActiveControllers
 
boost::shared_ptr< AnimationTimemAnimationTimePtr [sNumBlendMasks]
 
NodeMap mNodeMap
 
bool mNodeMapCreated
 
MWWorld::Ptr mPtr
 
Resource::ResourceSystemmResourceSystem
 
osg::Vec3f mAccumulate
 
std::vector< EffectParamsmEffects
 
TextKeyListenermTextKeyListener
 
osg::ref_ptr< RotateControllermHeadController
 
float mHeadYawRadians
 
float mHeadPitchRadians
 
osg::ref_ptr
< SceneUtil::LightSource
mGlowLight
 
osg::ref_ptr< GlowUpdatermGlowUpdater
 
float mAlpha
 
osg::ref_ptr
< SceneUtil::LightListCallback
mLightListCallback
 

Private Member Functions

 Animation (const Animation &)
 
void operator= (Animation &)
 

Member Typedef Documentation

typedef std::vector<boost::shared_ptr<AnimSource> > MWRender::Animation::AnimSourceList
protected
typedef std::map<std::string,AnimState> MWRender::Animation::AnimStateMap
protected
typedef std::multimap<osg::ref_ptr<osg::Node>, osg::ref_ptr<osg::NodeCallback> > MWRender::Animation::ControllerMap
protected
typedef std::map<std::string, osg::ref_ptr<osg::MatrixTransform> > MWRender::Animation::NodeMap
protected

Member Enumeration Documentation

Enumerator
BlendMask_LowerBody 
BlendMask_Torso 
BlendMask_LeftArm 
BlendMask_RightArm 
BlendMask_UpperBody 
BlendMask_All 
Enumerator
BoneGroup_LowerBody 
BoneGroup_Torso 
BoneGroup_LeftArm 
BoneGroup_RightArm 

Constructor & Destructor Documentation

MWRender::Animation::Animation ( const MWWorld::Ptr ptr,
osg::ref_ptr< osg::Group >  parentNode,
Resource::ResourceSystem resourceSystem 
)

Here is the call graph for this function:

MWRender::Animation::~Animation ( )
virtual

Here is the call graph for this function:

MWRender::Animation::Animation ( const Animation )
private

Member Function Documentation

void MWRender::Animation::addAnimSource ( const std::string &  model)
protected

Adds the keyframe controllers in the specified model as a new animation source. Note that the .nif file extension will be replaced with .kf.

Note
Later added animation sources have the highest priority when it comes to finding a particular animation.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::addControllers ( )
protectedvirtual

Provided to allow derived classes adding their own controllers. Note, the controllers must be added to mActiveControllers so they get cleaned up properly on the next controller rebuild. A controller rebuild may be necessary to ensure correct ordering.

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the call graph for this function:

Here is the caller graph for this function:

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 by which you can identify it later. If this is not wanted, set to -1.
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 - if empty, do not override
Note
Will not add an effect twice.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::addExtraLight ( osg::ref_ptr< osg::Group >  parent,
const ESM::Light light 
)
protected

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

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::addGlow ( osg::ref_ptr< osg::Node >  node,
osg::Vec4f  glowColor,
float  glowDuration = -1 
)
protected

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::addSpellCastGlow ( const ESM::MagicEffect effect,
float  glowDuration = 1.5 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::adjustSpeedMult ( const std::string &  groupname,
float  speedmult 
)

Adjust the speed multiplier of an already playing animation.

Here is the caller graph for this function:

virtual void MWRender::Animation::attachArrow ( )
inlinevirtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the caller graph for this function:

void MWRender::Animation::clearAnimSources ( )
protected

Here is the caller graph for this function:

size_t MWRender::Animation::detectBlendMask ( const osg::Node *  node) const
protected

Here is the caller graph for this function:

void MWRender::Animation::disable ( const std::string &  groupname)

Disables the specified animation group;

Parameters
groupnameAnimation group to disable.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void MWRender::Animation::enableHeadAnimation ( bool  enable)
inlinevirtual

Reimplemented in MWRender::NpcAnimation.

Here is the caller graph for this function:

size_t MWRender::Animation::getCurrentLoopCount ( const std::string &  groupname) const

Here is the caller graph for this function:

float MWRender::Animation::getCurrentTime ( const std::string &  groupname) const

Get the current absolute position in the animation track for the animation that is currently playing from the given group.

Here is the caller graph for this function:

osg::Vec4f MWRender::Animation::getEnchantmentColor ( const MWWorld::ConstPtr item) const
protected

Here is the call graph for this function:

Here is the caller graph for this function:

float MWRender::Animation::getHeadPitch ( ) const
virtual

Here is the caller graph for this function:

float MWRender::Animation::getHeadYaw ( ) const
virtual

Here is the caller graph for this function:

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.

Here is the caller graph for this function:

void MWRender::Animation::getLoopingEffects ( std::vector< int > &  out) const

Here is the caller graph for this function:

const osg::Node * MWRender::Animation::getNode ( const std::string &  name) const

Return a node with the specified name, or NULL if not existing.

Note
The matching is case-insensitive.

Here is the call graph for this function:

Here is the caller graph for this function:

const Animation::NodeMap & MWRender::Animation::getNodeMap ( ) const
protected

Here is the caller graph for this function:

osg::Group * MWRender::Animation::getObjectRoot ( )
osg::Group * MWRender::Animation::getOrCreateObjectRoot ( )

Here is the caller graph for this function:

MWWorld::ConstPtr MWRender::Animation::getPtr ( ) const
float MWRender::Animation::getStartTime ( const std::string &  groupname) const

Get the absolute position in the animation track of the first text key with the given group.

Here is the call graph for this function:

Here is the caller graph for this function:

float MWRender::Animation::getTextKeyTime ( const std::string &  textKey) const

Get the absolute position in the animation track of the text key.

Here is the caller graph for this function:

float MWRender::Animation::getVelocity ( const std::string &  groupname) const

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

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::handleTextKey ( AnimState state,
const std::string &  groupname,
const std::multimap< float, std::string >::const_iterator &  key,
const std::multimap< float, std::string > &  map 
)
protected

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWRender::Animation::hasAnimation ( const std::string &  anim) const

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWRender::Animation::isPlaying ( const std::string &  groupname) const

Returns true if the named animation group is playing.

Here is the caller graph for this function:

void MWRender::Animation::operator= ( Animation )
private
void MWRender::Animation::play ( const std::string &  groupname,
const AnimPriority priority,
int  blendMask,
bool  autodisable,
float  speedmult,
const std::string &  start,
const std::string &  stop,
float  startpoint,
size_t  loops,
bool  loopfallback = false 
)

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.
blendMaskBone 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 may fall back to "start" and "stop", but only if the loopFallback parameter is true.
loopFallbackAllow looping an animation that has no loop keys, i.e. fall back to use the "start" and "stop" keys for looping?

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void MWRender::Animation::releaseArrow ( float  attackStrength)
inlinevirtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the caller graph for this function:

void MWRender::Animation::removeEffect ( int  effectId)

Here is the caller graph for this function:

bool MWRender::Animation::reset ( AnimState state,
const std::multimap< float, std::string > &  keys,
const std::string &  groupname,
const std::string &  start,
const std::string &  stop,
float  startpoint,
bool  loopfallback 
)
protected

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::resetActiveGroups ( )
protected

Here is the call graph for this function:

Here is the caller graph for this function:

osg::Vec3f MWRender::Animation::runAnimation ( float  duration)
virtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::setAccumulation ( const osg::Vec3f &  accum)

Here is the caller graph for this function:

virtual void MWRender::Animation::setAccurateAiming ( bool  enabled)
inlinevirtual

Reimplemented in MWRender::NpcAnimation.

Here is the caller graph for this function:

void MWRender::Animation::setActive ( bool  active)

Set active flag on the object skeleton, if one exists.

See Also
SceneUtil::Skeleton::setActive

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::setAlpha ( float  alpha)

A value < 1 makes the animation translucent, 1.f = fully opaque.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWRender::Animation::setHeadPitch ( float  pitchRadians)
virtual

Here is the caller graph for this function:

void MWRender::Animation::setHeadYaw ( float  yawRadians)
virtual

Here is the caller graph for this function:

void MWRender::Animation::setLightEffect ( float  effect)
virtual

Makes this object glow, by placing a Light in its center.

Parameters
effectControls the radius and intensity of the light.

Here is the caller graph for this function:

void MWRender::Animation::setLoopingEnabled ( const std::string &  groupname,
bool  enabled 
)

Here is the caller graph for this function:

void MWRender::Animation::setObjectRoot ( const std::string &  model,
bool  forceskeleton,
bool  baseonly,
bool  isCreature 
)
protected

Sets the root model of the object.

Note that you must make sure all animation sources are cleared before resetting the object root. All nodes previously retrieved with getNode will also become invalidated.

Parameters
forceskeletonWrap the object root in a Skeleton, even if it contains no skinned parts. Use this if you intend to add skinned parts manually.
baseonlyIf true, then any meshes or particle systems in the model are ignored (useful for NPCs, where only the skeleton is needed for the root, and the actual NPC parts are then assembled from separate files).

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void MWRender::Animation::setPitchFactor ( float  factor)
inlinevirtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the caller graph for this function:

void MWRender::Animation::setRenderBin ( )
protectedvirtual

Set the render bin for this animation's object root. May be customized by subclasses.

Reimplemented in MWRender::NpcAnimation.

Here is the caller graph for this function:

void MWRender::Animation::setTextKeyListener ( Animation::TextKeyListener listener)

Here is the caller graph for this function:

virtual void MWRender::Animation::setVampire ( bool  vampire)
inlinevirtual

Reimplemented in MWRender::NpcAnimation.

Here is the caller graph for this function:

virtual void MWRender::Animation::setWeaponGroup ( const std::string &  group)
inlinevirtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the caller graph for this function:

virtual void MWRender::Animation::showCarriedLeft ( bool  show)
inlinevirtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the caller graph for this function:

virtual void MWRender::Animation::showWeapons ( bool  showWeapon)
inlinevirtual

Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.

Here is the caller graph for this function:

void MWRender::Animation::updateEffects ( float  duration)

This is typically called as part of runAnimation, but may be called manually if needed.

Here is the caller graph for this function:

void MWRender::Animation::updatePosition ( float  oldtime,
float  newtime,
osg::Vec3f &  position 
)
protected

Here is the caller graph for this function:

void MWRender::Animation::updatePtr ( const MWWorld::Ptr ptr)
virtual

Reimplemented in MWRender::NpcAnimation.

Here is the caller graph for this function:

bool MWRender::Animation::upperBodyReady ( ) const

Returns true if no important animations are currently playing on the upper body.

Here is the caller graph for this function:

Member Data Documentation

osg::ref_ptr<NifOsg::KeyframeController> MWRender::Animation::mAccumCtrl
protected
osg::ref_ptr<osg::Node> MWRender::Animation::mAccumRoot
protected
osg::Vec3f MWRender::Animation::mAccumulate
protected
ControllerMap MWRender::Animation::mActiveControllers
protected
float MWRender::Animation::mAlpha
protected
boost::shared_ptr<AnimationTime> MWRender::Animation::mAnimationTimePtr[sNumBlendMasks]
protected
AnimSourceList MWRender::Animation::mAnimSources
protected
std::vector<EffectParams> MWRender::Animation::mEffects
protected
osg::ref_ptr<SceneUtil::LightSource> MWRender::Animation::mGlowLight
protected
osg::ref_ptr<GlowUpdater> MWRender::Animation::mGlowUpdater
protected
osg::ref_ptr<RotateController> MWRender::Animation::mHeadController
protected
float MWRender::Animation::mHeadPitchRadians
protected
float MWRender::Animation::mHeadYawRadians
protected
osg::ref_ptr<osg::Group> MWRender::Animation::mInsert
protected
osg::ref_ptr<SceneUtil::LightListCallback> MWRender::Animation::mLightListCallback
protected
NodeMap MWRender::Animation::mNodeMap
mutableprotected
bool MWRender::Animation::mNodeMapCreated
mutableprotected
osg::ref_ptr<osg::Group> MWRender::Animation::mObjectRoot
protected
MWWorld::Ptr MWRender::Animation::mPtr
protected
osg::ref_ptr<ResetAccumRootCallback> MWRender::Animation::mResetAccumRootCallback
protected
Resource::ResourceSystem* MWRender::Animation::mResourceSystem
protected
SceneUtil::Skeleton* MWRender::Animation::mSkeleton
protected
AnimStateMap MWRender::Animation::mStates
protected
TextKeyListener* MWRender::Animation::mTextKeyListener
protected
const size_t MWRender::Animation::sNumBlendMasks = 4
static

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