Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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