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
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
[7353]13*/
14
[7385]15class SDL_Surface;
[7353]16class BspTreeNode;
17class Vector;
18class Material;
[7801]19class MoviePlayer;
[7353]20class VertexArrayModel;
21
[7801]22
[7385]23typedef struct
[7353]24{
[7395]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
[7385]29}
30plane;
[7353]31
32typedef struct
33{
[7395]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
[7385]40}
41model;
[7353]42
43typedef struct
44{
[7395]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.
[7385]50}
51node;
[7353]52
53typedef struct
54{
[7395]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.
[7385]63}
64leaf;
[7353]65
[7563]66struct brush
[7353]67{
[7395]68  int brushside;        //!< First brushside for brush.
69  int n_brushsides;     //!< Number of brushsides for brush.
70  int texture;          //!< Texture index.
[7563]71};
[7353]72
73typedef struct
74{
[7395]75  int plane;    //!< Plane index.
76  int texture;  //!< Texture index.
[7385]77}
78brushside;
[7353]79
[7385]80struct face
[7353]81{
[7395]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.
[7465]91  int lm_size [ 2 ];     //!< Size of this face's lightmap image in lightmap.
[7395]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.
[7353]96} ;
97
98typedef struct
99{
[7395]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.
[7385]104}
105BspVertex;
[7353]106
107typedef struct
108{
[7385]109  int offset;
110}
[7395]111meshvert;                    //!< Integer offset to mesh vertex
[7353]112
[7385]113typedef struct
[7353]114{
[7385]115  float position [ 3 ];
116}
117BspVec;
[7353]118
[7385]119typedef struct
[7353]120{
[7385]121  Material* mat;
[7801]122  MoviePlayer* aviMat;
[7385]123  bool alpha;
[7801]124  bool animated;
[7385]125}
126AMat;
[7353]127
[7465]128typedef struct
129{
130  unsigned char map [128][128][3];
131}
132lightmap;
133
[7563]134typedef struct
135{
136  char name[64];
137  int flags;
138  int contents;
139}
140BspTexture;
141
[7385]142class BspFile
143{
144  friend class BspManager;
[7353]145
[7385]146public:
147  BspFile();
[7596]148  int read(const char* name );
[7385]149  void build_tree();
150  void load_textures();
151  void tesselate( int iface );
152  BspTreeNode* get_root();
153  AMat loadMat( char* mat );
[7801]154  AMat loadAVI(char * mat);
155 
[7353]156
[7385]157private:
158  BspTreeNode* root;
159  char header [ 280 ];       //!< Buffer for header of BSP-File
[7395]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
[7385]164  char* leafFaces;           //!< Buffer to store leafFaces
[7395]165  face* faces;               //!<
[7385]166  char* leafBrushes;         //!< Buffer to store brush indice
[7410]167  brush* brushes;            //!< Buffer to store  brushes
[7507]168  brushside* brushSides;     //!<
[7385]169  char* vertice;             //!<
[7511]170  meshvert* meshverts;       //!< Buffer to store meshverice
171  char* visData;             //!< Buffer to store visibility data
172  char* textures;            //!< Holds all the texture filename strings
[7465]173  char* patchVertice;        //!<
[7385]174  char* patchIndexes;
175  char* patchTrianglesPerRow;
[7465]176  lightmap* lightMaps;       //!< Buffer to store lightmap-images
177
178
[7385]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;
[7465]194  int numLightMaps;
[7385]195
[7563]196
197
[7385]198  BspTreeNode* build_tree_rec( int i );
[7465]199  unsigned int loadLightMapToGL(lightmap&);
[7385]200  AMat* Materials;
[7465]201  unsigned int* glLightMapTextures;
202  unsigned int whiteLightMap;
203  unsigned char whiteTexture[3];
[7801]204  void swapAllBspCoordinates();
205  void swapCoords(int * array);
206  void swapCoords(float * array);
[7385]207  SDL_Surface* testSurf;
208
[7801]209 
210
[7353]211};
212
Note: See TracBrowser for help on using the repository browser.