My Project
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ParaEngine::Animated< T, D, Conv > Class Template Reference
Inheritance diagram for ParaEngine::Animated< T, D, Conv >:
ParaEngine::IAnimated

Public Member Functions

bool CheckIsAnimated ()
 check if all key are equal
 
void SetConstantKey (T key)
 if all animated values equals to the key, this animation will be set unused
 
void SetConstantKey (T key, float fEpsilon)
 if all animated values are very close to a given key, this animation will be set unused
 
getValue (int anim, int time)
 this function will return the interpolated animation vector at the specified anim id and frame number More...
 
getDefaultValue ()
 
getValue (int nCurrentAnim, int currentFrame, int nBlendingAnim, int blendingFrame, float blendingFactor)
 get value with motion blending with a specified blending frame. More...
 
getValue (const AnimIndex &Index)
 it accept anim index of both local and external animation
 
getValue (const AnimIndex &CurrentAnim, const AnimIndex &BlendingAnim, float blendingFactor)
 it accept anim index of both local and external animation
 
void SetRangeByAnimIndex (int nAnimIndex, const AnimRange &range)
 
void AppendKey (int time_, const T &data_)
 
void UpdateLastKey (int time_, const T &data_)
 
int GetKeyNum ()
 
void CompressKeyLinear (float fEpsilon)
 if multiple adjacent keys can be linearly interpolated and get an error smaller than fEpsilon, those keys will be collapsed to save space Note: this function only works when there is only one animation range. More...
 
virtual int GetNumKeys ()
 get total number of animated keys. More...
 
virtual void SetNumKeys (int nKeyCount)
 get set the total number of animated keys. More...
 
virtual void SetTime (int nIndex, int nTime)
 only applied to Animated attribute More...
 
virtual int GetTime (int nIndex)
 
- Public Member Functions inherited from ParaEngine::IAnimated
virtual int GetNextKeyIndex (int nTime)
 return the index of the first key whose time is larger than or equal to time. More...
 
virtual int AddKey (int time, bool *isKeyExist=NULL)
 add a given key with default value at specified time if there is already a key at the index, we will return the old index. More...
 
virtual void SetValue (int nIndex, const Quaternion &val)
 
virtual bool GetValue (int nIndex, Quaternion &val)
 
virtual bool GetValueByTime (int nTime, Quaternion &val)
 
virtual void SetValue (int nIndex, const Vector2 &val)
 
virtual bool GetValue (int nIndex, Vector2 &val)
 
virtual bool GetValueByTime (int nTime, Vector2 &val)
 
virtual void SetValue (int nIndex, const Vector3 &val)
 
virtual bool GetValue (int nIndex, Vector3 &val)
 
virtual bool GetValueByTime (int nTime, Vector3 &val)
 
virtual void SetValue (int nIndex, const double &val)
 
virtual bool GetValue (int nIndex, double &val)
 
virtual bool GetValueByTime (int nTime, double &val)
 
virtual void SetValue (int nIndex, const float &val)
 
virtual bool GetValue (int nIndex, float &val)
 
virtual bool GetValueByTime (int nTime, float &val)
 
virtual void SetValue (int nIndex, const int &val)
 
virtual bool GetValue (int nIndex, int &val)
 
virtual bool GetValueByTime (int nTime, int &val)
 
virtual void SetValue (int nIndex, const std::string &val)
 
virtual bool GetValue (int nIndex, std::string &val)
 
virtual bool GetValueByTime (int nTime, std::string &val)
 

Static Public Member Functions

static float Absolute1 (float v)
 
static float Absolute1 (double v)
 
static float Absolute1 (const Vector3 &v)
 
static float Absolute1 (const Quaternion &v)
 
static float Absolute1 (const Vector2 &v)
 
static T BlendValues (const T &currentValue, const T &blendingValue, float blendingFactor)
 

Public Attributes

bool used
 whether it is a constant value(not animated). More...
 
int type
 interpolation of type Interpolations
 
int seq
 
int * globals
 a reference to the global sequence object which is an array of time ranges for global sequences. More...
 
std::vector< AnimRange > ranges
 
std::vector< int > times
 
std::vector< T > data
 
std::vector< T > in
 
std::vector< T > out
 

Member Function Documentation

§ CompressKeyLinear()

template<class T, class D = T, class Conv = Identity<T>>
void ParaEngine::Animated< T, D, Conv >::CompressKeyLinear ( float  fEpsilon)
inline

if multiple adjacent keys can be linearly interpolated and get an error smaller than fEpsilon, those keys will be collapsed to save space Note: this function only works when there is only one animation range.

otherwise ranges member may be invalid after compression.

§ GetNumKeys()

template<class T, class D = T, class Conv = Identity<T>>
virtual int ParaEngine::Animated< T, D, Conv >::GetNumKeys ( )
inlinevirtual

get total number of animated keys.

For non-animated attribute, this will return 1.

Reimplemented from ParaEngine::IAnimated.

§ getValue() [1/2]

template<class T, class D = T, class Conv = Identity<T>>
T ParaEngine::Animated< T, D, Conv >::getValue ( int  anim,
int  time 
)
inline

this function will return the interpolated animation vector at the specified anim id and frame number

global animation has nothing to do the current animation. Such animation may be the blinking of eyes and some effects which always loops regardless of the current animation.

it is also a global animation, however, range[0] is used instead of globals

get the range according to the current animation.

by LiXizhi: use binary search for the time frame: 2005/09:

modify the brutal force search by binary search and use interpolation.

  1. location = -1;
  2. while ((more than one item in list)) 2A. look at the middle item 2B. if (middle item is target) have found target return location as the result else 2C. if (target < middle item) list = first half of list 2D. else (target > middle item) list = last half of list end while

§ getValue() [2/2]

template<class T, class D = T, class Conv = Identity<T>>
T ParaEngine::Animated< T, D, Conv >::getValue ( int  nCurrentAnim,
int  currentFrame,
int  nBlendingAnim,
int  blendingFrame,
float  blendingFactor 
)
inline

get value with motion blending with a specified blending frame.

Parameters
nCurrentAnimcurrent animation sequence ID
currentFramean absolute ParaX frame number denoting the current animation frame. It is always within the range of the current animation sequence's start and end frame number.
nBlendingAnimthe animation sequence with which the current animation should be blended.
blendingFramean absolute ParaX frame number denoting the blending animation frame. It is always within the range of the blending animation sequence's start and end frame number.
blendingFactorby how much the blending frame should be blended with the current frame. 1.0 will use solely the blending frame, whereas 0.0 will use only the current frame. [0,1), blendingFrame*(blendingFactor)+(1-blendingFactor)*currentFrame

§ SetNumKeys()

template<class T, class D = T, class Conv = Identity<T>>
virtual void ParaEngine::Animated< T, D, Conv >::SetNumKeys ( int  nKeyCount)
inlinevirtual

get set the total number of animated keys.

Reimplemented from ParaEngine::IAnimated.

§ SetTime()

template<class T, class D = T, class Conv = Identity<T>>
virtual void ParaEngine::Animated< T, D, Conv >::SetTime ( int  nIndex,
int  nTime 
)
inlinevirtual

only applied to Animated attribute

Parameters
nIndexkey index.
nTimein milliseconds

Reimplemented from ParaEngine::IAnimated.

Member Data Documentation

§ globals

template<class T, class D = T, class Conv = Identity<T>>
int* ParaEngine::Animated< T, D, Conv >::globals

a reference to the global sequence object which is an array of time ranges for global sequences.

§ seq

template<class T, class D = T, class Conv = Identity<T>>
int ParaEngine::Animated< T, D, Conv >::seq
  • if this is 0 or above, it is the index into the global sequence.
  • if this is -1, it is not a global animation, animID is used instead;
  • if this is -2, it is a local global animation, where range[0] is used and a global timer is used to loop on this range;

§ used

template<class T, class D = T, class Conv = Identity<T>>
bool ParaEngine::Animated< T, D, Conv >::used

whether it is a constant value(not animated).


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