root/OpenSceneGraph/trunk/src/osgPlugins/bsp/Q3BSPLoad.h @ 13041

Revision 13041, 3.5 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1
2
3#ifndef Q3BSPLOAD_H
4#define Q3BSPLOAD_H
5
6
7#include <osg/Vec3f>
8#include <osg/GL>
9
10#include <vector>
11#include <string>
12
13#include <fstream>
14
15
16namespace bsp
17{
18
19
20//Directory entry in header
21class BSP_DIRECTORY_ENTRY
22{
23public:
24    int m_offset;
25    int m_length;
26};
27
28//Types of directory entry
29enum BSP_DIRECTORY_ENTRY_TYPE
30{
31    bspEntities=0,
32    bspTextures,
33    bspPlanes,
34    bspNodes,
35    bspLeaves,
36    bspLeafFaces,
37    bspLeafBrushes,
38    bspModels,
39    bspBrushes,
40    bspBrushSides,
41    bspVertices,
42    bspMeshIndices,
43    bspEffect,
44    bspFaces,
45    bspLightmaps,
46    bspLightVols,
47    bspVisData
48};
49
50
51
52//BSP file header
53class BSP_HEADER
54{
55public:
56  char m_string[4];
57  int m_version;
58  BSP_DIRECTORY_ENTRY m_directoryEntries[17];
59};
60
61
62
63//vertex as found in file
64class BSP_LOAD_VERTEX
65{
66public:
67  osg::Vec3f m_position;
68  float m_decalS, m_decalT;
69  float m_lightmapS, m_lightmapT;
70  osg::Vec3f m_normal;
71  unsigned char m_color[4];
72};
73
74struct BSP_LoadPlane
75{
76  osg::Vec3f m_Normal;
77  float      m_Dist;
78};
79
80
81
82//face as found in the file
83class BSP_LOAD_FACE
84{
85public:
86  int m_texture;
87  int m_effect;  // No se usa
88  int m_type;
89  int m_firstVertexIndex;
90  int m_numVertices;
91  unsigned int m_firstMeshIndex;
92  unsigned int m_numMeshIndices;
93  int m_lightmapIndex;
94  int m_lightmapStart[2]; // No se usa
95  int m_lightmapSize[2];  // No se usa
96  //VECTOR3D m_lightmapOrigin;  // No se usa
97  //VECTOR3D m_sTangent, m_tTangent;  // No se usa
98  //VECTOR3D m_normal;  // No se usa
99
100  osg::Vec3f m_lightmapOrigin;  // No se usa
101  osg::Vec3f m_sTangent, m_tTangent;  // No se usa
102  osg::Vec3f m_normal;  // No se usa
103
104
105  int m_patchSize[2];
106};
107
108
109
110
111
112
113//texture as found in file
114class BSP_LOAD_TEXTURE
115{
116public:
117  char m_name[64];
118  int m_flags, m_contents;    //unknown, no se usa
119};
120
121//lightmap as found in file
122class BSP_LOAD_LIGHTMAP
123{
124public:
125  unsigned char m_lightmapData[128*128*3];
126};
127
128
129
130
131
132//leaf of bsp tree as found in file
133class BSP_LOAD_LEAF
134{
135public:
136  int m_cluster;    //cluster index for visdata
137  int m_area;       //areaportal area,   No se usa
138  int m_mins[3];    //min x,y,z (bounding box)
139  int m_maxs[3];
140  int m_firstLeafFace;  //first index in leafFaces array
141  int m_numFaces;
142  int m_firstLeafBrush; //first index into leaf brushes array, No se usa
143  int m_numBrushes;     // No se usa
144};
145
146
147
148
149//node of BSP tree
150class BSP_NODE
151{
152public:
153  int m_planeIndex;
154  int m_front, m_back;    //child nodes
155  int m_mins[3];    //min x,y,z (bounding box)  No se usa
156  int m_maxs[3];    // No se usa
157};
158
159
160
161
162//VIS data table
163class BSP_VISIBILITY_DATA
164{
165public:
166  int m_numClusters;
167  int m_bytesPerCluster;
168  std::vector<unsigned char> m_bitset;
169
170};
171
172
173
174
175
176
177
178class Q3BSPLoad
179{
180public:
181
182  bool Load(const std::string& filename, int curveTessellation);
183  void LoadVertices(std::ifstream& aFile);
184  void LoadFaces(std::ifstream& aFile, int curveTessellation);
185  void LoadTextures(std::ifstream& aFile);
186  void LoadLightmaps(std::ifstream& aFile);
187  void LoadBSPData(std::ifstream& aFile);
188
189
190  std::string m_entityString;
191  //header
192  BSP_HEADER m_header;
193
194  // Load Data
195  std::vector<BSP_LOAD_VERTEX>    m_loadVertices;
196  std::vector<GLuint>             m_loadMeshIndices;
197  std::vector<BSP_LOAD_FACE>      m_loadFaces;
198  std::vector<BSP_LOAD_TEXTURE>   m_loadTextures;
199  std::vector<BSP_LOAD_LIGHTMAP>  m_loadLightmaps;
200  std::vector<BSP_LOAD_LEAF>      m_loadLeaves;
201  std::vector<int>                m_loadLeafFaces;
202  std::vector<BSP_LoadPlane>      m_loadPlanes;
203  std::vector<BSP_NODE>           m_loadNodes;
204  BSP_VISIBILITY_DATA             m_loadVisibilityData;
205};
206
207
208}
209
210
211#endif  // Q3BSPLOAD_H
Note: See TracBrowser for help on using the browser.