Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model/src/lib/graphics/importer/bsp_file.h @ 7801

Last change on this file since 7801 was 7801, checked in by bottac, 18 years ago

Support for animated textures in bsp maps started.

File size: 5.5 KB
Line 
1/*
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
13*/
14
15class SDL_Surface;
16class BspTreeNode;
17class Vector;
18class Material;
19class MoviePlayer;
20class VertexArrayModel;
21
22
23typedef struct
24{
25  float x;     //!< 1st component of the plane's normal
26  float y;     //!< 2nd component of the plane's normal
27  float z;     //!< 3rd component of the plane's normal
28  float d;     //!< distance of the plane to the origin
29}
30plane;
31
32typedef struct
33{
34  float mins [ 3 ]; //!< Bounding box min coord.
35  float maxs [ 3 ]; //!< Bounding box max coord.
36  int face;         //!< First face for model.
37  int n_faces;      //!< Number of faces for model.
38  int brush;        //!< First brush for model.
39  int n_brushes;    //!< Number of brushes
40}
41model;
42
43typedef struct
44{
45  int plane;        //!< Plane index.
46  int left;         //!< 1st Child index. Negative numbers are leaf indices: -(leaf+1).
47  int right;        //!< 2nd Child index. Negative numbers are leaf indices: -(leaf+1).
48  int mins[ 3 ];    //!< Integer bounding box min coord.
49  int maxs[ 3 ];    //!< Integer bounding box max coord.
50}
51node;
52
53typedef struct
54{
55  int cluster;            //!< Visdata cluster index.
56  int area;               //!< Areaportal area.
57  int mins[ 3 ];          //!< Integer bounding box min coord.
58  int maxs[ 3 ];          //!< Integer bounding box max coord.
59  int leafface;           //!< First leafface for leaf.
60  int n_leaffaces;        //!< Number of leaffaces for leaf.
61  int leafbrush_first;    //!< leafbrush for leaf.
62  int n_leafbrushes;      //!< Number of leafbrushes for leaf.
63}
64leaf;
65
66struct brush
67{
68  int brushside;        //!< First brushside for brush.
69  int n_brushsides;     //!< Number of brushsides for brush.
70  int texture;          //!< Texture index.
71};
72
73typedef struct
74{
75  int plane;    //!< Plane index.
76  int texture;  //!< Texture index.
77}
78brushside;
79
80struct face
81{
82  int texture;          //!< Texture index.
83  int effect;           //!< Index into lump 12 (Effects), or -1.
84  int type;             //!< Face type. 1=polygon, 2=patch, 3=mesh, 4=billboard
85  int vertex;           //!< Index of first vertex.
86  int n_vertexes;       //!< Number of vertices.
87  int meshvert;         //!< Index of first meshvert.
88  int n_meshverts;      //!< Number of meshverts.
89  int lm_index;         //!< Lightmap index.
90  int lm_start [ 2 ];   //!< Corner of this face's lightmap image in lightmap.
91  int lm_size [ 2 ];     //!< Size of this face's lightmap image in lightmap.
92  float lm_origin [ 3 ] ;    //!<  World space origin of lightmap.
93  float lm_vecs [ 2 ][ 3 ];  //!< World space lightmap s and t unit vectors.
94  float normal[ 3 ];         //!< Surface normal.
95  int size [ 2 ] ;           //!< Patch dimensions.
96} ;
97
98typedef struct
99{
100  float position[ 3 ];        //!< Vertex position.
101  float texcoord[ 2 ][ 2 ];   //!< Vertex texture coordinates. [0][x]=surface, [1][x]=lightmap.
102  float normal[ 3 ];          //!< Vertex normal.
103  unsigned char color [ 4 ];  //!< Vertex color. RGBA.
104}
105BspVertex;
106
107typedef struct
108{
109  int offset;
110}
111meshvert;                    //!< Integer offset to mesh vertex
112
113typedef struct
114{
115  float position [ 3 ];
116}
117BspVec;
118
119typedef struct
120{
121  Material* mat;
122  MoviePlayer* aviMat;
123  bool alpha;
124  bool animated;
125}
126AMat;
127
128typedef struct
129{
130  unsigned char map [128][128][3];
131}
132lightmap;
133
134typedef struct
135{
136  char name[64];
137  int flags;
138  int contents;
139}
140BspTexture;
141
142class BspFile
143{
144  friend class BspManager;
145
146public:
147  BspFile();
148  int read(const char* name );
149  void build_tree();
150  void load_textures();
151  void tesselate( int iface );
152  BspTreeNode* get_root();
153  AMat loadMat( char* mat );
154  AMat loadAVI(char * mat);
155 
156
157private:
158  BspTreeNode* root;
159  char header [ 280 ];       //!< Buffer for header of BSP-File
160  node* nodes;               //!< Buffer to store BSP-Tree-Nodes
161  leaf* leaves;              //!< Buffer to store BSP-Tree-Leaves
162  plane* planes;             //!< Buffer to store planes separateing the space
163  model* bspModels;          //!< Buffer to store BSP-Model-List
164  char* leafFaces;           //!< Buffer to store leafFaces
165  face* faces;               //!<
166  char* leafBrushes;         //!< Buffer to store brush indice
167  brush* brushes;            //!< Buffer to store  brushes
168  brushside* brushSides;     //!<
169  char* vertice;             //!<
170  meshvert* meshverts;       //!< Buffer to store meshverice
171  char* visData;             //!< Buffer to store visibility data
172  char* textures;            //!< Holds all the texture filename strings
173  char* patchVertice;        //!<
174  char* patchIndexes;
175  char* patchTrianglesPerRow;
176  lightmap* lightMaps;       //!< Buffer to store lightmap-images
177
178
179  int** patchRowIndexes;
180  VertexArrayModel** VertexArrayModels;
181  int patchOffset;
182
183  int numNodes;
184  int numLeafs;
185  int numVertex;
186  int numPlanes;
187  int numBspModels;
188  int numLeafFaces;
189  int numFaces;
190  int numLeafBrushes;
191  int numTextures;
192  int numPatches;
193  int numBrushSides;
194  int numLightMaps;
195
196
197
198  BspTreeNode* build_tree_rec( int i );
199  unsigned int loadLightMapToGL(lightmap&);
200  AMat* Materials;
201  unsigned int* glLightMapTextures;
202  unsigned int whiteLightMap;
203  unsigned char whiteTexture[3];
204  void swapAllBspCoordinates();
205  void swapCoords(int * array);
206  void swapCoords(float * array);
207  SDL_Surface* testSurf;
208
209 
210
211};
212
Note: See TracBrowser for help on using the repository browser.