Deals with synchronisation issues between raw animation data (CModel, CSkeletonAnim) and the simulation system (via CUnit), providing a simple fire-and-forget API to play animations.
More...
#include <UnitAnimation.h>
|
| CUnitAnimation (entity_id_t ent, CModel *model, CObjectEntry *object) |
| Construct for a given unit, defaulting to the "idle" animation. More...
|
|
void | SetEntityID (entity_id_t ent) |
| Change the entity ID associated with this animation (currently used for playing locational sound effects). More...
|
|
void | SetAnimationState (const CStr &name, bool once, float speed, float desync, const CStrW &actionSound) |
| Start playing an animation. More...
|
|
void | SetAnimationSyncRepeat (float repeatTime) |
| Adjust the speed of the current animation, so that Update(repeatTime) will do a complete animation loop. More...
|
|
void | SetAnimationSyncOffset (float actionTime) |
| Adjust the offset of the current animation, so that Update(actionTime) will advance it to the 'action' point defined in the actor. More...
|
|
void | Update (float time) |
| Advance the animation state. More...
|
|
void | ReloadUnit (CModel *model, const CObjectEntry *object) |
| Regenerate internal animation state from the models in the current unit. More...
|
|
Deals with synchronisation issues between raw animation data (CModel, CSkeletonAnim) and the simulation system (via CUnit), providing a simple fire-and-forget API to play animations.
(This is really just a component of CUnit and could probably be merged back into that class.)
Definition at line 35 of file UnitAnimation.h.
Construct for a given unit, defaulting to the "idle" animation.
Definition at line 43 of file UnitAnimation.cpp.
Regenerate internal animation state from the models in the current unit.
This should be called whenever the unit is changed externally, to keep this in sync.
Definition at line 86 of file UnitAnimation.cpp.
void CUnitAnimation::SetAnimationState |
( |
const CStr & |
name, |
|
|
bool |
once, |
|
|
float |
speed, |
|
|
float |
desync, |
|
|
const CStrW & |
actionSound |
|
) |
| |
Start playing an animation.
The unit's actor defines the available animations, and if more than one is available then one is picked at random (with a new random choice each loop). By default, animations start immediately and run at the given speed with no syncing. Use SetAnimationSync after this to force a specific timing, if it needs to match the simulation timing. Alternatively, set desync
to a non-zero value (e.g. 0.05) to slightly randomise the offset and speed, so units don't all move in lockstep.
- Parameters
-
name | animation's name ("idle", "walk", etc) |
once | if true then the animation freezes on its last frame; otherwise it loops |
speed | fraction of actor-defined speed to play back at (should typically be 1.0) |
desync | maximum fraction of length/speed to randomly adjust timings (or 0.0 for no desyncing) |
actionSound | sound group name to be played at the 'action' point in the animation, or empty string |
Definition at line 95 of file UnitAnimation.cpp.
void CUnitAnimation::SetAnimationSyncOffset |
( |
float |
actionTime | ) |
|
Adjust the offset of the current animation, so that Update(actionTime) will advance it to the 'action' point defined in the actor.
This must be called after SetAnimationSyncRepeat sets the speed.
- Parameters
-
actionTime | time between now and when the action should occur, in msec |
Definition at line 118 of file UnitAnimation.cpp.
void CUnitAnimation::SetAnimationSyncRepeat |
( |
float |
repeatTime | ) |
|
Adjust the speed of the current animation, so that Update(repeatTime) will do a complete animation loop.
- Parameters
-
repeatTime | time for complete loop of animation, in msec |
Definition at line 113 of file UnitAnimation.cpp.
Change the entity ID associated with this animation (currently used for playing locational sound effects).
Definition at line 50 of file UnitAnimation.cpp.
void CUnitAnimation::Update |
( |
float |
time | ) |
|
CStrW CUnitAnimation::m_ActionSound |
|
private |
float CUnitAnimation::m_Desync |
|
private |
bool CUnitAnimation::m_Looping |
|
private |
CModel* CUnitAnimation::m_Model |
|
private |
float CUnitAnimation::m_OriginalSpeed |
|
private |
float CUnitAnimation::m_Speed |
|
private |
CStr CUnitAnimation::m_State |
|
private |
float CUnitAnimation::m_SyncRepeatTime |
|
private |
The documentation for this class was generated from the following files: