www.pudn.com > DirectX source.zip > CAnimationNode.h


/*! 
	@file : CAnimationNode.h 
	Contains the header of class CAnimationNode 
 
	@author Sarmad Kh. Abdulla 
*/ 
//------------------------------------------------------------------------------ 
 
 
//! This class holds a frame animation 
/*! Animation keys are stored here with the code required to perform the animation */ 
class CAnimationNode : public CObject 
{ 
// construction / destruction 
public: 
	CAnimationNode() 
	{ 
		aPositionKey = NULL; 
		aRotationKey = NULL; 
		aScaleKey = NULL; 
		aMatrixKey = NULL; 
		pTargetFrame = NULL; 
	} 
	virtual ~CAnimationNode() 
	{ 
		Destroy(); 
	} 
 
// member functions 
public: 
	//! Load data from the x file 
	void Load( LPDIRECTXFILEOBJECT pxofobj ); 
	//! Destroy this object and its childs 
	virtual void Destroy( void ); 
	//! Animate the target bone according to the given time 
	void SetTime( DWORD dwtime ); 
	//! Find the target bone for this animation 
	void FindBone( CFrameNode * prootframe ); 
	//! Return the name of this animation object. 
	string & GetName( void ) 
	{ 
		return Name; 
	} 
	//! Set the name of this animation object. 
	void SetName( const char * name ) 
	{ 
		Name = name; 
	} 
 
// data types 
protected: 
	struct BONEPOSITIONKEY 
	{ 
		DWORD dwTime; 
		D3DXVECTOR3 Pos; 
	}; 
	struct BONESCALEKEY 
	{ 
		DWORD dwTime; 
		D3DXVECTOR3 Scale; 
	}; 
	struct BONEROTATIONKEY 
	{ 
		DWORD dwTime; 
		D3DXQUATERNION Rotation; 
	}; 
	struct BONEMATRIXKEY 
	{ 
		DWORD dwTime; 
		D3DXMATRIX Mat; 
	}; 
 
// member variables 
protected: 
	string Name; 
	BONEPOSITIONKEY * aPositionKey;		//!< The array of position keys 
	DWORD dwPositionKeyCount;			//!< The size of the position keys array 
	BONESCALEKEY * aScaleKey;			//!< The array of scale keys 
	DWORD dwScaleKeyCount;				//!< The size of the scale keys array 
	BONEROTATIONKEY * aRotationKey;		//!< The array of rotation keys 
	DWORD dwRotationKeyCount;			//!< The size of the rotation keys array 
	BONEMATRIXKEY * aMatrixKey;			//!< The array of matrix keys 
	DWORD dwMatrixKeyCount;				//!< The size of the matrix keys array 
 
	string TargetName;					//!< The name of the target frame 
	CFrameNode * pTargetFrame;			//!< A pointer to the target frame 
};