Page principale | Hiérarchie des classes | Liste alphabétique | Liste des classes | Liste des fichiers | Membres de classe

C:/Projects/ngn/include/q3types.h

00001 /***************************************************************************
00002  *            q3types.h
00003  *
00004  *  Wed Jan 21 06:50:29 2004
00005  *  Copyright  2004  thierry schartz
00006  *  thierry.schartz@bluebottle.com
00007  ****************************************************************************/
00008 /*
00009  *  This program is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  This program is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU Library General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with this program; if not, write to the Free Software
00021  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023  /* thanks to   
00024  *      Ben Humphrey (DigiBen)
00025  *      Game Programmer
00026  *      DigiBen@GameTutorials.com
00027  *      Co-Web Host of www.GameTutorials.com
00028  */ 
00029  
00030 #ifndef _Q3TYPES_H
00031 #define _Q3TYPES_H
00032 
00033 #ifdef WIN32
00034 #include <windows.h>
00035 #endif
00036 
00037 #include <vector>
00038 #include "vector2d.h"
00039 #include "vector3d.h"
00040 
00041 // face properties
00042 #define FACE_POLYGON 1
00043 #define BEZIER_PATCH 2
00044 #define MESH_POLYGON 3
00045 #define BILLBOARD    4
00046 
00047 
00048 #define BSP_IDENT (('P'<<24)+('S'<<16)+('B'<<8)+'I')    // little-endian "IBSP"
00049 
00050 #define SURF_SKY 0x4                    // sky surface
00051 #define SURF_NONSOLID 0x4000    // don't collide against curves with this set
00052 
00053 // Following flags are used in tBSPTexture flags 
00054 #define CONTENTS_SOLID                  1                       
00055 #define CONTENTS_WINDOW                 2                       
00056 #define CONTENTS_AUX                    4
00057 #define CONTENTS_LAVA                   8
00058 #define CONTENTS_SLIME                  16                      // 0x10
00059 #define CONTENTS_WATER                  32                      // 0x20
00060 #define CONTENTS_FOG                    64                      // 0x40
00061 #define CONTENTS_TRANSLUCENT 0x20000000 // blended surface
00062 
00063 
00064 namespace ngn {
00065         namespace core {
00066 
00067 
00068                 /* BSP file format */
00069                 /*******************/
00070 
00071                         // This is our BSP header structure
00072                         struct tBSPHeader
00073                         {
00074                                 int id;                                         // This should always be 'IBSP'
00075                                 int version;                            // This should be 0x2e for Quake 3 files
00076                         }; 
00077 
00078 
00079                         // This is our BSP lump structure
00080                         struct tBSPLump
00081                         {
00082                                 int offset;                                     // The offset into the file for the start of this lump
00083                                 int length;                                     // The length in bytes for this lump
00084                         };
00085 
00086 
00087                         // This is our BSP vertex structure
00088                         struct tBSPVertex
00089                         {
00090                                 Vector3df vPosition;                    // (x, y, z) position. 
00091                                 Vector2df vTextureCoord;                // (u, v) texture coordinate
00092                                 Vector2df vLightmapCoord;       // (u, v) lightmap coordinate
00093                                 Vector3df vNormal;                      // (x, y, z) normal vector
00094                                 unsigned char color[4];                         // RGBA color for the vertex 
00095 
00096                                 tBSPVertex operator+(const tBSPVertex& v)       
00097                                 {
00098                                         tBSPVertex res;
00099                                         res.vPosition = vPosition+v.vPosition;
00100                                         res.vTextureCoord = vTextureCoord+v.vTextureCoord;
00101                                         res.vLightmapCoord = vLightmapCoord+v.vLightmapCoord;
00102                                         return res;
00103                                 }
00104                                 tBSPVertex operator*(float factor)      
00105                                 {
00106                                         tBSPVertex res;
00107                                         res.vPosition = vPosition*factor;
00108                                         res.vTextureCoord = vTextureCoord*factor;
00109                                         res.vLightmapCoord = vLightmapCoord*factor;
00110                                         return res;
00111                                 }
00112                         };
00113 
00114 
00115                         // This is our BSP face structure
00116                         struct tBSPFace
00117                         {
00118                                 int textureID;                          // The index into the texture array 
00119                                 int effect;                                     // The index for the effects (or -1 = n/a) 
00120                                 int type;                                       // 1=polygon, 2=patch, 3=mesh, 4=billboard 
00121                                 int startVertIndex;                     // The starting index into this face's first vertex 
00122                                 int numOfVerts;                         // The number of vertices for this face 
00123                                 int meshVertIndex;                      // The index into the first meshvertex 
00124                                 int numMeshVerts;                       // The number of mesh vertices 
00125                                 int lightmapID;                         // The texture index for the lightmap 
00126                                 int lMapCorner[2];                      // The face's lightmap corner in the image 
00127                                 int lMapSize[2];                        // The size of the lightmap section 
00128                                 Vector3df lMapPos;                      // The 3D origin of lightmap. 
00129                                 Vector3df lMapVecs[2];          // The 3D space for s and t unit vectors. 
00130                                 Vector3df vNormal;                      // The face normal. 
00131                                 int size[2];                            // The bezier patch dimensions. 
00132                         };
00133 
00134 
00135                         // This is our BSP texture structure
00136                         struct tBSPTexture
00137                         {
00138                                 char strName[64];                       // The name of the texture w/o the extension 
00139                                 int flags;                                      // The surface flags (unknown) 
00140                                 int type;                                       // solid, water, slime face ...
00141                         };
00142 
00143                         // This is our BSP lightmap structure which stores the 128x128 RGB values
00144                         struct tBSPLightmap
00145                         {
00146                                 unsigned char imageBits[128][128][3];   // The RGB data in a 128x128 image
00147                         };
00148 
00149 
00150                         // This stores a node in the BSP tree
00151                         struct tBSPNode
00152                         {
00153                                 int plane;                                      // The index into the planes array 
00154                                 int front;                                      // The child index for the front node 
00155                                 int back;                                       // The child index for the back node 
00156                                 Vector3di min;                          // The bounding box min position. 
00157                                 Vector3di max;                          // The bounding box max position. 
00158                         }; 
00159 
00160                         // This stores a leaf (end node) in the BSP tree
00161                         struct tBSPLeaf
00162                         {
00163                                 int cluster;                            // The visibility cluster 
00164                                 int area;                                       // The area portal 
00165                                 Vector3di min;                          // The bounding box min position 
00166                                 Vector3di max;                          // The bounding box max position 
00167                                 int leafface;                           // The first index into the face array 
00168                                 int numOfLeafFaces;                     // The number of faces for this leaf 
00169                                 int leafBrush;                          // The first index for into the brushes 
00170                                 int numOfLeafBrushes;           // The number of brushes for this leaf 
00171                         }; 
00172 
00173                         // This stores a splitter plane in the BSP tree
00174                         struct tBSPPlane
00175                         {
00176                                 Vector3df vNormal;                      // Plane normal. 
00177                                 float d;                                        // The plane distance from origin 
00178                         };
00179 
00180                         // This stores the cluster data for the PVS's
00181                         struct tBSPVisData
00182                         {
00183                                 int numOfClusters;                      // The number of clusters
00184                                 int bytesPerCluster;            // The amount of bytes (8 bits) in the cluster's bitset
00185                                 unsigned char *pBitsets;        // The array of bytes that holds the cluster bitsets                            
00186                         };
00187 
00188                         struct tBSPModel
00189                         {
00190                                 Vector3df min;           // The min position for the bounding box
00191                                 Vector3df max;           // The max position for the bounding box. 
00192                                 int faceIndex;          // The first face index in the model 
00193                                 int numOfFaces;         // The number of faces in the model 
00194                                 int brushIndex;         // The first brush index in the model 
00195                                 int numOfBrushes;       // The number brushes for the model
00196                         };
00197 
00198                         struct tBSPLights
00199                         {
00200                                 unsigned char ambient[3];     // This is the ambient color in RGB
00201                                 unsigned char directional[3]; // This is the directional color in RGB
00202                                 unsigned char direction[2];   // The direction of the light: [phi,theta] 
00203                         };
00204 
00205                         // This stores the brush data
00206                         struct tBSPBrush 
00207                         {
00208                                 int brushSide;                          // The starting brush side for the brush 
00209                                 int numOfBrushSides;            // Number of brush sides for the brush
00210                                 int textureID;                          // The texture index for the brush
00211                         }; 
00212                         
00213                         // This stores the brush side data, which stores indices for the normal and texture ID
00214                         struct tBSPBrushSide 
00215                         {
00216                                 int plane;                                      // The plane index
00217                                 int textureID;                          // The texture index
00218                         }; 
00219 
00220                         
00221                         enum eLumps
00222                         {
00223                                 kEntities = 0,                          // Stores player/object positions, etc...
00224                                 kTextures,                                      // Stores texture information
00225                                 kPlanes,                                    // Stores the splitting planes
00226                                 kNodes,                                         // Stores the BSP nodes
00227                                 kLeafs,                                         // Stores the leafs of the nodes
00228                                 kLeafFaces,                                     // Stores the leaf's indices into the faces
00229                                 kLeafBrushes,                           // Stores the leaf's indices into the brushes
00230                                 kModels,                                        // Stores the info of world models
00231                                 kBrushes,                                       // Stores the brushes info (for collision)
00232                                 kBrushSides,                            // Stores the brush surfaces info
00233                                 kVertices,                                      // Stores the level vertices
00234                                 kMeshVerts,                                     // Stores the model vertices offsets
00235                                 kShaders,                                       // Stores the shader files (blending, anims..)
00236                                 kFaces,                                         // Stores the faces for the level
00237                                 kLightmaps,                                     // Stores the lightmaps for the level
00238                                 kLightVolumes,                          // Stores extra world lighting information
00239                                 kVisData,                                       // Stores PVS and cluster info (visibility)
00240                                 kMaxLumps                                       // A constant to store the number of lumps
00241 
00242                         };
00243 
00244 
00245                 
00246 /*
00247 // These file formats are owned by ID Software. This should
00248 // not be sold or used under any way for commercial use with out written consent
00249 // from ID Software.
00250 //
00251 // Quake2 and Quake3 are trademarks of id Software.
00252 // All trademarks used are properties of their respective owners.
00253 */
00254 
00255 
00256 
00257 
00258     }//core
00259 }//ngn    
00260 #endif /* _Q3TYPES_H */

Généré le Fri Nov 19 14:20:29 2004 pour NGN par  doxygen 1.3.9.1