My Project
XFileAnimInstance.h
1 #pragma once
2 #include "AnimInstanceBase.h"
3 #include "XFileMultiAnim.h"
4 
5 namespace ParaEngine
6 {
7 class CAudioEngine;
8 #define IDLE_TRANSITION_TIME 0.125f
9 #define MOVE_TRANSITION_TIME 0.25f
10 
11 #define ANIMINDEX_FAIL 0xffffffff
12 
13 
14 //-----------------------------------------------------------------------------
15 // Name: class CBHandlerTiny
16 // Desc: Derived from ID3DXAnimationCallbackHandler. Callback handler for
17 // CBiped -- plays the footstep sounds
18 //-----------------------------------------------------------------------------
19 class CBipedCallbackHandler : public ID3DXAnimationCallbackHandler
20 {
21  HRESULT CALLBACK HandleCallback( THIS_ UINT Track, LPVOID pCallbackData )
22  {
23  return S_OK;
24  }
25 };
26 
27 #define ACTION_NO_MAX 11
28 
29 /* biped animation callback: all instances use a single callback handler */
30 extern CBipedCallbackHandler g_BipedCallbackHandler; // callback interface to handle callback keys
31 
32 struct SceneState;
77 {
78 protected:
79  // -- data structuring
80  CMultiAnim * m_pMA; // pointer to mesh-type-specific object
81  DWORD m_dwMultiAnimIdx; // index identifying which CAnimInstance this object uses
82  CAnimInstance * m_pAI; // pointer to CAnimInstance specific to this object
83 
85  DWORD m_dwAnimIdxLoiter, // Indexes of various animation sets
86  m_dwAnimIdxWalk,m_dwAnimIdxJog,m_dwAnimIdxSwim,
87  m_dwAnimIdxSpeak,
88  m_dwAnimIdxAction[ACTION_NO_MAX];
89  Matrix4 m_mxOrientation; // transform that gets the mesh into a common world space
90 
91 
92 
94 
95  // operational status
96  double m_dTimePrev; // global time value before last update
97  double m_dTimeCurrent; // current global time value
98  bool m_bPlaySounds; // true == this instance is playing sounds
99  DWORD m_dwCurrentTrack; // current animation track for primary animation
100  Matrix4 m_mxWorld; // world transform of the animation.
101 
102  // animation callback
105 
106  char m_szASName[22]; // Current track's animation set name (for preserving across device reset)
107  char m_szASNameTarget[22];// Target track's animation set name (for preserving across device reset)
108 
109 protected:
110  // --The following are not callable by the app -- internal stuff
111  void PlayAnimation( bool bContinue);
112  void SmoothLoiter();
113 
114  HRESULT GetAnimationIndex();
115  DWORD GetAnimIndex( char sString[] );
116  HRESULT AddCallbackKeysAndCompress( LPD3DXANIMATIONCONTROLLER pAC, LPD3DXKEYFRAMEDANIMATIONSET pAS, DWORD dwNumCallbackKeys, D3DXKEY_CALLBACK aKeys[], DWORD dwCompressionFlags, FLOAT fCompression );
117  HRESULT SetupCallbacksAndCompression();
118  void SetSounds( bool bSounds );
119 
120  virtual HRESULT ResetTime();
121 
122 public:
123  HRESULT InitObject( CMultiAnim *pMA, double dTimeCurrent);
124  HRESULT InitDeviceObjects();
125  HRESULT InvalidateDeviceObjects();
126  HRESULT RestoreDeviceObjects();
127  void Cleanup();
128 
129  //-- rendering
130  void LoadBipedState(const char* sTargetAnim, const Matrix4* mxWorld);
131  virtual void Animate( double dTimeDelta );
132  virtual void AdvanceTime( double dTimeDelta);
133  HRESULT Draw( SceneState * sceneState);
134  virtual CAnimInstance *GetAnimInstance();
135 
136  //-- querying
137  //CBipedObject* GetAssociatedBipedObject(){return m_pBipedObject;};
138  //void SetAssociatedBipedObject(CBipedObject* pObj){m_pBipedObject = pObj;};
139 
140 public:
142  ~CXFileAnimInstance(void);
143 };
144 }
Biped Animation controller.
Definition: XFileAnimInstance.h:76
It's used as parameter to Draw method of each scene object.
Definition: SceneState.h:284
abstract class for all animation instance implementation.
Definition: AnimInstanceBase.h:66
Encapsulates an animation instance, with its own animation controller.
Definition: XFileMultiAnim.h:137
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: XFileAnimInstance.h:19
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
This class encapsulates a mesh hierarchy (typically loaded from an .X file).
Definition: XFileMultiAnim.h:79
DWORD m_dwAnimIdxLoiter
CSoundManager * m_pSM; // pointer to sound management interface.
Definition: XFileAnimInstance.h:85
double m_dTimePrev
CallbackDataTiny m_CallbackData[ 2 ]; // Data to pass to callback handler.
Definition: XFileAnimInstance.h:96