KeosMD2AnimatedLoader.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_MD2ANIMATEDLOADER_H
00022 #define KEOS_MD2ANIMATEDLOADER_H
00023 
00024 #include "KeosPrerequisites.h"
00025 #include "KeosLoader.h"
00026 #include "KeosAnimatedMeshKF.h"
00027 
00028 namespace Keos
00029 {
00030   //-----------------------------------------------------------------------
00033   class CMD2AnimatedLoader : public ILoader<CAnimatedMeshKF>
00034   {
00035   public :
00036 
00041     virtual CAnimatedMeshKF* LoadFromFile(const String& strFilename);
00042 
00043   private :
00044 
00046     static const int ms_nMagicId    = ('2' << 24) + ('P' << 16) + ('D' << 8) + 'I';
00048     static const int ms_nMD2Version = 8;
00050     static const TVector3F ms_NormalTable[];
00051 
00052 #include <pshpack1.h>
00053 
00055     struct THeader
00056     {
00057       int Ident;            // This is used to identify the file
00058       int Version;          // The version number of the file (Must be 8)
00059       int TexWidth;         // The skin width in pixels
00060       int TexHeight;        // The skin height in pixels
00061       int FrameSize;        // The size in bytes the frames are
00062       int NbTextures;       // The number of skins associated with the model
00063       int NbVertices;       // The number of vertices (constant for each frame)
00064       int NbTexCoords;      // The number of texture coordinates
00065       int NbTriangles;      // The number of faces (polygons)
00066       int NbGLCommands;     // The number of gl commands
00067       int NbFrames;         // The number of animation frames
00068       int OffsetTextures;   // The offset in the file for the skin data
00069       int OffsetTexCoords;  // The offset in the file for the texture data
00070       int OffsetTriangles;  // The offset in the file for the face data
00071       int OffsetFrames;     // The offset in the file for the frames data
00072       int OffsetGLCommands; // The offset in the file for the gl commands data
00073       int OffsetEnd;        // The end of the file offset
00074     };
00075 
00077     struct TPoint
00078     {
00079       unsigned char x, y, z;
00080       unsigned char n; // light normal index
00081     };
00082 
00084     struct TTexCoord
00085     {
00086       short u, v;
00087     };
00088 
00090     struct TTriangle
00091     {
00092       unsigned short Vertices[3];
00093       unsigned short TexCoords[3];
00094     };
00095 
00096     // This stores a skin name
00097     struct TTexture
00098     {
00099       char Name[68];
00100     };
00101 
00102     // This stores the animation scale, translation and name information for a frame, plus verts
00103     struct TFrame
00104     {
00105       TVector3F           Scale;
00106       TVector3F           Translate;
00107       char                Name[16];
00108       std::vector<TPoint> Vertices;
00109     };
00110 #include <poppack.h>
00111   };
00112 } // namespace Keos
00113 
00114 #endif // KEOS_MD2ANIMATEDLOADER_H

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