The HBhvAnimation class defines an animation. More...

#include <HBhvAnimation.h>

Public Member Functions

void AddChildAnimation (HBhvAnimation *childanimation)
 
void AddInterpolator (HBhvInterpolator *interpolator)
 
void AdjustKeyframe (int keyframe, int delta, bool doall=true, bool relative=false)
 
void AdjustToTick (int totalticks)
 
virtual bool Animate (float currenttime)
 
virtual bool Animate (float currenttime, float starttime)
 
void CleanWithoutDelete ()
 
HBhvAnimationCreateInstance ()
 
void DeleteKeyframe (int keyframe)
 
void Duplicate (int newkeyframe, int oldkeyframe)
 
void DuplicateNextOrPrevious (int keyframe, bool next)
 
void Evaluate (float currenttick, bool &hasPos, HPoint &pos, bool &hasQuat, HQuat &quat, bool &hasScale, HPoint &scale)
 
bool ExecuteOnce ()
 
HBhvBehaviorManagerGetBehaviorManager ()
 
struct vlist_s * GetChildAnimationList ()
 
bool GetCurrentlyRunning ()
 
float GetCurrentTick ()
 
bool GetDefaultActive ()
 
int GetDelay ()
 
int GetFirstTick ()
 
HBhvAnimationGetInstancedAnimation ()
 
HBhvInterpolatorGetInterpolator ()
 
bool GetInterpolator (int time, int &interval, HKeyframe **keyframe)
 
struct vlist_s * GetInterpolatorList ()
 
int GetLastTick ()
 
int GetLoop ()
 
const char * GetName ()
 
HBhvAnimationGetParentAnimation ()
 
HBhvTargetObjectGetTarget ()
 
float * GetTargetScaleMatrix ()
 
HBhvTimelineGetTimeline ()
 
virtual const char * GetType ()
 
 HBhvAnimation (const char *name, HBhvBehaviorManager *BehaviorManager, HBhvAnimation *parentanimation=0)
 
void PlotCurve (bool rotations)
 
void Reset ()
 
virtual void Serialize (HUtilityXMLGenerator *xmlgen, HUtilityXMLTag *xmlt)
 
virtual void Serialize (HUtilityXMLGenerator *xmlgen)
 
void SetBehaviorManager (HBhvBehaviorManager *behaviourmanager)
 
void SetCurrentlyRunning (bool running)
 
void SetDefaultActive (bool active)
 
void SetDelay (int delay)
 
void SetExecuteOnce (bool once)
 
void SetInstancedAnimation (HBhvAnimation *animation)
 
void SetLoop (int loop)
 
void SetName (const char *name)
 
void SetTarget (HBhvTargetObject *target)
 
void SetTargetByPath (const char *targetpath)
 
void SetTargetByPath (const char *name, const char *targetpath)
 
void SetTargetScaleMatrix (float const *target_matrix)
 
void SetTimeline (HBhvTimeline *timeline)
 
virtual ~HBhvAnimation ()
 

Static Public Member Functions

static void * XMLCallback (HUtilityXMLTag *xt, bool open, void *m_pExtraData)
 

Protected Member Functions

virtual bool AnimateInternal (float currenttick)
 
void CloneAnimation ()
 
virtual void SerializeTarget (HUtilityXMLTag *xmlt)
 
void SetInstanceOf (const char *name)
 

Protected Attributes

bool m_bCurrentlyRunning
 
bool m_bDefaultActive
 
bool m_bExecuteOnce
 
struct vlist_s * m_ChildAnimationList
 
int m_Delay
 
char m_InstanceOf [BHV_MAX_NAME_LENGTH]
 
struct vlist_s * m_InterpolatorList
 
int m_Loop
 
char m_Name [BHV_MAX_NAME_LENGTH]
 
HBhvBehaviorManagerm_pBehaviorManager
 
HBhvAnimationm_pInstancedAnimation
 
HBhvAnimationm_pParentAnimation
 
HBhvTimelinem_pTimeline
 
HBhvTimelineInstance * m_pTimelineInstance
 
HBhvTargetObjectm_Target
 
float m_TargetScaleMatrix [16]
 

Detailed Description

The HBhvAnimation class defines an animation.

By combining a timeline with one or more interpolators and a target object, the animation class defines a single animation. Animations must be added to the behaviour manager for execution. They can either be active by default or be activated by a sensor action. The animation class also defines various helper functions to manage interpolator keyframes and to set and retrieve various properties of the animation.

Constructor & Destructor Documentation

◆ HBhvAnimation()

HBhvAnimation::HBhvAnimation ( const char *  name,
HBhvBehaviorManager BehaviorManager,
HBhvAnimation parentanimation = 0 
)

Constructs an HBhvAnimation object.

Parameters
nameName of the animation. This name should be unique.
BehaviorManagerA pointer to HBhvBehaviorManager object that this animation belongs to.
parentanimationA pointer to parent animation if it exists.
This value can be null if there is not parent animation.

◆ ~HBhvAnimation()

virtual HBhvAnimation::~HBhvAnimation ( )
virtual

Destructor of the HBhvAnimation object.

Member Function Documentation

◆ AddChildAnimation()

void HBhvAnimation::AddChildAnimation ( HBhvAnimation childanimation)

Adds an animation to the child animation list.

Parameters
childanimationThe child animation to be added.

◆ AddInterpolator()

void HBhvAnimation::AddInterpolator ( HBhvInterpolator interpolator)

Adds an interpolator to the interpolator list.

Parameters
interpolatorThe interpolator to be added.

◆ AdjustKeyframe()

void HBhvAnimation::AdjustKeyframe ( int  keyframe,
int  delta,
bool  doall = true,
bool  relative = false 
)

Adjusts keyframe intervals by the given number of ticks.

Parameters
keyframeStart keyframe to adjust.
deltaAmount of ticks to offset the keyframe time.
doallPass true to adjust all keyframes after the start keyframe.
relativeAdjust keyframes all keyframes after the given keyframe so that they will also have an additional delta offset between the next keyframe.

◆ AdjustToTick()

void HBhvAnimation::AdjustToTick ( int  totalticks)

This method has been deprecated.

◆ Animate() [1/2]

virtual bool HBhvAnimation::Animate ( float  currenttime)
virtual

Performs animation based on the given time.

Parameters
currenttimeTime (in ticks) relative to start time of overall animation.

◆ Animate() [2/2]

virtual bool HBhvAnimation::Animate ( float  currenttime,
float  starttime 
)
virtual

Performs animation based on the given time in relation to given start time.

Parameters
currenttimeTime (in ticks) relative to given start time (second parameter)
starttimeStart time (in ticks) to evaluate animation from

◆ AnimateInternal()

virtual bool HBhvAnimation::AnimateInternal ( float  currenttick)
protectedvirtual

This is a helper function for Animate(). It checks that the current tick is valid for the associated timeline and then animates the interpolators.

Parameters
currenttickCurrent Time in ticks of animation

◆ CleanWithoutDelete()

void HBhvAnimation::CleanWithoutDelete ( )

This method set disassociates the current timeline from this animation and clears the interpolator list without deleting any of the previous associated timeline or interpolator objects.

◆ CloneAnimation()

void HBhvAnimation::CloneAnimation ( )
protected

Creates an animation instance.

◆ CreateInstance()

HBhvAnimation* HBhvAnimation::CreateInstance ( )

In special cases, you may want an animation that references this animation without changing it. Use this method to create such an animation.

Returns
A pointer to newly created animation that refers to this animation.

◆ DeleteKeyframe()

void HBhvAnimation::DeleteKeyframe ( int  keyframe)

This method deletes a given keyframe in the timeline and interpolators for this animation.

Parameters
keyframeNumber of keyframe

◆ Duplicate()

void HBhvAnimation::Duplicate ( int  newkeyframe,
int  oldkeyframe 
)

This method makes a copy of newkeyframe and then replaces oldkeyframe with the copy.

Parameters
newkeyframeKeyframe to copy to
oldkeyframeKeyframe to copy from

◆ DuplicateNextOrPrevious()

void HBhvAnimation::DuplicateNextOrPrevious ( int  keyframe,
bool  next 
)

Copies the next or previous keyframe to the given target keyframe.

Parameters
keyframeThe keyframe to copy to.
nextPass false for the previous keyframe and true for the next keyframe.

◆ ExecuteOnce()

bool HBhvAnimation::ExecuteOnce ( )
inline
Returns
True if the animation is flagged to only run for one update.

◆ GetBehaviorManager()

HBhvBehaviorManager* HBhvAnimation::GetBehaviorManager ( )
inline
Returns
A pointer to the HBhvBehaviorManager object associated with this animation.

◆ GetChildAnimationList()

struct vlist_s* HBhvAnimation::GetChildAnimationList ( )
inline
Returns
A pointer to the list of child animations associated to this animation.

◆ GetCurrentlyRunning()

bool HBhvAnimation::GetCurrentlyRunning ( )
inline
Returns
True if the animation is running and false if it is not running

◆ GetCurrentTick()

float HBhvAnimation::GetCurrentTick ( )
Returns
The current "tick" (i.e. frame) as reported by the behavior manager.

◆ GetDefaultActive()

bool HBhvAnimation::GetDefaultActive ( )
inline
Returns
True if the animation is active by default and false if otherwise. If the animation is not active by default then it can only become activated by a sensor or by calling SetDefaultActive and passing true.

◆ GetDelay()

int HBhvAnimation::GetDelay ( )
inline
Returns
The initial delay time for this animation.

◆ GetFirstTick()

int HBhvAnimation::GetFirstTick ( )
Returns
The value of first entry in the timeline.

◆ GetInstancedAnimation()

HBhvAnimation* HBhvAnimation::GetInstancedAnimation ( )
inline
Returns
A pointer to the animation that this animation references.

◆ GetInterpolator() [1/2]

HBhvInterpolator* HBhvAnimation::GetInterpolator ( )
Returns
The first interpolator in the interpolator list.

◆ GetInterpolator() [2/2]

bool HBhvAnimation::GetInterpolator ( int  time,
int &  interval,
HKeyframe **  keyframe 
)

For a given time, this method finds the closest keyframe and interval in the interpolator.

Parameters
timeTime in which you are looking for the closest keyframe.
intervalReturns the interval in timeline which the given time falls between.
keyframeReturns an Hkeyframe object for given time.
Returns
True if a keyframe and interval were found and false if none was found.

◆ GetInterpolatorList()

struct vlist_s* HBhvAnimation::GetInterpolatorList ( )
inline
Returns
A pointer to the list of interpolators for this animation.

◆ GetLastTick()

int HBhvAnimation::GetLastTick ( )
Returns
The value of last entry in the timeline.

◆ GetLoop()

int HBhvAnimation::GetLoop ( )
inline
Returns
A value of 1 if the animation will be looped or 0 if the animation stops when it reaches the end of the timeline.

◆ GetName()

const char* HBhvAnimation::GetName ( )
inline
Returns
Name of the animation.

◆ GetParentAnimation()

HBhvAnimation* HBhvAnimation::GetParentAnimation ( )
inline
Returns
Parent animation for this animation.

◆ GetTarget()

HBhvTargetObject* HBhvAnimation::GetTarget ( )
inline
Returns
A pointer to target object of this animation.

◆ GetTimeline()

HBhvTimeline* HBhvAnimation::GetTimeline ( )
inline
Returns
A pointer to the timeline associated to this animation.

◆ GetType()

virtual const char* HBhvAnimation::GetType ( )
inlinevirtual
Returns
The type of animation which is 'HBhvAnimation'.

◆ PlotCurve()

void HBhvAnimation::PlotCurve ( bool  rotations)

This method plots a curve on the scene representing the path of this animation.

Parameters
rotationsPass true to include rotation in the curve or false to not include it.

◆ Reset()

void HBhvAnimation::Reset ( )

Stop the animation if it is currently running and resets all the interpolators associated with this animation.

◆ Serialize() [1/2]

virtual void HBhvAnimation::Serialize ( HUtilityXMLGenerator *  xmlgen,
HUtilityXMLTag *  xmlt 
)
virtual

This method writes XML data to a buffer.

◆ Serialize() [2/2]

virtual void HBhvAnimation::Serialize ( HUtilityXMLGenerator *  xmlgen)
virtual

This method writes XML data to a buffer.

◆ SerializeTarget()

virtual void HBhvAnimation::SerializeTarget ( HUtilityXMLTag *  xmlt)
protectedvirtual

This method writes XML Data for this animation's target to a buffer.

◆ SetBehaviorManager()

void HBhvAnimation::SetBehaviorManager ( HBhvBehaviorManager behaviourmanager)
inline

Sets the HBhvBehaviorManager Object associated to this animation.

◆ SetCurrentlyRunning()

void HBhvAnimation::SetCurrentlyRunning ( bool  running)
inline

Sets the currently running flag which indicates whether an animation is currently executing.

Parameters
runningPass true to indicate that this animation is currently running and false if it is not running.

◆ SetDefaultActive()

void HBhvAnimation::SetDefaultActive ( bool  active)
inline

Sets default active parameter for this animation. If you pass false, then the animation is inactive by default which means that it can only be triggered by a sensor action.

Parameters
activePass true if you want this animation to be active by default or false if otherwise.

◆ SetDelay()

void HBhvAnimation::SetDelay ( int  delay)
inline

Sets initial delay time for this animation. A delay can be used to prevent this animation from occuring at exactly the same time as other items in the HBhvBehaviorManager's animation list.

◆ SetExecuteOnce()

void HBhvAnimation::SetExecuteOnce ( bool  once)
inline

Use this method to indicate if this animation should only run for one update.

Parameters
oncePass true if you want the animation to be disabled after the next update or false if you want to the animation to run normally.

◆ SetInstancedAnimation()

void HBhvAnimation::SetInstancedAnimation ( HBhvAnimation animation)
inline

Sets pointer to animation that you want this animation to reference.

Parameters
animationA pointer to the animation to reference.

◆ SetInstanceOf()

void HBhvAnimation::SetInstanceOf ( const char *  name)
protected

Sets name of the animation that this animation references.

Parameters
nameThe name of the referenced animation.

◆ SetLoop()

void HBhvAnimation::SetLoop ( int  loop)
inline

Use this method to indicate if animation is looped or plays once.

Parameters
loopPass 1 if the animation should loop or 0 if the animation should stop when it reaches the end of the timeline.

◆ SetName()

void HBhvAnimation::SetName ( const char *  name)

Sets the name of the animation.

◆ SetTarget()

void HBhvAnimation::SetTarget ( HBhvTargetObject target)

Associates a given target object with this animation.

◆ SetTargetByPath() [1/2]

void HBhvAnimation::SetTargetByPath ( const char *  targetpath)

This method creates a target object using the given target path and then attaches it to this animation.

Parameters
targetpathSegment path to target

◆ SetTargetByPath() [2/2]

void HBhvAnimation::SetTargetByPath ( const char *  name,
const char *  targetpath 
)

This method creates a target object using the given target path and name. Then it attaches the newly created target to this animation.

Parameters
nameName of newly created target object
targetpathSegment path to target

◆ SetTargetScaleMatrix()

void HBhvAnimation::SetTargetScaleMatrix ( float const *  target_matrix)

Given the target modelling matrix, it extracts its scaling elements.

◆ SetTimeline()

void HBhvAnimation::SetTimeline ( HBhvTimeline timeline)

This method associates the passed timeline with this animation.

Parameters
timelineThe timeline to be associated with this animation.

◆ XMLCallback()

static void* HBhvAnimation::XMLCallback ( HUtilityXMLTag *  xt,
bool  open,
void *  m_pExtraData 
)
static

This is XML read callback which parses XML data and then populates the member variables with the associated values.

Member Data Documentation

◆ m_bCurrentlyRunning

bool HBhvAnimation::m_bCurrentlyRunning
protected

The value is true if the animation is currently running and false if otherwise.

◆ m_bDefaultActive

bool HBhvAnimation::m_bDefaultActive
protected

The value is true if the animation is active by default and false if otherwise.

◆ m_bExecuteOnce

bool HBhvAnimation::m_bExecuteOnce
protected

A flag that determines if animation should only run for one update.

◆ m_ChildAnimationList

struct vlist_s* HBhvAnimation::m_ChildAnimationList
protected

A pointer to the list of child animations.

◆ m_Delay

int HBhvAnimation::m_Delay
protected

Initial delay for this animation

◆ m_InstanceOf

char HBhvAnimation::m_InstanceOf[BHV_MAX_NAME_LENGTH]
protected

The name of the referenced animation.

◆ m_InterpolatorList

struct vlist_s* HBhvAnimation::m_InterpolatorList
protected

A pointer to the interpolator list.

◆ m_Loop

int HBhvAnimation::m_Loop
protected

A value of 1 means that this animation should be looped while a value of 0 means the animation should stop when it reaches the end of the timeline.

◆ m_Name

char HBhvAnimation::m_Name[BHV_MAX_NAME_LENGTH]
protected

Name of this animation.

Referenced by HBhvInterpolator::GetName().

◆ m_pBehaviorManager

HBhvBehaviorManager* HBhvAnimation::m_pBehaviorManager
protected

A pointer to the BehaviorManager object that this animation belongs to.

◆ m_pInstancedAnimation

HBhvAnimation* HBhvAnimation::m_pInstancedAnimation
protected

A pointer to the referenced animation (if any).

◆ m_pParentAnimation

HBhvAnimation* HBhvAnimation::m_pParentAnimation
protected

A pointer to the parent animation.

◆ m_pTimeline

HBhvTimeline* HBhvAnimation::m_pTimeline
protected

A pointer to the timeline object.

◆ m_pTimelineInstance

HBhvTimelineInstance* HBhvAnimation::m_pTimelineInstance
protected

A pointer to the referenced timeline (if any).

◆ m_Target

HBhvTargetObject* HBhvAnimation::m_Target
protected

A pointer to the target object of this animation.

◆ m_TargetScaleMatrix

float HBhvAnimation::m_TargetScaleMatrix[16]
protected

The target scale matrix.


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