KeosMDLQ1Loader.h

Go to the documentation of this file.
00001 /*
00002  * This source file is part of KEOS (Free 3D Engine)
00003  * For the latest info, see http://www.keosengine.org/
00004  * E-mails : thierry.vouriot@keosengine.org, yeri@keosengine.org
00005  *
00006  * This program is free software; you can redistribute it and/or modify it under
00007  * the terms of the GNU Lesser General Public License as published by the Free Software
00008  * Foundation; either version 2 of the License, or (at your option) any later
00009  * version.
00010  *
00011  * This program is distributed in the hope that it will be useful, but WITHOUT
00012  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00018  * http://www.gnu.org/copyleft/lesser.txt.
00019  *
00020  */
00021 #ifndef KEOS_MDLQ1LOADER_H
00022 #define KEOS_MDLQ1LOADER_H
00023 
00024 #include "KeosPrerequisites.h"
00025 #include "KeosLoader.h"
00026 #include "KeosMesh.h"
00027 
00028 namespace Keos
00029 {
00030   //-----------------------------------------------------------------------
00033   class CMDLQ1Loader : public ILoader<CMesh>
00034   {
00035   public :
00036 
00041     virtual CMesh* LoadFromFile(const String& strFilename);
00042 
00043   private :
00044 
00049     void LoadColorMap( const String& strFilename, uchar* ColorMap );
00050 
00052     static const int ms_nMagicId = (('O' << 24) + ('P' << 16) + ('D' << 8) + 'I');
00054     static const int ms_nMDLQ1Version = 6;
00056     static const TVector3F ms_NormalTable[];
00058     static const uchar ms_DefaultColorMap[];
00059 
00060 #include <pshpack1.h>
00061 
00062     typedef enum
00063     {
00064       ST_SYNC = 0, ST_RAND
00065     }
00066     TSyncType;
00067     typedef enum { ALIAS_SKIN_SINGLE = 0, ALIAS_SKIN_GROUP } TSkinType;
00068 
00070     struct THeader
00071     {
00072       int   Ident;   // This is used to identify the file
00073       int   Version;  // The version number of the file (Must be 6)
00074 
00075       TVector3F Scale;
00076       TVector3F Translate;  // Translation vector
00077       float  BoundinGradius; // Bounding sphere radius
00078       TVector3F EyePosition; // Eye position
00079 
00080       int   NbTextures;  // The number of textures
00081       int   TexWidth;  // largeur texture
00082       int   TexHeight;  // hauteur texture
00083 
00084       int   NbVertices;  // The number of vertices
00085       int   NbTriangles; // The number of triangles
00086       int   NbFrames;  // The number of frames
00087 
00088       TSyncType SyncType;
00089       int   Flags;
00090       float  Size;
00091 
00092     };
00093 
00094     // Texture
00095     struct TTexture
00096     {
00097       TSkinType   Group; // Value = 0
00098       std::vector<uchar> Data; // Texture data
00099 
00100     };
00101 
00103     struct TTexCoord
00104     {
00105       int  Onseam;   // 0 or 0x20
00106       int  u;
00107       int  v;
00108 
00109     };
00110 
00111     // Triangle
00112     struct TTriangle
00113     {
00114       int  FacesFront;  // 0 = back face, 1 = front face
00115       int  Vertices[3]; // Vertices index
00116 
00117     };
00118 
00119     // Vertice
00120     struct TPoint
00121     {
00122       unsigned char x, y, z;
00123       unsigned char n; // light normal index
00124 
00125     };
00126 
00127     // Frame
00128     struct TFrame
00129     {
00130       long    Type;
00131       TPoint    BBoxMin;
00132       TPoint    BBoxMax;
00133       char    Name[16];
00134       std::vector<TPoint> Vertices;
00135 
00136     };
00137 
00138 #include <poppack.h>
00139   };
00140 } // namespace Keos
00141 
00142 #endif // KEOS_MDLQ1LOADER_H

Generated on Fri Mar 9 14:29:02 2007 for Keos by  doxygen 1.5.1-p1