Go to the documentation of this file.00001 #pragma once
00002 #define NOMINMAX
00003 #include <windows.h>
00004 #include "math.h"
00005 #include <vector>
00006 #include <NxPhysics.h>
00007 #include <NxController.h>
00008 #include "constants.h"
00009 #include "types.h"
00010 #include "GGraphicsObject.h"
00011 #include "GSkeleton.h"
00012 #include "GBoundingSphere.h"
00013 #include "GAnimationManager.h"
00014 #include "GMatrix16.h"
00015 #include "HitCallBack.h"
00016 #include "NxCCDSkeleton.h"
00017
00018 using namespace std;
00019
00021 enum Command
00022 {
00023 NoCommand,
00024 Run,
00025 Strafe,
00026 Jump
00027 };
00028
00030 enum ActionState
00031 {
00032 Idle,
00033 Idle_Run,
00034 Run_Idle,
00035 Idle_Strafe,
00036 Strafe_Idle,
00037 Running,
00038 Strafing,
00039 Falling,
00040 Jumping
00041 };
00042
00044 enum BoundingType
00045 {
00046 None,
00047 Box,
00048 Sphere,
00049 Cooked
00050 };
00051
00052
00053 class GSkeleton;
00054 class GAnimatedMesh;
00055 class GAnimationManager;
00056 class GCamera;
00057
00058
00060 class GModel : public GGraphicsObject
00061 {
00062 protected:
00064 GSkeleton *Skeleton;
00066 vector<GAnimatedMesh*> Meshes;
00068 GBoundingSphere *BoundingSphere;
00070 GBoundingBox *BoundingBox;
00072 GAnimationManager *AnimationManager;
00073
00075 GVec4f Position;
00077 GVec4f Offset;
00079 GVec4f Rotation;
00081 GVec4f JumpDir;
00083 GVec4f RunDir;
00085 float Speed;
00087 float JumpPower;
00089 vector<GGraphicsObject *> Children;
00091 GGraphicsObject *Parent;
00093 GCamera* Camera;
00095 float m_Mass;
00097 GVec4f mVelocityMemory;
00098
00100 ActionState State;
00102 keyframe_t *IntermediateKeframe;
00104 bool lock;
00106 double FallingStart;
00108 GMatrix16 WorldSpaceMatrix;
00110 BoundingType m_BoundingType;
00112 NxActor *m_Actor;
00114 NxController *m_Controller;
00116 NxCCDSkeleton *m_CCDSkeleton;
00118 GVec4f Velocity;
00120 Command currentCommand;
00122 Command nextCommand;
00124 float mfUpwardsForce;
00125
00126 public:
00128 HitCallBack myHitCallBack;
00130 GModel();
00132 GModel( GSkeleton *_Skeleton,
00133 GAnimatedMesh *_Mesh,
00134 GAnimationManager *AnimationManager);
00136 ~GModel();
00138 virtual int Draw(double time, double dtime, GMatrix16 *viewmatrix, GMatrix16 *worldmatrix, int FLAGS);
00140 virtual int DrawSprites(double time, double dtime, GMatrix16 *viewmatrix, GMatrix16 *worldmatrix, int FLAGS);
00142 int RecalculateBoneData(void);
00144 unsigned int GetMeshCount(void);
00146 GVec4f GetOffset(void);
00148 void SetOffset(GVec4f _offset);
00150 NxCCDSkeleton *GetCCDSkeleton(void);
00152 void SetCCDSkeleton(NxCCDSkeleton *s);
00154 Command GetCurrentCommand(void);
00156 void SetCurrentCommand(Command c);
00157 Command GetNextCommand(void);
00158 void SetNextCommand(Command c);
00159 NxActor *SetActor(NxActor *a);
00160 NxActor *GetActor(void);
00161 void SetVelocity(GVec4f _v);
00162 GVec4f GetVelocity(void);
00163 ActionState GetState(void);
00165 int OutLineMappedVertices(int FLAGS);
00167 int Skin(int FLAGS);
00169 int Rotate(GVec4f _Rotations);
00171 GSkeleton *GetSkeleton(void);
00173 float GetMass(void);
00175 void SetMass(float _m);
00177 int SetSkeleton(GSkeleton *s);
00179 void setCamera(GCamera *cam);
00181 GAnimatedMesh *GetMesh(int pos = 0);
00183 GAnimationManager *GetAnimationManager(void);
00185 virtual GBoundingBox *GetBoundingBox(void);
00187 virtual GBoundingSphere *GetBoundingSphere(void);
00189 int UpdateAnimation(float now, int FLAGS);
00191 int ResetAnimation(void);
00193 int ComposeModel( std::string Path,
00194 std::string Modelname,
00195 std::string Skeletonname,
00196 animationlibrary_t *AnimationLibrary,
00197 keyframelibrary_t *KeyframeLibrary);
00199 int Move(GVec4f v);
00201 int Move(float x, float y, float z);
00203 void queryPosition(GVec4f *v);
00205 virtual int setPosition(GVec4f v);
00207 void queryRotation(GVec4f *v);
00209 GVec4f getLookDir();
00211 virtual int setRotation(GVec4f v);
00213 int AddMesh(GAnimatedMesh *_Mesh);
00215 int SetMesh(GAnimatedMesh *_Mesh, int pos = -1);
00217 int RecalculateBoundingBox(int FLAGS);
00219 int RecalculateBoundingSphere(int FLAGS);
00221 GGraphicsObject *GetParent(void);
00223 int SetParent(GGraphicsObject *_Parent);
00225 void SetVelocityMemory(GVec4f m);
00227 GVec4f GetVelocityMemory(void);
00229 int CreateDefaultSkeleton(int FLAGS);
00231 int CreateDefaultVertexMapper(int FLAGS);
00233 int MoveTo(GVec4f v);
00235 int AddAnimationManager(GAnimationManager *AM = NULL);
00237 int SetAnimationManager(GAnimationManager *am);
00239 virtual int RebuildMatrix(void);
00241 GVec4f GetLinearVelocity(void);
00243 int SetBoundingType(BoundingType b);
00245 BoundingType GetBoundingType(void);
00247 NxController *GetController(void);
00249 void SetController(NxController * _c);
00251 bool IsFalling(void);
00253 bool IsJumping(void);
00255 bool IsRunning(void);
00257 bool IsIdle(void);
00259 void SetRunningDirection(GVec4f d);
00261 void SetJumpingDirection(GVec4f d);
00263 int SetState(ActionState s);
00265 void Lock(void);
00267 void Unlock(void);
00269 void SetFallingStart(double d);
00271 double GetFallingStart(void);
00273 bool IsLocked(void);
00275 GMatrix16 GetRotationMatrix(void);
00277 GVec4f GetWorldSpaceCenter(void);
00279 GMatrix16 GetWorldSpaceMatrix(void);
00281 virtual int Update(double time, double dtime);
00283 float GetSpeed(void);
00285 void SetSpeed(float);
00287 vector<GAnimatedMesh*> GetMeshes(void);
00289 int SetMeshes(vector<GAnimatedMesh*>);
00290 };