00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef MODELS_H
00024 #define MODELS_H
00025
00026 #ifdef WIN32
00027 #include <windows.h>
00028 #endif
00029
00030
00031 #include <string>
00032 #include <vector>
00033 #include "vector2d.h"
00034 #include "vector3d.h"
00035
00036 namespace ngn {
00037
00038
00039 namespace core {
00040 class AABB;
00041 }
00042 class Camera;
00043 typedef unsigned char byte;
00044
00045
00046 enum NGNAnimType
00047 {
00048 NGN_ANIM_STAND = 0,
00049 NGN_ANIM_RUN,
00050 NGN_ANIM_ATTACK,
00051 NGN_ANIM_PAIN_A,
00052 NGN_ANIM_PAIN_B,
00053 NGN_ANIM_PAIN_C,
00054 NGN_ANIM_JUMP,
00055 NGN_ANIM_FLIP,
00056 NGN_ANIM_SALUTE,
00057 NGN_ANIM_FALLBACK,
00058 NGN_ANIM_WAVE,
00059 NGN_ANIM_POINT,
00060 NGN_ANIM_CROUCH_STAND,
00061 NGN_ANIM_CROUCH_WALK,
00062 NGN_ANIM_CROUCH_ATTACK,
00063 NGN_ANIM_CROUCH_PAIN,
00064 NGN_ANIM_CROUCH_DEATH,
00065 NGN_ANIM_DEATH_FALLBACK,
00066 NGN_ANIM_DEATH_FALLFORWARD,
00067 NGN_ANIM_DEATH_FALLBACKSLOW,
00068 NGN_ANIM_BOOM,
00069 NGN_ANIM_MAX_ANIMATIONS = 21
00070
00071 };
00072
00073 struct SFace
00074 {
00075 int vertIndex[3];
00076 int coordIndex[3];
00077 };
00078
00079 struct SMaterialInfo
00080 {
00081 char strName[255];
00082 char strFile[255];
00083 byte colour[3];
00084 int textureID;
00085 float uTile;
00086 float vTile;
00087 float uOffset;
00088 float vOffset;
00089 } ;
00090
00091 struct SAnimationInfo
00092 {
00093 char strName[255];
00094 int startFrame;
00095 int endFrame;
00096 };
00097
00098 struct SObject
00099 {
00100 int numVertices;
00101 int numFaces;
00102 int numTexCoords;
00103 int materialID;
00104 bool hasTexture;
00105 char strName[255];
00106 core::Vector3df *pVerts;
00107 core::Vector3df *pNormals;
00108 core::Vector2df *pTexCoords;
00109 SFace *pFaces;
00110 };
00111
00112
00117 class NGN_API Model
00118 {
00119 public:
00120 Model();
00121 virtual ~Model();
00122
00124 void setCurrentAnimation( unsigned int anim );
00126 unsigned int getCurrentAnimation();
00128 core::AABB* getBBox();
00130 void setScaleFactor( float scale );
00132 float getScaleFactor();
00134 static void setAnimationSpeed( float speed );
00136 float getAnimationSpeed();
00138 void setPosition( const core::Vector3df& pos );
00140 core::Vector3df& getPosition();
00142 void setID( int id );
00144 int getID() const;
00146 void setName( const std::string& name );
00148 const std::string& getName() const;
00150 int getNumAnimations();
00151
00153 virtual bool loadModel( std::string model_file, std::string texture_file ) = 0;
00155 virtual void renderModel( const Camera& cam ) = 0;
00156
00158 void rotateY( float rotation );
00159
00160 protected:
00162 virtual void calculateBBox() = 0;
00164 void setNumObjects( int num_object );
00166 int getNumObjects();
00168 void setNumMaterials( int num_materials );
00170 int getNumMaterials();
00172 void setNumAnimations( int num_animations );
00174 void setCurrentFrame( int current_frame );
00176 int getCurrentFrame();
00178 void addAnimation( SAnimationInfo anim );
00180 void addMaterial( SMaterialInfo material );
00182 void addObject( SObject object );
00183
00184 int m_numObjects;
00185 int m_numMaterials;
00186 int m_numAnimations;
00187 unsigned int m_currentAnim;
00188 int m_currentFrame;
00189 std::vector<SAnimationInfo> m_animations;
00190 std::vector<SMaterialInfo> m_materials;
00191 std::vector<SObject> m_frames;
00192 core::AABB* m_bbox;
00193 float m_scale;
00194 float m_rotation;
00195 static float m_animationSpeed;
00196
00197 core::Vector3df m_position;
00198
00199 int m_ID;
00200 std::string m_name;
00201
00202 };
00203
00204
00205
00206 }
00207 #endif
00208