Page principale | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe

C:/Projects/ngn/include/models.h

00001 /***************************************************************************
00002  *            models.h
00003  *
00004  *  Wed Mar 31 10:47:38 2004
00005  *  Copyright  2004  tite
00006  *  thierry.schartz@bluebottle.com
00007  ****************************************************************************/
00008 /*
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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                  // animation type
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];           // indicies for the verts that make up this triangle
00076                         int coordIndex[3];          // indicies for the tex coords to texture this face
00077                 };
00078 
00079                 struct SMaterialInfo
00080                 {
00081                         char  strName[255];         // The texture name
00082                         char  strFile[255];         // The texture file name (If this is set it's a texture map)
00083                         byte  colour[3];             // The color of the object (R, G, B)
00084                         int   textureID;             // the texture ID
00085                         float uTile;                // u tiling of texture  (Currently not used)
00086                         float vTile;                // v tiling of texture  (Currently not used)
00087                         float uOffset;              // u offset of texture  (Currently not used)
00088                         float vOffset;              // v offset of texture  (Currently not used)
00089                 } ;
00090 
00091                 struct SAnimationInfo
00092                 {
00093                         char strName[255];          // This stores the name of the animation (Jump, Pain, etc..)
00094                         int startFrame;             // This stores the first frame number for this animation
00095                         int endFrame;               // This stores the last frame number for this animation
00096                 };
00097 
00098                 struct SObject 
00099                 {
00100                         int  numVertices;                       // The number of verts in the model
00101                         int  numFaces;                  // The number of faces in the model
00102                         int  numTexCoords;                      // The number of texture coordinates
00103                         int  materialID;                        // The texture ID to use, which is the index into our texture array
00104                         bool hasTexture;                        // This is TRUE if there is a texture map for this object
00105                         char strName[255];                      // The name of the object
00106                         core::Vector3df  *pVerts;                       // The object's vertices
00107                         core::Vector3df  *pNormals;             // The object's normals
00108                         core::Vector2df  *pTexCoords;           // The texture's UV coordinates
00109                         SFace *pFaces;                          // The faces information of the object
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;  // default = 5.0f
00196 
00197                         core::Vector3df m_position;
00198                                                 
00199                         int m_ID;
00200                         std::string m_name;
00201                                 
00202                 };
00203 
00204 
00205 
00206 }//ngn
00207 #endif /* MODELS_H */
00208 

Généré le Fri Nov 19 14:20:29 2004 pour NGN par  doxygen 1.3.9.1