Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

# 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 "KeosModel.h"
    00027
    00028 namespace Keos
    00029 {
    00030     //-----------------------------------------------------------------------
    00033     class CMDLQ1Loader : public ILoader<CModel>
    00034     {
    00035     public :
    00036
    00041         virtual CModel* 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 { ST_SYNC = 0, ST_RAND } TSyncType;
    00063         typedef enum { ALIAS_SKIN_SINGLE = 0, ALIAS_SKIN_GROUP } TSkinType;
    00064
    00066         struct THeader
    00067         {
    00068                 int                     Ident;                  // This is used to identify the file
    00069                 int                     Version;                // The version number of the file (Must be 6)
    00070
    00071                 TVector3F       Scale;
    00072                 TVector3F       Translate;              // Translation vector
    00073                 float           BoundinGradius; // Bounding sphere radius
    00074                 TVector3F       EyePosition;    // Eye position
    00075
    00076                 int                     NbTextures;             // The number of textures
    00077                 int                     TexWidth;               // largeur texture
    00078                 int                     TexHeight;              // hauteur texture
    00079
    00080                 int                     NbVertices;             // The number of vertices
    00081                 int                     NbTriangles;    // The number of triangles
    00082                 int                     NbFrames;               // The number of frames
    00083
    00084                 TSyncType       SyncType;
    00085                 int                     Flags;
    00086                 float           Size;
    00087
    00088         };
    00089
    00090         // Texture
    00091         struct TTexture
    00092         {
    00093                 TSkinType                       Group;  // Value = 0
    00094                 std::vector<uchar>      Data;   // Texture data
    00095
    00096         };
    00097
    00099         struct TTexCoord
    00100         {
    00101                 int             Onseam;                 // 0 or 0x20
    00102                 int             u;
    00103                 int             v;
    00104
    00105         };
    00106
    00107         // Triangle
    00108         struct TTriangle
    00109         {
    00110                 int             FacesFront;             // 0 = back face, 1 = front face
    00111                 int             Vertices[3];    // Vertices index
    00112
    00113         };
    00114
    00115         // Vertice
    00116         struct TPoint
    00117         {
    00118                 unsigned char x, y, z;
    00119                 unsigned char n;        // light normal index
    00120
    00121         };
    00122
    00123         // Frame
    00124         struct TFrame
    00125         {
    00126                 long                            Type;
    00127                 TPoint                          BBoxMin;
    00128                 TPoint                          BBoxMax;
    00129                 char                            Name[16];
    00130                 std::vector<TPoint>     Vertices;
    00131
    00132         };
    00133
    00134         #include <poppack.h>
    00135     };
    00136 } // namespace Keos
    00137
    00138 #endif // KEOS_MDLQ1LOADER_H