Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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