Page principale   Liste des namespaces   Hiérarchie des classes   Liste par ordre alphabétique   Liste des composants   Liste des fichiers   Membres des namespaces   Composants   Déclarations  

ExCModelMD2.h

Aller à la documentation de ce fichier.
00001 /*
00002  * ExNihilo 3D Engine
00003  * 
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  *
00018  * Please read AUTHORS file !!!
00019  * 
00020 
00021  *
00022  */
00023 
00024 #ifndef __EXCMODELMD2_H__
00025 #define __EXCMODELMD2_H__
00026 //--------------------------------
00027 // File to include
00028 //--------------------------------
00029 #include "ExDefine.h"
00030 #include "ExMath.h"
00031 #include "ExCModelMD.h"
00032 #include "ExCImageLoader.h"
00033 //--------------------------------
00034 // These are the needed defines for the max values when loading .MD2 files
00035 #define MD2_MAX_TRIANGLES               4096
00036 #define MD2_MAX_VERTICES                2048
00037 #define MD2_MAX_TEXCOORDS               2048
00038 #define MD2_MAX_FRAMES                  512
00039 #define MD2_MAX_SKINS                   32
00040 #define MD2_MAX_FRAMESIZE               (MD2_MAX_VERTICES * 4 + 128)
00041 
00042 // This holds the header information that is read in at the beginning of the file
00043 typedef struct
00044 {
00045    int ident;            // identifies as MD2 file "IDP2"
00046    int version;  // mine is 8
00047    int skinwidth;    // width of texture
00048    int skinheight;   // height of texture
00049    int framesize;    // number of bytes per frame
00050    int numSkins;     // number of textures
00051    int numXYZ;       // number of points
00052    int numST;        // number of texture
00053    int numTris;      // number of triangles
00054    int numGLcmds;
00055    int numFrames;    // total number of frames
00056    int offsetSkins;  // offset to skin names (64 bytes each)
00057    int offsetST;     // offset of texture s-t values
00058    int offsetTris;   // offset of triangle mesh
00059    int offsetFrames; // offset of frame data (points)
00060    int offsetGLcmds; // type of OpenGL commands to use
00061    int offsetEnd;    // end of file
00062 } modelHeader_t;
00063 // This stores the frames vertices after they have been transformed
00064 // info for a single frame point
00065 typedef struct
00066 {
00067    short s;
00068    short t;
00069 } stIndex_t;
00070 
00071 typedef struct
00072 {
00073    unsigned char v[3];
00074    unsigned char normalIndex;   // not used
00075 } framePoint_t;
00076 
00077 // information for a single frame
00078 typedef struct
00079 {
00080    float scale[3];
00081    float translate[3];
00082    char name[16];
00083    framePoint_t fp[1];
00084 } frame_t;
00085 // data for a single triangle
00086 typedef struct
00087 {
00088    unsigned short meshIndex[3];         // vertex indices
00089    unsigned short stIndex[3];           // texture coordinate indices
00090 } mesh_t;
00091 //--------------------------------
00092 class ExCModelMD2 : public ExCModelMD
00093 {
00094 protected:
00095         int m_magic;                                    // This is used to identify the file
00096         int m_version;                                  // The version number of the file (Must be 8)
00097         int m_skinWidth;                                // The skin width in pixels
00098         int m_skinHeight;                               // The skin height in pixels
00099         int m_frameSize;                                // The size in bytes the frames are
00100         int m_numSkins;                         // The number of skins associated with the model
00101         int m_numVertices;                              // The number of vertices (constant for each frame)
00102         int m_numTexCoords;                     // The number of texture coordinates
00103         int m_numTriangles;                     // The number of faces (polygons)
00104         int m_numGlCommands;                    // The number of gl commands
00105         //int m_numFrames;                              // The number of animation frames
00106         int m_offsetSkins;                              // The offset in the file for the skin data
00107         int m_offsetTexCoords;                  // The offset in the file for the texture data
00108         int m_offsetTriangles;                  // The offset in the file for the face data
00109         int m_offsetFrames;                     // The offset in the file for the frames data
00110         int m_offsetGlCommands;         // The offset in the file for the gl commands data
00111         int m_offsetEnd;                                // The end of the file offset
00112         
00113 //--------------------------------
00114 // Variable
00115 //--------------------------------
00116         std::vector<std::string>        m_VecSkin;
00117         std::vector<ExCVec2D>           m_VecTexture;
00118         std::vector< std::pair<ExCVec3D , ExCVec3D > >  m_VecTriangle;
00119         std::vector<ExCVec3D>           m_VecVertex;
00120         std::string m_Skin;
00121 //--------------------------------
00122 // Methode
00123 //--------------------------------
00124 
00125 public:
00126 //--------------------------------
00127 // Constructor // Destructor
00128 //--------------------------------
00129         ExCModelMD2(void);
00130         //ExCModelMD2(const ExCModelMD2& copy);
00131         ~ExCModelMD2(void);
00132 //--------------------------------
00133 // Methode
00134 //--------------------------------
00135         void Draw(void);
00136         void DrawFrameFromFile(int NumFrame,int interpolation);
00137         bool Load(std::string FileName);
00138         void StopRun(void);
00139         void StartRun(void);
00140         void StartAction(std::string     Action);
00141         void StopAction(void);
00142         void Process(std::string         Action);
00143 };
00144 #endif //__EXCMODELMD2_H__

Généré le Tue Dec 10 18:18:09 2002 pour ExNihilo par doxygen1.3-rc1