Wasabi
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WAnimation Class Referenceabstract

#include <WAnimation.hpp>

Inheritance diagram for WAnimation:
WFileAsset WBase WSkeleton

Public Member Functions

virtual std::string GetTypeName () const override
 
virtual void SetID (uint32_t newID) override
 
virtual void SetName (std::string newName) override
 
 WAnimation (class Wasabi *const app, uint32_t ID=0)
 
virtual void Update (float fDeltaTime)
 
virtual class WImageGetTexture () const =0
 
virtual void AddSubAnimation ()
 
virtual void RemoveSubAnimation (uint32_t index)
 
WError SetKeyFrameTime (uint32_t frame, float fTime)
 
void SetPlaySpeed (float fSpeedMultiplier, uint32_t subAnimation=-1)
 
void SetCurrentFrame (uint32_t frame, uint32_t subAnimation=0)
 
void SetCurrentTime (float fTime, uint32_t subAnimation=0)
 
void SetPlayingBounds (uint32_t startFrame, uint32_t endFrame, uint32_t subAnimation=0)
 
void SetPlayingBounds_Time (float fStartTime, float fEndTime, uint32_t subAnimation=0)
 
void Play (uint32_t subAnimation=-1)
 
void Loop (uint32_t subAnimation=-1)
 
void Stop (uint32_t subAnimation=-1)
 
void Reset (uint32_t subAnimation=-1)
 
bool Playing (uint32_t subAnimation=0) const
 
bool Looping (uint32_t subAnimation=0) const
 
float GetTime (uint32_t subAnimation=0) const
 
virtual WError CopyFrom (const WAnimation *const from)=0
 
virtual WError UseAnimationFrames (const WAnimation *const anim)=0
 
- Public Member Functions inherited from WFileAsset
 WFileAsset (class Wasabi *const app, uint32_t ID=0)
 
virtual WError SaveToStream (class WFile *file, std::ostream &outputStream)=0
 
virtual WError LoadFromStream (class WFile *file, std::istream &inputStream, vector< void * > &args, std::string nameSuffix)=0
 
- Public Member Functions inherited from WBase
 WBase (class Wasabi *const app, uint32_t ID=0)
 
uint32_t GetID () const
 
std::string GetName () const
 
class WasabiGetAppPtr () const
 
void AddReference ()
 
void RemoveReference ()
 
virtual bool Valid () const =0
 

Static Public Member Functions

static std::string _GetTypeName ()
 

Protected Member Functions

void m_UpdateFirstFrame (uint32_t subAnimation=-1)
 

Protected Attributes

bool m_bFramesOwner
 
float m_totalTime
 
vector< W_FRAME * > m_frames
 
vector< W_SUB_ANIMATION * > m_subAnimations
 
- Protected Attributes inherited from WBase
class Wasabim_app
 
uint32_t m_ID
 
std::string m_name
 

Detailed Description

This is an abstract base class that represents an animation which could be attached to an object. This base class is responsible for maintaining subanimations and managing their playing and looping.

Member Function Documentation

◆ _GetTypeName()

static std::string WAnimation::_GetTypeName ( )
static

Returns "Animation" string.

Returns
Returns "Animation" string

◆ AddSubAnimation()

virtual void WAnimation::AddSubAnimation ( )
virtual

Appends a subanimation to this animation.

Reimplemented in WSkeleton.

◆ CopyFrom()

virtual WError WAnimation::CopyFrom ( const WAnimation *const  from)
pure virtual

Copies another WAnimation. This function is specific to the implementation.

Parameters
fromAnimation to copy from
Returns
Error code, see WError.h

Implemented in WSkeleton.

◆ GetTexture()

virtual class WImage* WAnimation::GetTexture ( ) const
pure virtual

Retrieves the texture that corresponds to the animation. This depends on the implementation. For example, a skeletal animation implementation may return a texture that contains bone matrices encoded in its pixels.

Returns
The animation texture

Implemented in WSkeleton.

◆ GetTime()

float WAnimation::GetTime ( uint32_t  subAnimation = 0) const

Retrieves the current time in the subanimation.

Parameters
subAnimationsubanimation to check
Returns
The current time of the subanimation

◆ GetTypeName()

virtual std::string WAnimation::GetTypeName ( ) const
overridevirtual

This function must be implemented by a child class. This is used for debugging, in which a class should return its name.

Returns
The name of the class

Implements WBase.

◆ Loop()

void WAnimation::Loop ( uint32_t  subAnimation = -1)

Starts looping the subanimation.

Parameters
subAnimationsubanimation to loop, -1 for all subanimations

◆ Looping()

bool WAnimation::Looping ( uint32_t  subAnimation = 0) const

Whether or not the subanimation is looping.

Parameters
subAnimationsubanimation to check
Returns
true if the subanimation is looping, false otherwise

◆ m_UpdateFirstFrame()

void WAnimation::m_UpdateFirstFrame ( uint32_t  subAnimation = -1)
protected

Updates W_SUB_ANIMATION::firstFrame for the given subanimation to match its' W_SUB_ANIMATION::fPlayStartTime.

Parameters
subAnimationsubanimation to update, -1 to update all subanimations

◆ Play()

void WAnimation::Play ( uint32_t  subAnimation = -1)

Starts playing the subanimation.

Parameters
subAnimationsubanimation to play, -1 for all subanimations

◆ Playing()

bool WAnimation::Playing ( uint32_t  subAnimation = 0) const

Whether or not the subanimation is playing (or looping).

Parameters
subAnimationsubanimation to check
Returns
true if the subanimation is playing (or looping), false otherwise

◆ RemoveSubAnimation()

virtual void WAnimation::RemoveSubAnimation ( uint32_t  index)
virtual

Removes a subanimation from this animation. Subanimation at index 0 cannot be removed.

Parameters
indexThe index of the subanimation to remove

◆ Reset()

void WAnimation::Reset ( uint32_t  subAnimation = -1)

Resets the subanimation by setting its current time and frame to the beginning of the boundaries set for it (Set boundaries using SetPlayingBounds and SetPlayingBounds_Time).

Parameters
subAnimationsubanimation to reset, -1 for all subanimations

◆ SetCurrentFrame()

void WAnimation::SetCurrentFrame ( uint32_t  frame,
uint32_t  subAnimation = 0 
)

Immediately sets the current frame in the subanimation.

Parameters
frameThe frame index to go to
subAnimationThe subanimation to set its frame, -1 for all subanimations

◆ SetCurrentTime()

void WAnimation::SetCurrentTime ( float  fTime,
uint32_t  subAnimation = 0 
)

Immediately sets the current time in the subanimation.

Parameters
fTimeThe time to set the subanimation to
subAnimationThe subanimation to set its time, -1 for all subanimations

◆ SetID()

virtual void WAnimation::SetID ( uint32_t  newID)
overridevirtual

Sets the ID of this object and notifies its manager.

Parameters
newIDNew ID

Implements WBase.

◆ SetKeyFrameTime()

WError WAnimation::SetKeyFrameTime ( uint32_t  frame,
float  fTime 
)

Sets the time interval for a keyframe in the animation frames.

Parameters
frameFrame index
fTimeTime to set for the frame
Returns
Error code, see WError.h

◆ SetName()

virtual void WAnimation::SetName ( std::string  newName)
overridevirtual

Sets the name of this object.

Parameters
nameNew name for the object

Implements WBase.

◆ SetPlayingBounds()

void WAnimation::SetPlayingBounds ( uint32_t  startFrame,
uint32_t  endFrame,
uint32_t  subAnimation = 0 
)

Sets the range in which the subanimation can loop.

Parameters
startFrameThe first frame to start looping
endFrameThe last frame for the loop
subAnimationThe subanimation to set its boundaries, -1 for all subanimations

◆ SetPlayingBounds_Time()

void WAnimation::SetPlayingBounds_Time ( float  fStartTime,
float  fEndTime,
uint32_t  subAnimation = 0 
)

Sets the range in which the subanimation can loop.

Parameters
fStartTimeThe time at which looping begins
fEndTimeThe time at which the loop restarts
subAnimationThe subanimation to set its boundaries, -1 for all subanimations

◆ SetPlaySpeed()

void WAnimation::SetPlaySpeed ( float  fSpeedMultiplier,
uint32_t  subAnimation = -1 
)

Sets the play speed multiplier for the selected subanimation.

Parameters
fSpeedMultiplierSpeed multiplier
subAnimationsubanimation index, -1 will set the speed for all subanimations

◆ Stop()

void WAnimation::Stop ( uint32_t  subAnimation = -1)

Stops playing (and looping) the subanimation.

Parameters
subAnimationsubanimation to stop, -1 for all subanimations

◆ Update()

virtual void WAnimation::Update ( float  fDeltaTime)
virtual

Steps the state of the playing (or looping) subanimations forward. This is usually called by the engine during normal execution each frame.

Parameters
fDeltaTimestep time in seconds

Reimplemented in WSkeleton.

◆ UseAnimationFrames()

virtual WError WAnimation::UseAnimationFrames ( const WAnimation *const  anim)
pure virtual

Use the animation frames of another animation object. This should be more efficient than copying in time and memory usage. This function depends on the implementation.

Parameters
animAnimation to use its frames
Returns
Error code, see WError.h

Implemented in WSkeleton.

Member Data Documentation

◆ m_bFramesOwner

bool WAnimation::m_bFramesOwner
protected

true if this object owns the frames in m_frames, and can thus free them. The owner of the frames is the one who allocated them.

◆ m_frames

vector<W_FRAME*> WAnimation::m_frames
protected

The frames of this animation

◆ m_subAnimations

vector<W_SUB_ANIMATION*> WAnimation::m_subAnimations
protected

The subanimations of this animation

◆ m_totalTime

float WAnimation::m_totalTime
protected

Total time of all the frames


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