Animating a model: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
Line 24: Line 24:
If your entity inherits from <code>CBaseAnimatingOverlay</code> you can blend up to 15 sequences on top of the standard one.
If your entity inherits from <code>CBaseAnimatingOverlay</code> you can blend up to 15 sequences on top of the standard one.


{{tip|Layers are played in order of <code>priority</code>.}}
; <code>[[int]] AddGesture([[Activity]] activity, [[bool]] autokill=true)</code>
: Helper which creates a layer with the given activity. Return value is the layer's index, or -1 on failure.
; <code>void RestartGesture([[Activity]] activity, [[bool]] addifmissing=true, [[bool]] autokill=true)</code>
: Resets the first layer playing the given activity to its first frame. Optionally creates a new layer with the gesture if nothing is found.
; <code>[[int]] FindGestureLayer([[Activity]] activity)</code>
: Searches for a active layer playing the given activity. Returns -1 on failure.
; <code>[[int]] AddGestureSequence([[int]] sequence, [[bool]] autokill=true)</code>
: As <code>AddGesture()</code>, but doesn't require an activity.
; <code>[[int]] AddLayeredSequence([[int]] sequence, [[int]] priority)</code>
; <code>[[int]] AddLayeredSequence([[int]] sequence, [[int]] priority)</code>
: Adds a new layer which plays the given sequence. Return value is the layer's index; check it with <code>IsValidLayer()</code>.
: Directly adds a new layer and makes it play the given sequence. Return value is the layer's index, or -1 on failure.
 
; <code>SetLayerAutokill([[int]] layer, [[bool]] autokill)</code>
; <code>SetLayerAutokill([[int]] layer, [[bool]] autokill)</code>
: A layer, by default, persists after its sequence is over. Setting autokill causes it to be removed automatically (even if it loops) once it's through.
: A layer, by default, persists after its sequence is over. Setting autokill causes it to be removed automatically (even if it loops) once it's through.
; <code>[[int]] AddGesture([[Activity]] activity, [[bool]] autokill = true)</code>
: Helper which creates a layer with the given activity. Return value is the layer's index.
; <code>[[int]] FindGestureLayer([[Activity]] activity)</code>
: Finds a active layer playing the given activity. Returns -1 on failure.
; <code>SetLayerDuration([[int]] layer, [[float]] duration)</code>
; <code>SetLayerDuration([[int]] layer, [[float]] duration)</code>
: Adjusts the framerate of the given layer so that it lasts for the given number of seconds.
: Adjusts the framerate of the given layer so that it lasts for the given number of seconds.
; <code>CAnimationLayer* GetAnimOverlay([[int]])</code>
; <code>CAnimationLayer* GetAnimOverlay([[int]])</code>
: Directly access an animation layer. You will need to do this in order to kill one manually.
: Directly access an animation layer. You will need to do this in order to kill one manually.


[[Category:CBaseAnimating]]
[[Category:CBaseAnimating]]

Revision as of 05:30, 16 September 2011

CBaseAnimating::SetSequence() changes an entity's current skeletal animation sequence. If the sequence is already playing, and is not marked as a loop, it will restart.

Related functions

SetSequenceByName(char*)
Searches for a sequence by name. Avoid doing this if you can.
int SelectWeightedSequence(Activity)
Selects an appropriate sequence for the given activity. Pass the return value to SetSequence().
int LookupActivity(char*)
int LookupSequence(char*)
Gets an activity or sequence by name.
SetCycle(float)
Changes the frame of the current sequence.
SetPlaybackRate(float)
Changes the sequence's speed. The argument is a normalised percentage.
GetSequenceLinearMotion(int sequence, Vector* output)
Gets a Vector which describes the sequence's extracted motion over its entire duration.

Blending

If your entity inherits from CBaseAnimatingOverlay you can blend up to 15 sequences on top of the standard one.

Tip.pngTip:Layers are played in order of priority.
int AddGesture(Activity activity, bool autokill=true)
Helper which creates a layer with the given activity. Return value is the layer's index, or -1 on failure.
void RestartGesture(Activity activity, bool addifmissing=true, bool autokill=true)
Resets the first layer playing the given activity to its first frame. Optionally creates a new layer with the gesture if nothing is found.
int FindGestureLayer(Activity activity)
Searches for a active layer playing the given activity. Returns -1 on failure.
int AddGestureSequence(int sequence, bool autokill=true)
As AddGesture(), but doesn't require an activity.
int AddLayeredSequence(int sequence, int priority)
Directly adds a new layer and makes it play the given sequence. Return value is the layer's index, or -1 on failure.
SetLayerAutokill(int layer, bool autokill)
A layer, by default, persists after its sequence is over. Setting autokill causes it to be removed automatically (even if it loops) once it's through.
SetLayerDuration(int layer, float duration)
Adjusts the framerate of the given layer so that it lasts for the given number of seconds.
CAnimationLayer* GetAnimOverlay(int)
Directly access an animation layer. You will need to do this in order to kill one manually.