HBhvAnimation
-
class
HBhvAnimation The
HBhvAnimationclass 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.
Index
Methods
AddChildAnimation()AddInterpolator()AdjustKeyframe()AdjustToTick()Animate()Animate()AnimateInternal()CleanWithoutDelete()CloneAnimation()CreateInstance()DeleteKeyframe()Duplicate()DuplicateNextOrPrevious()Evaluate()ExecuteOnce()GetBehaviorManager()GetChildAnimationList()GetCurrentlyRunning()GetCurrentTick()GetDefaultActive()GetDelay()GetFirstTick()GetInstancedAnimation()GetInterpolator()GetInterpolator()GetInterpolatorList()GetLastTick()GetLoop()GetName()GetParentAnimation()GetTarget()GetTargetScaleMatrix()GetTimeline()GetType()HBhvAnimation()PlotCurve()Reset()Serialize()Serialize()SerializeTarget()SetBehaviorManager()SetCurrentlyRunning()SetDefaultActive()SetDelay()SetExecuteOnce()SetInstancedAnimation()SetInstanceOf()SetLoop()SetName()SetTarget()SetTargetByPath()SetTargetByPath()SetTargetScaleMatrix()SetTimeline()XMLCallback()~HBhvAnimation()
Variables
Methods
-
HBhvAnimation::HBhvAnimation(char const *name, HBhvBehaviorManager *BehaviorManager, HBhvAnimation *parentanimation = 0) Constructs an
HBhvAnimationobject.Parameters
name: Name of the animation. This name should be unique.
BehaviorManager: A pointer to
HBhvBehaviorManagerobject that this animation belongs to.parentanimation: A pointer to parent animation if it exists. This value can be null if there is not parent animation.
-
virtual
HBhvAnimation::~HBhvAnimation() virtual
Destructor of the
HBhvAnimationobject.
-
virtual char const *
HBhvAnimation::GetType() virtual
Returns
The type of animation which is ‘HBhvAnimation‘.
-
char const *
HBhvAnimation::GetName() Returns
Name of the animation.
-
void
HBhvAnimation::SetName(char const *name) Sets the name of the animation.
-
virtual bool
HBhvAnimation::Animate(float currenttime) virtual
Performs animation based on the given time.
Parameters
currenttime: Time (in ticks) relative to start time of overall animation.
-
virtual bool
HBhvAnimation::Animate(float currenttime, float starttime) virtual
Performs animation based on the given time in relation to given start time.
Parameters
currenttime: Time (in ticks) relative to given start time (second parameter)
starttime: Start time (in ticks) to evaluate animation from
-
void
HBhvAnimation::DeleteKeyframe(int keyframe) This method deletes a given keyframe in the timeline and interpolators for this animation.
Parameters
keyframe: Number of keyframe
-
void
HBhvAnimation::DuplicateNextOrPrevious(int keyframe, bool next) Copies the next or previous keyframe to the given target keyframe.
Parameters
keyframe: The keyframe to copy to.
next: Pass false for the previous keyframe and true for the next keyframe.
-
void
HBhvAnimation::Duplicate(int newkeyframe, int oldkeyframe) This method makes a copy of newkeyframe and then replaces oldkeyframe with the copy.
Parameters
newkeyframe: Keyframe to copy to
oldkeyframe: Keyframe to copy from
-
void
HBhvAnimation::PlotCurve(bool rotations) This method plots a curve on the scene representing the path of this animation.
Parameters
rotations: Pass true to include rotation in the curve or false to not include it.
-
void
HBhvAnimation::AdjustToTick(int totalticks) This method has been deprecated.
-
virtual void
HBhvAnimation::Serialize(HUtilityXMLGenerator *xmlgen, HUtilityXMLTag *xmlt) virtual
This method writes XML data to a buffer.
-
virtual void
HBhvAnimation::Serialize(HUtilityXMLGenerator *xmlgen) virtual
This method writes XML data to a buffer.
-
HBhvBehaviorManager *
HBhvAnimation::GetBehaviorManager() Returns
A pointer to theHBhvBehaviorManagerobject associated with this animation.
-
void
HBhvAnimation::SetBehaviorManager(HBhvBehaviorManager *behaviourmanager) Sets the
HBhvBehaviorManagerObject associated to this animation.
-
int
HBhvAnimation::GetFirstTick() Returns
The value of first entry in the timeline.
-
int
HBhvAnimation::GetLastTick() Returns
The value of last entry in the timeline.
-
int
HBhvAnimation::GetLoop() 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.
-
void
HBhvAnimation::SetLoop(int loop) Use this method to indicate if animation is looped or plays once.
Parameters
loop: Pass 1 if the animation should loop or 0 if the animation should stop when it reaches the end of the timeline.
-
HBhvTimeline *
HBhvAnimation::GetTimeline() Returns
A pointer to the timeline associated to this animation.
-
void
HBhvAnimation::SetTimeline(HBhvTimeline *timeline) This method associates the passed timeline with this animation.
Parameters
timeline: The timeline to be associated with this animation.
-
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.
-
struct vlist_s *
HBhvAnimation::GetInterpolatorList() Returns
A pointer to the list of interpolators for this animation.
-
struct vlist_s *
HBhvAnimation::GetChildAnimationList() Returns
A pointer to the list of child animations associated to this animation.
-
HBhvInterpolator *
HBhvAnimation::GetInterpolator() Returns
The first interpolator in the interpolator list.
-
void
HBhvAnimation::AddInterpolator(HBhvInterpolator *interpolator) Adds an interpolator to the interpolator list.
Parameters
interpolator: The interpolator to be added.
-
void
HBhvAnimation::AddChildAnimation(HBhvAnimation *childanimation) Adds an animation to the child animation list.
Parameters
childanimation: The child animation to be added.
-
HBhvAnimation *
HBhvAnimation::GetParentAnimation() Returns
Parent animation for this animation.
-
void
HBhvAnimation::SetDelay(int delay) 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.
-
int
HBhvAnimation::GetDelay() Returns
The initial delay time for this animation.
-
HBhvTargetObject *
HBhvAnimation::GetTarget() Returns
A pointer to target object of this animation.
-
HBhvAnimation *
HBhvAnimation::GetInstancedAnimation() Returns
A pointer to the animation that this animation references.
-
void
HBhvAnimation::SetInstancedAnimation(HBhvAnimation *animation) Sets pointer to animation that you want this animation to reference.
Parameters
animation: A pointer to the animation to reference.
-
void
HBhvAnimation::Reset() Stop the animation if it is currently running and resets all the interpolators associated with this animation.
-
void
HBhvAnimation::SetTargetByPath(char const *targetpath) This method creates a target object using the given target path and then attaches it to this animation.
Parameters
targetpath: Segment path to target
-
void
HBhvAnimation::SetTargetByPath(char const *name, char const *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
name: Name of newly created target object
targetpath: Segment path to target
-
void
HBhvAnimation::SetTarget(HBhvTargetObject *target) Associates a given target object with this animation.
-
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
time: Time in which you are looking for the closest keyframe.
interval: Returns the interval in timeline which the given time falls between.
keyframe: Returns an Hkeyframe object for given time.
Returns
True if a keyframe and interval were found and false if none was found.
-
void
HBhvAnimation::SetDefaultActive(bool active) 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
active: Pass true if you want this animation to be active by default or false if otherwise.
-
bool
HBhvAnimation::GetDefaultActive() 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.
-
void
HBhvAnimation::SetCurrentlyRunning(bool running) Sets the currently running flag which indicates whether an animation is currently executing.
Parameters
running: Pass true to indicate that this animation is currently running and false if it is not running.
-
bool
HBhvAnimation::GetCurrentlyRunning() Returns
True if the animation is running and false if it is not running
-
float
HBhvAnimation::GetCurrentTick() Returns
The current “tick” (i.e. frame) as reported by the behavior manager.
-
void
HBhvAnimation::AdjustKeyframe(int keyframe, int delta, bool doall = true, bool relative = false) Adjusts keyframe intervals by the given number of ticks.
Parameters
keyframe: Start keyframe to adjust.
delta: Amount of ticks to offset the keyframe time.
doall: Pass true to adjust all keyframes after the start keyframe.
relative: Adjust keyframes all keyframes after the given keyframe so that they will also have an additional delta offset between the next keyframe.
-
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.
-
bool
HBhvAnimation::ExecuteOnce() Returns
True if the animation is flagged to only run for one update.
-
void
HBhvAnimation::SetExecuteOnce(bool once) Use this method to indicate if this animation should only run for one update.
Parameters
once: Pass true if you want the animation to be disabled after the next update or false if you want to the animation to run normally.
-
void
HBhvAnimation::Evaluate(float currenttick, bool &hasPos, HPoint &pos, bool &hasQuat, HQuat &quat, bool &hasScale, HPoint &scale)
-
void
HBhvAnimation::SetTargetScaleMatrix(float const *target_matrix) Given the target modelling matrix, it extracts its scaling elements.
-
float *
HBhvAnimation::GetTargetScaleMatrix()
-
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.
-
void
HBhvAnimation::SetInstanceOf(char const *name) protected
Sets name of the animation that this animation references.
Parameters
name: The name of the referenced animation.
-
virtual bool
HBhvAnimation::AnimateInternal(float currenttick) protected virtual
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
currenttick: Current Time in ticks of animation
-
void
HBhvAnimation::CloneAnimation() protected
Creates an animation instance.
-
virtual void
HBhvAnimation::SerializeTarget(HUtilityXMLTag *xmlt) protected virtual
This method writes XML Data for this animation’s target to a buffer.
Variables
-
HBhvAnimation *
HBhvAnimation::m_pInstancedAnimation protected
A pointer to the referenced animation (if any).
-
HBhvTimelineInstance *
HBhvAnimation::m_pTimelineInstance protected
HBhvTimelineInstanceA pointer to the referenced timeline (if any).
-
char
HBhvAnimation::m_InstanceOf[BHV_MAX_NAME_LENGTH] protected
charThe name of the referenced animation.
-
HBhvTargetObject *
HBhvAnimation::m_Target protected
A pointer to the target object of this animation.
-
bool
HBhvAnimation::m_bCurrentlyRunning protected
boolThe value is true if the animation is currently running and false if otherwise.
-
bool
HBhvAnimation::m_bDefaultActive protected
boolThe value is true if the animation is active by default and false if otherwise.
-
HBhvBehaviorManager *
HBhvAnimation::m_pBehaviorManager protected
A pointer to the BehaviorManager object that this animation belongs to.
-
HBhvAnimation *
HBhvAnimation::m_pParentAnimation protected
A pointer to the parent animation.
-
HBhvTimeline *
HBhvAnimation::m_pTimeline protected
A pointer to the timeline object.
-
struct vlist_s *
HBhvAnimation::m_InterpolatorList protected
struct vlist_sA pointer to the interpolator list.
-
struct vlist_s *
HBhvAnimation::m_ChildAnimationList protected
struct vlist_sA pointer to the list of child animations.
-
char
HBhvAnimation::m_Name[BHV_MAX_NAME_LENGTH] protected
charName of this animation.
-
int
HBhvAnimation::m_Loop protected
intA 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.
-
int
HBhvAnimation::m_Delay protected
intInitial delay for this animation
-
bool
HBhvAnimation::m_bExecuteOnce protected
boolA flag that determines if animation should only run for one update.
-
float
HBhvAnimation::m_TargetScaleMatrix[16] protected
floatThe target scale matrix.