OpenMW
|
#include <animation.hpp>
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 NodeMap & | getNodeMap () 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::Skeleton * | mSkeleton |
osg::ref_ptr< osg::Node > | mAccumRoot |
osg::ref_ptr < NifOsg::KeyframeController > | mAccumCtrl |
osg::ref_ptr < ResetAccumRootCallback > | mResetAccumRootCallback |
ControllerMap | mActiveControllers |
boost::shared_ptr< AnimationTime > | mAnimationTimePtr [sNumBlendMasks] |
NodeMap | mNodeMap |
bool | mNodeMapCreated |
MWWorld::Ptr | mPtr |
Resource::ResourceSystem * | mResourceSystem |
osg::Vec3f | mAccumulate |
std::vector< EffectParams > | mEffects |
TextKeyListener * | mTextKeyListener |
osg::ref_ptr< RotateController > | mHeadController |
float | mHeadYawRadians |
float | mHeadPitchRadians |
osg::ref_ptr < SceneUtil::LightSource > | mGlowLight |
osg::ref_ptr< GlowUpdater > | mGlowUpdater |
float | mAlpha |
osg::ref_ptr < SceneUtil::LightListCallback > | mLightListCallback |
Private Member Functions | |
Animation (const Animation &) | |
void | operator= (Animation &) |
|
protected |
|
protected |
|
protected |
|
protected |
MWRender::Animation::Animation | ( | const MWWorld::Ptr & | ptr, |
osg::ref_ptr< osg::Group > | parentNode, | ||
Resource::ResourceSystem * | resourceSystem | ||
) |
|
virtual |
|
private |
|
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.
|
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.
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.
model | |
effectId | An ID for this effect by which you can identify it later. If this is not wanted, set to -1. |
loop | Loop 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. |
bonename | Bone to attach to, or empty string to use the scene node instead |
texture | override the texture specified in the model's materials - if empty, do not override |
|
protected |
Adds an additional light to the given node using the specified ESM record.
|
protected |
void MWRender::Animation::addSpellCastGlow | ( | const ESM::MagicEffect * | effect, |
float | glowDuration = 1.5 |
||
) |
void MWRender::Animation::adjustSpeedMult | ( | const std::string & | groupname, |
float | speedmult | ||
) |
Adjust the speed multiplier of an already playing animation.
|
inlinevirtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
|
protected |
|
protected |
void MWRender::Animation::disable | ( | const std::string & | groupname | ) |
Disables the specified animation group;
groupname | Animation group to disable. |
|
inlinevirtual |
size_t MWRender::Animation::getCurrentLoopCount | ( | const std::string & | groupname | ) | const |
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.
|
protected |
|
virtual |
|
virtual |
bool MWRender::Animation::getInfo | ( | const std::string & | groupname, |
float * | complete = NULL , |
||
float * | speedmult = NULL |
||
) | const |
Gets info about the given animation group.
groupname | Animation group to check. |
complete | Stores completion amount (0 = at start key, 0.5 = half way between start and stop keys), etc. |
speedmult | Stores the animation speed multiplier |
void MWRender::Animation::getLoopingEffects | ( | std::vector< int > & | out | ) | const |
const osg::Node * MWRender::Animation::getNode | ( | const std::string & | name | ) | const |
Return a node with the specified name, or NULL if not existing.
|
protected |
osg::Group * MWRender::Animation::getObjectRoot | ( | ) |
osg::Group * MWRender::Animation::getOrCreateObjectRoot | ( | ) |
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.
float MWRender::Animation::getTextKeyTime | ( | const std::string & | textKey | ) | const |
Get the absolute position in the animation track of the text key.
float MWRender::Animation::getVelocity | ( | const std::string & | groupname | ) | const |
Retrieves the velocity (in units per second) that the animation will move.
|
protected |
bool MWRender::Animation::hasAnimation | ( | const std::string & | anim | ) | const |
bool MWRender::Animation::isPlaying | ( | const std::string & | groupname | ) | const |
Returns true if the named animation group is playing.
|
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.
groupname | Name of the animation group to play. |
priority | Priority of the animation. The animation will play on bone groups that don't have another animation set of a higher priority. |
blendMask | Bone groups to play the animation on. |
autodisable | Automatically disable the animation when it stops playing. |
speedmult | Speed multiplier for the animation. |
start | Key marker from which to start. |
stop | Key marker to stop at. |
startpoint | How far in between the two markers to start. 0 starts at the start marker, 1 starts at the stop marker. |
loops | How 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. |
loopFallback | Allow looping an animation that has no loop keys, i.e. fall back to use the "start" and "stop" keys for looping? |
|
inlinevirtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
void MWRender::Animation::removeEffect | ( | int | effectId | ) |
|
protected |
|
protected |
|
virtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
void MWRender::Animation::setAccumulation | ( | const osg::Vec3f & | accum | ) |
|
inlinevirtual |
void MWRender::Animation::setActive | ( | bool | active | ) |
Set active flag on the object skeleton, if one exists.
void MWRender::Animation::setAlpha | ( | float | alpha | ) |
A value < 1 makes the animation translucent, 1.f = fully opaque.
|
virtual |
|
virtual |
|
virtual |
Makes this object glow, by placing a Light in its center.
effect | Controls the radius and intensity of the light. |
void MWRender::Animation::setLoopingEnabled | ( | const std::string & | groupname, |
bool | enabled | ||
) |
|
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.
forceskeleton | Wrap the object root in a Skeleton, even if it contains no skinned parts. Use this if you intend to add skinned parts manually. |
baseonly | If 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). |
|
inlinevirtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
|
protectedvirtual |
Set the render bin for this animation's object root. May be customized by subclasses.
Reimplemented in MWRender::NpcAnimation.
void MWRender::Animation::setTextKeyListener | ( | Animation::TextKeyListener * | listener | ) |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
|
inlinevirtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
|
inlinevirtual |
Reimplemented in MWRender::NpcAnimation, and MWRender::CreatureWeaponAnimation.
void MWRender::Animation::updateEffects | ( | float | duration | ) |
This is typically called as part of runAnimation, but may be called manually if needed.
|
protected |
|
virtual |
bool MWRender::Animation::upperBodyReady | ( | ) | const |
Returns true if no important animations are currently playing on the upper body.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |