Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/importer/bsp_file.h @ 9003

Last change on this file since 9003 was 9003, checked in by bensch, 18 years ago

orxonox/trunk: merged the single_player_map branche back
merged with command:
svn merge -r8896:HEAD https://svn.orxonox.net/orxonox/branches/single_player_map .
no conflicts

File size: 5.9 KB
RevLine 
[7353]1/*
[7385]2 orxonox - the future of 3D-vertical-scrollers
3 
4 Copyright (C) 2006 orx
5 
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10 
11 ### File Specific:
12 main-programmer: bottac@ee.ethz.ch
[8081]13 
14  Inspired by:
15  Rendering Q3 Maps by Morgan McGuire                  http://graphics.cs.brown.edu/games/quake/quake3.html
16  Unofficial Quake 3 Map Specs by Kekoa Proudfoot      http://graphics.stanford.edu/~kekoa/q3/
17  Quake 3 Collision Detection by Nathan Ostgard        http://www.devmaster.net/articles/quake3collision/
[7353]18*/
19
[8490]20#include <vector>
[7385]21class SDL_Surface;
[7353]22class BspTreeNode;
23class Vector;
24class Material;
[7801]25class MoviePlayer;
[7353]26class VertexArrayModel;
27
[7801]28
[8030]29 struct plane
[7353]30{
[7395]31  float x;     //!< 1st component of the plane's normal
32  float y;     //!< 2nd component of the plane's normal
33  float z;     //!< 3rd component of the plane's normal
34  float d;     //!< distance of the plane to the origin
[8030]35};
[7353]36
37typedef struct
38{
[7395]39  float mins [ 3 ]; //!< Bounding box min coord.
40  float maxs [ 3 ]; //!< Bounding box max coord.
41  int face;         //!< First face for model.
42  int n_faces;      //!< Number of faces for model.
43  int brush;        //!< First brush for model.
44  int n_brushes;    //!< Number of brushes
[7385]45}
46model;
[7353]47
48typedef struct
49{
[7395]50  int plane;        //!< Plane index.
51  int left;         //!< 1st Child index. Negative numbers are leaf indices: -(leaf+1).
52  int right;        //!< 2nd Child index. Negative numbers are leaf indices: -(leaf+1).
53  int mins[ 3 ];    //!< Integer bounding box min coord.
54  int maxs[ 3 ];    //!< Integer bounding box max coord.
[7385]55}
56node;
[7353]57
58typedef struct
59{
[7395]60  int cluster;            //!< Visdata cluster index.
61  int area;               //!< Areaportal area.
62  int mins[ 3 ];          //!< Integer bounding box min coord.
63  int maxs[ 3 ];          //!< Integer bounding box max coord.
64  int leafface;           //!< First leafface for leaf.
65  int n_leaffaces;        //!< Number of leaffaces for leaf.
66  int leafbrush_first;    //!< leafbrush for leaf.
67  int n_leafbrushes;      //!< Number of leafbrushes for leaf.
[7385]68}
69leaf;
[7353]70
[7563]71struct brush
[7353]72{
[7395]73  int brushside;        //!< First brushside for brush.
74  int n_brushsides;     //!< Number of brushsides for brush.
75  int texture;          //!< Texture index.
[7563]76};
[7353]77
78typedef struct
79{
[7395]80  int plane;    //!< Plane index.
81  int texture;  //!< Texture index.
[7385]82}
83brushside;
[7353]84
[7385]85struct face
[7353]86{
[7395]87  int texture;          //!< Texture index.
88  int effect;           //!< Index into lump 12 (Effects), or -1.
89  int type;             //!< Face type. 1=polygon, 2=patch, 3=mesh, 4=billboard
90  int vertex;           //!< Index of first vertex.
91  int n_vertexes;       //!< Number of vertices.
92  int meshvert;         //!< Index of first meshvert.
93  int n_meshverts;      //!< Number of meshverts.
94  int lm_index;         //!< Lightmap index.
95  int lm_start [ 2 ];   //!< Corner of this face's lightmap image in lightmap.
[7465]96  int lm_size [ 2 ];     //!< Size of this face's lightmap image in lightmap.
[7395]97  float lm_origin [ 3 ] ;    //!<  World space origin of lightmap.
98  float lm_vecs [ 2 ][ 3 ];  //!< World space lightmap s and t unit vectors.
99  float normal[ 3 ];         //!< Surface normal.
100  int size [ 2 ] ;           //!< Patch dimensions.
[7353]101} ;
102
103typedef struct
104{
[7395]105  float position[ 3 ];        //!< Vertex position.
106  float texcoord[ 2 ][ 2 ];   //!< Vertex texture coordinates. [0][x]=surface, [1][x]=lightmap.
107  float normal[ 3 ];          //!< Vertex normal.
108  unsigned char color [ 4 ];  //!< Vertex color. RGBA.
[7385]109}
110BspVertex;
[7353]111
112typedef struct
113{
[7385]114  int offset;
115}
[7395]116meshvert;                    //!< Integer offset to mesh vertex
[7353]117
[7385]118typedef struct
[7353]119{
[7385]120  float position [ 3 ];
121}
122BspVec;
[7353]123
[7385]124typedef struct
[7353]125{
[7385]126  Material* mat;
[7801]127  MoviePlayer* aviMat;
[7385]128  bool alpha;
[7801]129  bool animated;
[7385]130}
131AMat;
[7353]132
[7465]133typedef struct
134{
135  unsigned char map [128][128][3];
136}
137lightmap;
138
[7563]139typedef struct
140{
141  char name[64];
142  int flags;
143  int contents;
144}
145BspTexture;
146
[7385]147class BspFile
148{
149  friend class BspManager;
[7353]150
[7385]151public:
152  BspFile();
[9003]153  ~BspFile();
[7596]154  int read(const char* name );
[7385]155  void build_tree();
156  void load_textures();
157  void tesselate( int iface );
158  BspTreeNode* get_root();
159  AMat loadMat( char* mat );
[7801]160  AMat loadAVI(char * mat);
161 
[7353]162
[7385]163private:
164  BspTreeNode* root;
165  char header [ 280 ];       //!< Buffer for header of BSP-File
[7395]166  node* nodes;               //!< Buffer to store BSP-Tree-Nodes
167  leaf* leaves;              //!< Buffer to store BSP-Tree-Leaves
168  plane* planes;             //!< Buffer to store planes separateing the space
169  model* bspModels;          //!< Buffer to store BSP-Model-List
[7385]170  char* leafFaces;           //!< Buffer to store leafFaces
[7395]171  face* faces;               //!<
[7385]172  char* leafBrushes;         //!< Buffer to store brush indice
[7410]173  brush* brushes;            //!< Buffer to store  brushes
[7507]174  brushside* brushSides;     //!<
[7385]175  char* vertice;             //!<
[7511]176  meshvert* meshverts;       //!< Buffer to store meshverice
177  char* visData;             //!< Buffer to store visibility data
178  char* textures;            //!< Holds all the texture filename strings
[7465]179  char* patchVertice;        //!<
[7385]180  char* patchIndexes;
181  char* patchTrianglesPerRow;
[7465]182  lightmap* lightMaps;       //!< Buffer to store lightmap-images
183
184
[7385]185  int** patchRowIndexes;
[9003]186  VertexArrayModel** VertexArrayModels; 
[7385]187  int patchOffset;
188
189  int numNodes;
190  int numLeafs;
191  int numVertex;
192  int numPlanes;
193  int numBspModels;
194  int numLeafFaces;
195  int numFaces;
196  int numLeafBrushes;
197  int numTextures;
198  int numPatches;
199  int numBrushSides;
[7465]200  int numLightMaps;
[8030]201 
202  float  scale;
[7385]203
204  BspTreeNode* build_tree_rec( int i );
[7465]205  unsigned int loadLightMapToGL(lightmap&);
[7385]206  AMat* Materials;
[7465]207  unsigned int* glLightMapTextures;
208  unsigned int whiteLightMap;
209  unsigned char whiteTexture[3];
[7801]210  void swapAllBspCoordinates();
211  void swapCoords(int * array);
212  void swapCoords(float * array);
[7385]213  SDL_Surface* testSurf;
214
[7801]215 
[8490]216  ::std::vector<MoviePlayer* > MovieMaterials; //!< Movieplayer Materials
[7353]217};
218
Note: See TracBrowser for help on using the repository browser.