The Nebula Device 3: Animation::AnimJob Class Reference

The Nebula Device 3

Animation::AnimJob Class Reference

#include <animjob.h>

Inheritance diagram for Animation::AnimJob:

Core::RefCounted Animation::PlayClipJob

Detailed Description

Descibes a single animation sampling job in the AnimController. AnimJob objects have a start time and a duration and are arranged in parallel tracks. The sampling results of parallel AnimJobs at a given point in time are mixed into a single resulting animation by the AnimController. Subclasses of AnimJob are used to implement specific tasks like a lookat-controller, IK, and so forth...

FIXME: the current implementation of setting an absolute evaluation time doesn't allow to manipulate the playback speed (for this, advancing the time by a relative amount would be better).

(C) 2008 Radon Labs GmbH

Public Member Functions

 AnimJob ()
 constructor
virtual ~AnimJob ()
 destructor
void SetName (const Util::StringAtom &id)
 set human readable name (only used for debugging)
const Util::StringAtomGetName () const
 get human readable name (only used for debugging)
bool IsAttachedToSequencer () const
 return true if the job is currently attached to a sequencer
bool IsActive (Timing::Tick time) const
 return true if the job has currently playing (EvalTime within start/end time)
bool IsPending (Timing::Tick time) const
 return true if the job has been queued for playback but has not started yet
bool IsStoppingOrExpired (Timing::Tick time) const
 return true if anim job is stopping or expired
bool IsExpired (Timing::Tick time) const
 return true when the job has expired
void SetTrackIndex (IndexT trackIndex)
 set track index, defines blend priority and relationship to other jobs on same track
IndexT GetTrackIndex () const
 get track index
void SetEnqueueMode (AnimJobEnqueueMode::Code enqueueMode)
 set the enqueue behaviour of the new job (default is intercept)
AnimJobEnqueueMode::Code GetEnqueueMode () const
 get the enqueue behaviour of the new job
void SetExclusiveTag (IndexT id)
 exclusive tag (for AnimJobEnqueueMode::IgnoreIfSameExclTagActive)
IndexT GetExclusiveTag () const
 exclusive flag set?
void SetStartTime (Timing::Tick time)
 set the start time of the anim job (relativ to base time)
Timing::Tick GetStartTime () const
 get the start time of the anim job (relative to base time)
void SetDuration (Timing::Tick time)
 set the duration of the anim job (0 == infinite)
Timing::Tick GetDuration () const
 get the duration of the anim job
bool IsInfinite () const
 return true if the anim job is infinite
void SetFadeInTime (Timing::Tick fadeInTime)
 set the fade-in time of the anim job
Timing::Tick GetFadeInTime () const
 get the fade-in time of the anim job
void SetFadeOutTime (Timing::Tick fadeOutTime)
 set the fade-out time of the anim job
Timing::Tick GetFadeOutTime () const
 get the fade-out time of the anim job
void SetTimeFactor (float timeFactor)
 set time factor
float GetTimeFactor () const
 get time factor
void SetTimeOffset (Timing::Tick timeOffset)
 set sample time offset (if sampling should not start at the beginning)
Timing::Tick GetTimeOffset () const
 get sample time offset
void SetBlendWeight (float w)
 set blend weight of the anim job (default is 1.0)
float GetBlendWeight () const
 get blend weight of the anim job
Timing::Tick GetAbsoluteStartTime () const
 get the absolute start time (BaseTime + StartTime)
Timing::Tick GetAbsoluteEndTime () const
 get the absolute end time (BaseTime + StartTime + Duration)
Timing::Tick GetAbsoluteStopTime () const
 get the absolute, computed end time ((BaseTime + StartTime + Duration) - FadeOutTime)
int GetRefCount () const
 get the current refcount
void AddRef ()
 increment refcount by one
void Release ()
 decrement refcount and destroy object if refcount is zero
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
const Util::StringGetClassName () const
 get the class name
Util::FourCC GetClassFourCC () const
 get the class FourCC code

Static Public Member Functions

static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

Protected Member Functions

void SetBaseTime (Timing::Tick time)
 set the base time of the anim job (set by sequencer when job is attached)
Timing::Tick GetBaseTime () const
 get the base time of the anim job
virtual void OnAttachedToSequencer (const AnimSequencer &animSequencer)
 called when attached to anim sequencer
virtual void OnRemoveFromSequencer ()
 called when removed from sequencer
float ComputeBlendWeight (Timing::Tick relEvalTime) const
 compute current blend weight, this should take fade-in into account
void FixFadeTimes ()
 fix fade-in/fade-out times if the sum is bigger then the play duration
virtual Ptr< Jobs::JobCreateEvaluationJob (Timing::Tick time, const Ptr< CoreAnimation::AnimSampleBuffer > &mixIn, const Ptr< CoreAnimation::AnimSampleBuffer > &result)
 create evaluation job for asynchronous evaluation
virtual Util::Array< AnimEventInfoEmitAnimEvents (Timing::Tick startTime, Timing::Tick endTime, const Util::String &optionalCatgeory)
 emit anim events inside given time range
virtual void UpdateTimes (Timing::Tick time)
 compute sample time for next evaluation, always done, also if character isn't visible and no evaluation takes place
virtual void Stop (Timing::Tick time)
 stop the anim job at the given time

Member Function Documentation

bool Animation::AnimJob::IsActive ( Timing::Tick  time  )  const

return true if the job has currently playing (EvalTime within start/end time)

This method will return true if the current eval time is between the start time and end time of the anim job.

bool Animation::AnimJob::IsPending ( Timing::Tick  time  )  const

return true if the job has been queued for playback but has not started yet

This method will return true as long as the current eval time is before the start time (the job hasn't started yet).

bool Animation::AnimJob::IsStoppingOrExpired ( Timing::Tick  time  )  const

return true if anim job is stopping or expired

Return true if the anim job is currently in or after the fade-out phase.

bool Animation::AnimJob::IsExpired ( Timing::Tick  time  )  const

return true when the job has expired

This method will return true if the current eval time is greater then the end time of the job.

Timing::Tick Animation::AnimJob::GetAbsoluteStartTime (  )  const

get the absolute start time (BaseTime + StartTime)

Returns the absolute start time (BaseTime + StartTime).

Timing::Tick Animation::AnimJob::GetAbsoluteEndTime (  )  const

get the absolute end time (BaseTime + StartTime + Duration)

Return the absolute end time (BaseTime + StartTime + Duration). Method fails hard if AnimJob is infinite.

Timing::Tick Animation::AnimJob::GetAbsoluteStopTime (  )  const

get the absolute, computed end time ((BaseTime + StartTime + Duration) - FadeOutTime)

Returns the absolute end time before the fadeout-phase starts ((BaseTime + StartTime + Duration) - FadeOut)

float Animation::AnimJob::ComputeBlendWeight ( Timing::Tick  relEvalTime  )  const [protected]

compute current blend weight, this should take fade-in into account

This is a helper method for subclasses and returns the current blend weight for the current relative evaluation time, taking the fade-in and fade-out phases into account.

void Animation::AnimJob::FixFadeTimes (  )  [protected]

fix fade-in/fade-out times if the sum is bigger then the play duration

This method checks if the fade-in plus the fade-out times would be bigger then the play-duration, if yes it will fix the fade times in order to prevent "blend-popping".

Ptr< Job > Animation::AnimJob::CreateEvaluationJob ( Timing::Tick  time,
const Ptr< CoreAnimation::AnimSampleBuffer > &  mixIn,
const Ptr< CoreAnimation::AnimSampleBuffer > &  result 
) [protected, virtual]

create evaluation job for asynchronous evaluation

This method is called by the AnimSequencer when this job is active (the current eval time is between the start and end time of the job). The AnimJob object is expected to fill the provided AnimSampleBuffer with a result (sampled keys and sample counts, the sample counts indicate whether a given sample contributes to the final blended result. If the mixIn pointer is valid, the method must perform animation mixing as well.

This method is usually implemented by subclasses.

void Animation::AnimJob::UpdateTimes ( Timing::Tick  time  )  [protected, virtual]

compute sample time for next evaluation, always done, also if character isn't visible and no evaluation takes place

Updates evaluation times. Must be done every frame, even if character is not visible and so animjob is not evaluated. FIXME: INVISIBLE OBJECTS SHOULD NEVER UPDATE THEIR ANIMATION OR ANIM EVENTS!

void Animation::AnimJob::Stop ( Timing::Tick  time  )  [protected, virtual]

stop the anim job at the given time

Stop the anim job at the given time. This will just update the duration member.

int Core::RefCounted::GetRefCount (  )  const [inline, inherited]

get the current refcount

Return the current refcount of the object.

void Core::RefCounted::AddRef (  )  [inline, inherited]

increment refcount by one

Increment the refcount of the object.

void Core::RefCounted::Release (  )  [inline, inherited]

decrement refcount and destroy object if refcount is zero

Decrement the refcount and destroy object if refcount is zero.

const Util::String & Core::RefCounted::GetClassName (  )  const [inline, inherited]

get the class name

Get the class name of the object.

Util::FourCC Core::RefCounted::GetClassFourCC (  )  const [inline, inherited]

get the class FourCC code

Get the class FourCC of the object.

void Core::RefCounted::DumpRefCountingLeaks (  )  [static, inherited]

dump refcounting leaks, call at end of application (NEBULA3_DEBUG builds only!)

This method should be called as the very last before an application exits.