My Project
BipedStateManager.h
1 #pragma once
2 #include <stack>
3 
4 namespace ParaEngine
5 {
6  class CBipedObject;
7  struct ActionKey;
8 
9  using namespace std;
12  {
13  public:
14  CBipedStateManager(void);
16  ~CBipedStateManager(void);
17 
18  enum BipedState{
19  STATE_MOVING = 0,
20  STATE_WALK_FORWORD,
21  STATE_RUN_FORWORD,
22  STATE_WALK_LEFT,
23  STATE_WALK_RIGHT,
24  STATE_WALK_BACKWORD,
25  STATE_WALK_POINT,
26  STATE_SWIM_FORWORD,
27  STATE_SWIM_LEFT,
28  STATE_SWIM_RIGHT,
29  STATE_SWIM_BACKWORD,
30  STATE_FLY_DOWNWARD,
31  STATE_STANDING = 100, // without speed
32  STATE_IN_WATER, // under or in water
33  STATE_SWIM,
34  STATE_JUMP_IN_AIR, // in air
35  STATE_JUMP_START,
36  STATE_JUMP_END,
37  STATE_STAND,
38  STATE_TURNING,
39  STATE_ATTACK,
40  STATE_ATTACK1,
41  STATE_ATTACK2,
42  STATE_MOUNT, // mount on target
43  STATE_DANCE,
44  };
46  //struct BipedStateObj{
47  // BipedState m_state;
48  // void * m_data;
49  //public:
50  // BipedStateObj(BipedState s, void* data):m_state(s), m_data(data){};
51  //};
53  S_STANDING = 0,
59  S_WALK_FORWORD,
60  S_RUN_FORWORD,
61  S_WALK_LEFT,
62  S_WALK_RIGHT,
63  S_WALK_POINT, // walking to a point
64  S_TURNING,
65  S_WALK_BACKWORD,
66  S_SWIM_FORWORD,
67  S_SWIM_LEFT,
68  S_SWIM_RIGHT,
69  S_SWIM_BACKWORD,
70  S_JUMP_START,
71  S_JUMP_IN_AIR, // not used.
72  S_JUMP_END,
73  S_MOUNT,
74  S_FALLDOWN,
75  S_ATTACK,
76  S_ATTACK1,
77  S_ATTACK2,
78  S_DANCE,
79  S_ACTIONKEY, // perform the action in the action key, immediately.
80  S_FLY_DOWNWARD,
81  S_NONE
82  };
83  private:
85  list <BipedState> m_memory;
87  CBipedObject* m_pBiped;
90  float m_fTimer;
93  BipedState m_nLastAnimState;
96  bool m_bWalkOrRun:1;
98  bool m_bRecording:1;
100  bool m_bIsMounted:1;
101 
102  /* User data */
103  DVector3 m_vPos; // for position user data
104  float m_fAngleDelta; // for angle user data
105  float m_fJumpupSpeed;
106  protected:
108  void RemoveState(BipedState s);
110  void CheckMemory();
111 
113  void ReplaceState(BipedState s);
115  void PushState(BipedState s);
117  void PushUniqueState(BipedState s);
119  void PrependState(BipedState s);
121  void PrependUniqueState(BipedState s);
123  void SetUniqueState(BipedState s);
124  public:
126  bool IsMounted();
128  void SetMounted(bool bIsMounted);
130  bool IsRecording();
132  void SetRecording(bool bIsRecording = true);
134  bool WalkingOrRunning();
137  void SetWalkOrRun(bool bWalk);
138 
139 
146  bool GetStateAnimName(BipedState s, char* sName, int nNameSize=8);
147 
150  BipedState GetLastAnimState();
155  int FindStateInMemory(BipedState s);
156 
158  BipedState GetLastState();
160  BipedState GetFirstState();
161 
162  static bool IsStandingState(BipedState s);
163  static bool IsMovingState(BipedState s);
165  bool HasMovingState();
167  bool IsSwimming();
169  bool IsFlying();
170 
171  CBipedObject* GetBiped();
172  void SetBiped(CBipedObject* pBiped);
173 
184  BipedState AddAction(ActionSymbols nAct, const void* pData=NULL);
185 
187  void SetAngleDelta(float fAngleDelta);
189  float GetAngleDelta();
190 
192  void SetJumpupSpeed(float fSpeed);
194  float GetJumpupSpeed();
195 
197  void SetPos(const DVector3& v);
199  const DVector3& GetPos();
200 
206  void Update(float fTimeDelta);
207  friend class CAutoCamera;
208  };
209 }
3-dimensional vector with double precision.
Definition: ParaDVector3.h:17
make sure that the biped is in water
Definition: BipedStateManager.h:55
make sure that the biped is not in water (on land or in air)
Definition: BipedStateManager.h:56
different physics engine has different winding order.
Definition: EventBinding.h:32
Auto Camera is designed to handle smooth transitions between supported camera type, such as first person camera, third person camera, and rotation camera.
Definition: AutoCamera.h:14
ensure the biped has no speed
Definition: BipedStateManager.h:54
make sure that the biped is on water surface (not in water or in air)
Definition: BipedStateManager.h:57
ActionSymbols
state object that saves in memory
Definition: BipedStateManager.h:52
managing biped state
Definition: BipedStateManager.h:11
pop the current action
Definition: BipedStateManager.h:58
It can be used to represent biped object(like human, re spawning monsters) in the scene without inher...
Definition: BipedObject.h:60