Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

md2.h

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:17 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: md2.h,v 1.1.1.1 2002/12/07 19:02:17 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: md2.h,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:17  kolrabi
00031   initial release
00032 
00033 
00034 */
00035 
00042 #include            "forward.h"
00043  
00044 /**************************************************************************** 
00045  **************************************************************************** 
00046  * DEFINES ****************************************************************** 
00047  **************************************************************************** 
00048  ****************************************************************************/ 
00049 
00050 #define             MD2_MAGIC_NO        ('I'+('D'<<8)+('P'<<16)+('2'<<24))
00051  
00052 #define             MAX_NO_SKIN         5
00053 #define             MAX_SKIN_NAME       64
00054  
00055 #define             FRAME_HEADER_SIZE (sizeof(float)*6+16) 
00056 
00057 /**************************************************************************** 
00058  **************************************************************************** 
00059  * TYPES ******************************************************************** 
00060  **************************************************************************** 
00061  ****************************************************************************/ 
00062 
00063 #ifndef             OMICRON_MD2_TYPES_DEFINED 
00064 #define             OMICRON_MD2_TYPES_DEFINED 
00065 
00066 class md2_c: public model_c
00068 {
00069 private:
00070 
00071     struct md2_header_s
00073     { 
00074         ulong           magic;          
00075         ulong           version;
00076         ulong           skinWidth;
00077         ulong           skinHeight; 
00078         ulong           frameSize; 
00079  
00080         ulong           numSkins; 
00081         ulong           numVertices; 
00082         ulong           numTexCoords; 
00083         ulong           numTriangles; 
00084         ulong           numGlCommands; 
00085         ulong           numFrames; 
00086  
00087         ulong           offsetSkins; 
00088         ulong           offsetTexCoord; 
00089         ulong           offsetTriangles; 
00090         ulong           offsetFrames; 
00091         ulong           offsetGlCommands; 
00092         ulong           offsetEnd; 
00093     };
00094 
00095 #define MD2_TRIVERTSIZE ((sizeof uchar)*4)
00096     struct triangle_vertex_s
00098     { 
00099         uchar           vertex[3];      
00100         uchar           lnormal_idx;    
00101     };
00102  
00103     struct frame_s
00105     { 
00106         float           scale[3];       
00107         float           translate[3];   
00108         char            name[16];       
00109         triangle_vertex_s *pvertices;   
00110     };
00111  
00112     struct triangle_s
00114     { 
00115         ushort          vert_idx[3];    
00116         ushort          tex_idx[3];     
00117     };
00118 
00119     struct texture_coord_s
00121     { 
00122         sshort          s, t;
00123     };
00124  
00125     struct gl_command_s
00127     { 
00128         float           s, t;
00129         ulong           vert_idx;
00130     };
00131 
00132     void
00133     process_data();
00134 
00135 protected:
00136 
00137     md2_header_s    header;
00138 
00139     char            skinName[MAX_NO_SKIN][MAX_SKIN_NAME]; 
00140 
00141     texture_coord_s     *texData; 
00142     triangle_s          *triData; 
00143     triangle_vertex_s   *vertData; 
00144     frame_s             *frameData; 
00145 
00146     ushort          *glIndicesData; 
00147 
00148     unsigned int    listid;
00149 
00150     vertex_t        *vertices;
00151     ulong           vertcount;
00152 
00153 public:
00154 
00155     md2_c();
00156     virtual ~md2_c();
00157 
00158     bool
00159     load(const char* fileName);
00160 
00161     void
00162     unload();
00163 
00164     void                                
00165     set_frame(float frame);
00166 
00167     ulong
00168     get_frame_count();
00169 };
00170 
00171 #endif

Generated on Wed Dec 18 15:48:47 2002 for omicron engine by doxygen1.2.18