diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/CQ3LevelMesh.h | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CQ3LevelMesh.h | 982 |
1 files changed, 491 insertions, 491 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CQ3LevelMesh.h b/libraries/irrlicht-1.8/source/Irrlicht/CQ3LevelMesh.h index b7e9cf1..4d5659b 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CQ3LevelMesh.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CQ3LevelMesh.h | |||
@@ -1,491 +1,491 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __C_Q3_LEVEL_MESH_H_INCLUDED__ | 5 | #ifndef __C_Q3_LEVEL_MESH_H_INCLUDED__ |
6 | #define __C_Q3_LEVEL_MESH_H_INCLUDED__ | 6 | #define __C_Q3_LEVEL_MESH_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IQ3LevelMesh.h" | 8 | #include "IQ3LevelMesh.h" |
9 | #include "IReadFile.h" | 9 | #include "IReadFile.h" |
10 | #include "IFileSystem.h" | 10 | #include "IFileSystem.h" |
11 | #include "SMesh.h" | 11 | #include "SMesh.h" |
12 | #include "SMeshBufferLightMap.h" | 12 | #include "SMeshBufferLightMap.h" |
13 | #include "IVideoDriver.h" | 13 | #include "IVideoDriver.h" |
14 | #include "irrString.h" | 14 | #include "irrString.h" |
15 | #include "ISceneManager.h" | 15 | #include "ISceneManager.h" |
16 | #include "os.h" | 16 | #include "os.h" |
17 | 17 | ||
18 | namespace irr | 18 | namespace irr |
19 | { | 19 | { |
20 | namespace scene | 20 | namespace scene |
21 | { | 21 | { |
22 | class CQ3LevelMesh : public IQ3LevelMesh | 22 | class CQ3LevelMesh : public IQ3LevelMesh |
23 | { | 23 | { |
24 | public: | 24 | public: |
25 | 25 | ||
26 | //! constructor | 26 | //! constructor |
27 | CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr, | 27 | CQ3LevelMesh(io::IFileSystem* fs, scene::ISceneManager* smgr, |
28 | const quake3::Q3LevelLoadParameter &loadParam); | 28 | const quake3::Q3LevelLoadParameter &loadParam); |
29 | 29 | ||
30 | //! destructor | 30 | //! destructor |
31 | virtual ~CQ3LevelMesh(); | 31 | virtual ~CQ3LevelMesh(); |
32 | 32 | ||
33 | //! loads a level from a .bsp-File. Also tries to load all | 33 | //! loads a level from a .bsp-File. Also tries to load all |
34 | //! needed textures. Returns true if successful. | 34 | //! needed textures. Returns true if successful. |
35 | bool loadFile(io::IReadFile* file); | 35 | bool loadFile(io::IReadFile* file); |
36 | 36 | ||
37 | //! returns the amount of frames in milliseconds. If the amount | 37 | //! returns the amount of frames in milliseconds. If the amount |
38 | //! is 1, it is a static (=non animated) mesh. | 38 | //! is 1, it is a static (=non animated) mesh. |
39 | virtual u32 getFrameCount() const; | 39 | virtual u32 getFrameCount() const; |
40 | 40 | ||
41 | //! Gets the default animation speed of the animated mesh. | 41 | //! Gets the default animation speed of the animated mesh. |
42 | /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */ | 42 | /** \return Amount of frames per second. If the amount is 0, it is a static, non animated mesh. */ |
43 | virtual f32 getAnimationSpeed() const | 43 | virtual f32 getAnimationSpeed() const |
44 | { | 44 | { |
45 | return FramesPerSecond; | 45 | return FramesPerSecond; |
46 | } | 46 | } |
47 | 47 | ||
48 | //! Gets the frame count of the animated mesh. | 48 | //! Gets the frame count of the animated mesh. |
49 | /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated. | 49 | /** \param fps Frames per second to play the animation with. If the amount is 0, it is not animated. |
50 | The actual speed is set in the scene node the mesh is instantiated in.*/ | 50 | The actual speed is set in the scene node the mesh is instantiated in.*/ |
51 | virtual void setAnimationSpeed(f32 fps) | 51 | virtual void setAnimationSpeed(f32 fps) |
52 | { | 52 | { |
53 | FramesPerSecond=fps; | 53 | FramesPerSecond=fps; |
54 | } | 54 | } |
55 | 55 | ||
56 | //! returns the animated mesh based on a detail level. 0 is the | 56 | //! returns the animated mesh based on a detail level. 0 is the |
57 | //! lowest, 255 the highest detail. Note, that some Meshes will | 57 | //! lowest, 255 the highest detail. Note, that some Meshes will |
58 | //! ignore the detail level. | 58 | //! ignore the detail level. |
59 | virtual IMesh* getMesh(s32 frameInMs, s32 detailLevel=255, | 59 | virtual IMesh* getMesh(s32 frameInMs, s32 detailLevel=255, |
60 | s32 startFrameLoop=-1, s32 endFrameLoop=-1); | 60 | s32 startFrameLoop=-1, s32 endFrameLoop=-1); |
61 | 61 | ||
62 | //! Returns an axis aligned bounding box of the mesh. | 62 | //! Returns an axis aligned bounding box of the mesh. |
63 | //! \return A bounding box of this mesh is returned. | 63 | //! \return A bounding box of this mesh is returned. |
64 | virtual const core::aabbox3d<f32>& getBoundingBox() const; | 64 | virtual const core::aabbox3d<f32>& getBoundingBox() const; |
65 | 65 | ||
66 | virtual void setBoundingBox( const core::aabbox3df& box); | 66 | virtual void setBoundingBox( const core::aabbox3df& box); |
67 | 67 | ||
68 | //! Returns the type of the animated mesh. | 68 | //! Returns the type of the animated mesh. |
69 | virtual E_ANIMATED_MESH_TYPE getMeshType() const; | 69 | virtual E_ANIMATED_MESH_TYPE getMeshType() const; |
70 | 70 | ||
71 | //! loads the shader definition | 71 | //! loads the shader definition |
72 | virtual void getShader( io::IReadFile* file ); | 72 | virtual void getShader( io::IReadFile* file ); |
73 | 73 | ||
74 | //! loads the shader definition | 74 | //! loads the shader definition |
75 | virtual const quake3::IShader * getShader( const c8 * filename, bool fileNameIsValid=true ); | 75 | virtual const quake3::IShader * getShader( const c8 * filename, bool fileNameIsValid=true ); |
76 | 76 | ||
77 | //! returns a already loaded Shader | 77 | //! returns a already loaded Shader |
78 | virtual const quake3::IShader * getShader( u32 index ) const; | 78 | virtual const quake3::IShader * getShader( u32 index ) const; |
79 | 79 | ||
80 | 80 | ||
81 | //! loads a configuration file | 81 | //! loads a configuration file |
82 | virtual void getConfiguration( io::IReadFile* file ); | 82 | virtual void getConfiguration( io::IReadFile* file ); |
83 | //! get's an interface to the entities | 83 | //! get's an interface to the entities |
84 | virtual quake3::tQ3EntityList & getEntityList(); | 84 | virtual quake3::tQ3EntityList & getEntityList(); |
85 | 85 | ||
86 | //! returns the requested brush entity | 86 | //! returns the requested brush entity |
87 | virtual IMesh* getBrushEntityMesh(s32 num) const; | 87 | virtual IMesh* getBrushEntityMesh(s32 num) const; |
88 | 88 | ||
89 | //! returns the requested brush entity | 89 | //! returns the requested brush entity |
90 | virtual IMesh* getBrushEntityMesh(quake3::IEntity &ent) const; | 90 | virtual IMesh* getBrushEntityMesh(quake3::IEntity &ent) const; |
91 | 91 | ||
92 | //Link to held meshes? ... | 92 | //Link to held meshes? ... |
93 | 93 | ||
94 | 94 | ||
95 | //! returns amount of mesh buffers. | 95 | //! returns amount of mesh buffers. |
96 | virtual u32 getMeshBufferCount() const | 96 | virtual u32 getMeshBufferCount() const |
97 | { | 97 | { |
98 | return 0; | 98 | return 0; |
99 | } | 99 | } |
100 | 100 | ||
101 | //! returns pointer to a mesh buffer | 101 | //! returns pointer to a mesh buffer |
102 | virtual IMeshBuffer* getMeshBuffer(u32 nr) const | 102 | virtual IMeshBuffer* getMeshBuffer(u32 nr) const |
103 | { | 103 | { |
104 | return 0; | 104 | return 0; |
105 | } | 105 | } |
106 | 106 | ||
107 | //! Returns pointer to a mesh buffer which fits a material | 107 | //! Returns pointer to a mesh buffer which fits a material |
108 | /** \param material: material to search for | 108 | /** \param material: material to search for |
109 | \return Pointer to the mesh buffer or 0 if there is no such mesh buffer. */ | 109 | \return Pointer to the mesh buffer or 0 if there is no such mesh buffer. */ |
110 | virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const | 110 | virtual IMeshBuffer* getMeshBuffer( const video::SMaterial &material) const |
111 | { | 111 | { |
112 | return 0; | 112 | return 0; |
113 | } | 113 | } |
114 | 114 | ||
115 | virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) | 115 | virtual void setMaterialFlag(video::E_MATERIAL_FLAG flag, bool newvalue) |
116 | { | 116 | { |
117 | return; | 117 | return; |
118 | } | 118 | } |
119 | 119 | ||
120 | //! set the hardware mapping hint, for driver | 120 | //! set the hardware mapping hint, for driver |
121 | virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) | 121 | virtual void setHardwareMappingHint(E_HARDWARE_MAPPING newMappingHint, E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) |
122 | { | 122 | { |
123 | return; | 123 | return; |
124 | } | 124 | } |
125 | 125 | ||
126 | //! flags the meshbuffer as changed, reloads hardware buffers | 126 | //! flags the meshbuffer as changed, reloads hardware buffers |
127 | virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) | 127 | virtual void setDirty(E_BUFFER_TYPE buffer=EBT_VERTEX_AND_INDEX) |
128 | { | 128 | { |
129 | return; | 129 | return; |
130 | } | 130 | } |
131 | 131 | ||
132 | private: | 132 | private: |
133 | 133 | ||
134 | 134 | ||
135 | void constructMesh(); | 135 | void constructMesh(); |
136 | void solveTJunction(); | 136 | void solveTJunction(); |
137 | void loadTextures(); | 137 | void loadTextures(); |
138 | scene::SMesh** buildMesh(s32 num); | 138 | scene::SMesh** buildMesh(s32 num); |
139 | 139 | ||
140 | struct STexShader | 140 | struct STexShader |
141 | { | 141 | { |
142 | video::ITexture* Texture; | 142 | video::ITexture* Texture; |
143 | s32 ShaderID; | 143 | s32 ShaderID; |
144 | }; | 144 | }; |
145 | 145 | ||
146 | core::array< STexShader > Tex; | 146 | core::array< STexShader > Tex; |
147 | core::array<video::ITexture*> Lightmap; | 147 | core::array<video::ITexture*> Lightmap; |
148 | 148 | ||
149 | enum eLumps | 149 | enum eLumps |
150 | { | 150 | { |
151 | kEntities = 0, // Stores player/object positions, etc... | 151 | kEntities = 0, // Stores player/object positions, etc... |
152 | kShaders = 1, // Stores texture information | 152 | kShaders = 1, // Stores texture information |
153 | kPlanes = 2, // Stores the splitting planes | 153 | kPlanes = 2, // Stores the splitting planes |
154 | kNodes = 3, // Stores the BSP nodes | 154 | kNodes = 3, // Stores the BSP nodes |
155 | kLeafs = 4, // Stores the leafs of the nodes | 155 | kLeafs = 4, // Stores the leafs of the nodes |
156 | kLeafFaces = 5, // Stores the leaf's indices into the faces | 156 | kLeafFaces = 5, // Stores the leaf's indices into the faces |
157 | kLeafBrushes = 6, // Stores the leaf's indices into the brushes | 157 | kLeafBrushes = 6, // Stores the leaf's indices into the brushes |
158 | kModels = 7, // Stores the info of world models | 158 | kModels = 7, // Stores the info of world models |
159 | kBrushes = 8, // Stores the brushes info (for collision) | 159 | kBrushes = 8, // Stores the brushes info (for collision) |
160 | kBrushSides = 9, // Stores the brush surfaces info | 160 | kBrushSides = 9, // Stores the brush surfaces info |
161 | kVertices = 10, // Stores the level vertices | 161 | kVertices = 10, // Stores the level vertices |
162 | kMeshVerts = 11, // Stores the model vertices offsets | 162 | kMeshVerts = 11, // Stores the model vertices offsets |
163 | kFogs = 12, // Stores the shader files (blending, anims..) | 163 | kFogs = 12, // Stores the shader files (blending, anims..) |
164 | kFaces = 13, // Stores the faces for the level | 164 | kFaces = 13, // Stores the faces for the level |
165 | kLightmaps = 14, // Stores the lightmaps for the level | 165 | kLightmaps = 14, // Stores the lightmaps for the level |
166 | kLightGrid = 15, // Stores extra world lighting information | 166 | kLightGrid = 15, // Stores extra world lighting information |
167 | kVisData = 16, // Stores PVS and cluster info (visibility) | 167 | kVisData = 16, // Stores PVS and cluster info (visibility) |
168 | kLightArray = 17, // RBSP | 168 | kLightArray = 17, // RBSP |
169 | kMaxLumps // A constant to store the number of lumps | 169 | kMaxLumps // A constant to store the number of lumps |
170 | }; | 170 | }; |
171 | 171 | ||
172 | enum eBspSurfaceType | 172 | enum eBspSurfaceType |
173 | { | 173 | { |
174 | BSP_MST_BAD, | 174 | BSP_MST_BAD, |
175 | BSP_MST_PLANAR, | 175 | BSP_MST_PLANAR, |
176 | BSP_MST_PATCH, | 176 | BSP_MST_PATCH, |
177 | BSP_MST_TRIANGLE_SOUP, | 177 | BSP_MST_TRIANGLE_SOUP, |
178 | BSP_MST_FLARE, | 178 | BSP_MST_FLARE, |
179 | BSP_MST_FOLIAGE | 179 | BSP_MST_FOLIAGE |
180 | 180 | ||
181 | }; | 181 | }; |
182 | 182 | ||
183 | struct tBSPHeader | 183 | struct tBSPHeader |
184 | { | 184 | { |
185 | s32 strID; // This should always be 'IBSP' | 185 | s32 strID; // This should always be 'IBSP' |
186 | s32 version; // This should be 0x2e for Quake 3 files | 186 | s32 version; // This should be 0x2e for Quake 3 files |
187 | }; | 187 | }; |
188 | tBSPHeader header; | 188 | tBSPHeader header; |
189 | 189 | ||
190 | struct tBSPLump | 190 | struct tBSPLump |
191 | { | 191 | { |
192 | s32 offset; | 192 | s32 offset; |
193 | s32 length; | 193 | s32 length; |
194 | }; | 194 | }; |
195 | 195 | ||
196 | 196 | ||
197 | struct tBSPVertex | 197 | struct tBSPVertex |
198 | { | 198 | { |
199 | f32 vPosition[3]; // (x, y, z) position. | 199 | f32 vPosition[3]; // (x, y, z) position. |
200 | f32 vTextureCoord[2]; // (u, v) texture coordinate | 200 | f32 vTextureCoord[2]; // (u, v) texture coordinate |
201 | f32 vLightmapCoord[2]; // (u, v) lightmap coordinate | 201 | f32 vLightmapCoord[2]; // (u, v) lightmap coordinate |
202 | f32 vNormal[3]; // (x, y, z) normal vector | 202 | f32 vNormal[3]; // (x, y, z) normal vector |
203 | u8 color[4]; // RGBA color for the vertex | 203 | u8 color[4]; // RGBA color for the vertex |
204 | }; | 204 | }; |
205 | 205 | ||
206 | struct tBSPFace | 206 | struct tBSPFace |
207 | { | 207 | { |
208 | s32 textureID; // The index into the texture array | 208 | s32 textureID; // The index into the texture array |
209 | s32 fogNum; // The index for the effects (or -1 = n/a) | 209 | s32 fogNum; // The index for the effects (or -1 = n/a) |
210 | s32 type; // 1=polygon, 2=patch, 3=mesh, 4=billboard | 210 | s32 type; // 1=polygon, 2=patch, 3=mesh, 4=billboard |
211 | s32 vertexIndex; // The index into this face's first vertex | 211 | s32 vertexIndex; // The index into this face's first vertex |
212 | s32 numOfVerts; // The number of vertices for this face | 212 | s32 numOfVerts; // The number of vertices for this face |
213 | s32 meshVertIndex; // The index into the first meshvertex | 213 | s32 meshVertIndex; // The index into the first meshvertex |
214 | s32 numMeshVerts; // The number of mesh vertices | 214 | s32 numMeshVerts; // The number of mesh vertices |
215 | s32 lightmapID; // The texture index for the lightmap | 215 | s32 lightmapID; // The texture index for the lightmap |
216 | s32 lMapCorner[2]; // The face's lightmap corner in the image | 216 | s32 lMapCorner[2]; // The face's lightmap corner in the image |
217 | s32 lMapSize[2]; // The size of the lightmap section | 217 | s32 lMapSize[2]; // The size of the lightmap section |
218 | f32 lMapPos[3]; // The 3D origin of lightmap. | 218 | f32 lMapPos[3]; // The 3D origin of lightmap. |
219 | f32 lMapBitsets[2][3]; // The 3D space for s and t unit vectors. | 219 | f32 lMapBitsets[2][3]; // The 3D space for s and t unit vectors. |
220 | f32 vNormal[3]; // The face normal. | 220 | f32 vNormal[3]; // The face normal. |
221 | s32 size[2]; // The bezier patch dimensions. | 221 | s32 size[2]; // The bezier patch dimensions. |
222 | }; | 222 | }; |
223 | 223 | ||
224 | struct tBSPTexture | 224 | struct tBSPTexture |
225 | { | 225 | { |
226 | c8 strName[64]; // The name of the texture w/o the extension | 226 | c8 strName[64]; // The name of the texture w/o the extension |
227 | u32 flags; // The surface flags (unknown) | 227 | u32 flags; // The surface flags (unknown) |
228 | u32 contents; // The content flags (unknown) | 228 | u32 contents; // The content flags (unknown) |
229 | }; | 229 | }; |
230 | 230 | ||
231 | struct tBSPLightmap | 231 | struct tBSPLightmap |
232 | { | 232 | { |
233 | u8 imageBits[128][128][3]; // The RGB data in a 128x128 image | 233 | u8 imageBits[128][128][3]; // The RGB data in a 128x128 image |
234 | }; | 234 | }; |
235 | 235 | ||
236 | struct tBSPNode | 236 | struct tBSPNode |
237 | { | 237 | { |
238 | s32 plane; // The index into the planes array | 238 | s32 plane; // The index into the planes array |
239 | s32 front; // The child index for the front node | 239 | s32 front; // The child index for the front node |
240 | s32 back; // The child index for the back node | 240 | s32 back; // The child index for the back node |
241 | s32 mins[3]; // The bounding box min position. | 241 | s32 mins[3]; // The bounding box min position. |
242 | s32 maxs[3]; // The bounding box max position. | 242 | s32 maxs[3]; // The bounding box max position. |
243 | }; | 243 | }; |
244 | 244 | ||
245 | struct tBSPLeaf | 245 | struct tBSPLeaf |
246 | { | 246 | { |
247 | s32 cluster; // The visibility cluster | 247 | s32 cluster; // The visibility cluster |
248 | s32 area; // The area portal | 248 | s32 area; // The area portal |
249 | s32 mins[3]; // The bounding box min position | 249 | s32 mins[3]; // The bounding box min position |
250 | s32 maxs[3]; // The bounding box max position | 250 | s32 maxs[3]; // The bounding box max position |
251 | s32 leafface; // The first index into the face array | 251 | s32 leafface; // The first index into the face array |
252 | s32 numOfLeafFaces; // The number of faces for this leaf | 252 | s32 numOfLeafFaces; // The number of faces for this leaf |
253 | s32 leafBrush; // The first index for into the brushes | 253 | s32 leafBrush; // The first index for into the brushes |
254 | s32 numOfLeafBrushes; // The number of brushes for this leaf | 254 | s32 numOfLeafBrushes; // The number of brushes for this leaf |
255 | }; | 255 | }; |
256 | 256 | ||
257 | struct tBSPPlane | 257 | struct tBSPPlane |
258 | { | 258 | { |
259 | f32 vNormal[3]; // Plane normal. | 259 | f32 vNormal[3]; // Plane normal. |
260 | f32 d; // The plane distance from origin | 260 | f32 d; // The plane distance from origin |
261 | }; | 261 | }; |
262 | 262 | ||
263 | struct tBSPVisData | 263 | struct tBSPVisData |
264 | { | 264 | { |
265 | s32 numOfClusters; // The number of clusters | 265 | s32 numOfClusters; // The number of clusters |
266 | s32 bytesPerCluster; // Bytes (8 bits) in the cluster's bitset | 266 | s32 bytesPerCluster; // Bytes (8 bits) in the cluster's bitset |
267 | c8 *pBitsets; // Array of bytes holding the cluster vis. | 267 | c8 *pBitsets; // Array of bytes holding the cluster vis. |
268 | }; | 268 | }; |
269 | 269 | ||
270 | struct tBSPBrush | 270 | struct tBSPBrush |
271 | { | 271 | { |
272 | s32 brushSide; // The starting brush side for the brush | 272 | s32 brushSide; // The starting brush side for the brush |
273 | s32 numOfBrushSides; // Number of brush sides for the brush | 273 | s32 numOfBrushSides; // Number of brush sides for the brush |
274 | s32 textureID; // The texture index for the brush | 274 | s32 textureID; // The texture index for the brush |
275 | }; | 275 | }; |
276 | 276 | ||
277 | struct tBSPBrushSide | 277 | struct tBSPBrushSide |
278 | { | 278 | { |
279 | s32 plane; // The plane index | 279 | s32 plane; // The plane index |
280 | s32 textureID; // The texture index | 280 | s32 textureID; // The texture index |
281 | }; | 281 | }; |
282 | 282 | ||
283 | struct tBSPModel | 283 | struct tBSPModel |
284 | { | 284 | { |
285 | f32 min[3]; // The min position for the bounding box | 285 | f32 min[3]; // The min position for the bounding box |
286 | f32 max[3]; // The max position for the bounding box. | 286 | f32 max[3]; // The max position for the bounding box. |
287 | s32 faceIndex; // The first face index in the model | 287 | s32 faceIndex; // The first face index in the model |
288 | s32 numOfFaces; // The number of faces in the model | 288 | s32 numOfFaces; // The number of faces in the model |
289 | s32 brushIndex; // The first brush index in the model | 289 | s32 brushIndex; // The first brush index in the model |
290 | s32 numOfBrushes; // The number brushes for the model | 290 | s32 numOfBrushes; // The number brushes for the model |
291 | }; | 291 | }; |
292 | 292 | ||
293 | struct tBSPFog | 293 | struct tBSPFog |
294 | { | 294 | { |
295 | c8 shader[64]; // The name of the shader file | 295 | c8 shader[64]; // The name of the shader file |
296 | s32 brushIndex; // The brush index for this shader | 296 | s32 brushIndex; // The brush index for this shader |
297 | s32 visibleSide; // the brush side that ray tests need to clip against (-1 == none | 297 | s32 visibleSide; // the brush side that ray tests need to clip against (-1 == none |
298 | }; | 298 | }; |
299 | core::array < STexShader > FogMap; | 299 | core::array < STexShader > FogMap; |
300 | 300 | ||
301 | struct tBSPLights | 301 | struct tBSPLights |
302 | { | 302 | { |
303 | u8 ambient[3]; // This is the ambient color in RGB | 303 | u8 ambient[3]; // This is the ambient color in RGB |
304 | u8 directional[3]; // This is the directional color in RGB | 304 | u8 directional[3]; // This is the directional color in RGB |
305 | u8 direction[2]; // The direction of the light: [phi,theta] | 305 | u8 direction[2]; // The direction of the light: [phi,theta] |
306 | }; | 306 | }; |
307 | 307 | ||
308 | void loadTextures (tBSPLump* l, io::IReadFile* file); // Load the textures | 308 | void loadTextures (tBSPLump* l, io::IReadFile* file); // Load the textures |
309 | void loadLightmaps (tBSPLump* l, io::IReadFile* file); // Load the lightmaps | 309 | void loadLightmaps (tBSPLump* l, io::IReadFile* file); // Load the lightmaps |
310 | void loadVerts (tBSPLump* l, io::IReadFile* file); // Load the vertices | 310 | void loadVerts (tBSPLump* l, io::IReadFile* file); // Load the vertices |
311 | void loadFaces (tBSPLump* l, io::IReadFile* file); // Load the faces | 311 | void loadFaces (tBSPLump* l, io::IReadFile* file); // Load the faces |
312 | void loadPlanes (tBSPLump* l, io::IReadFile* file); // Load the Planes of the BSP | 312 | void loadPlanes (tBSPLump* l, io::IReadFile* file); // Load the Planes of the BSP |
313 | void loadNodes (tBSPLump* l, io::IReadFile* file); // load the Nodes of the BSP | 313 | void loadNodes (tBSPLump* l, io::IReadFile* file); // load the Nodes of the BSP |
314 | void loadLeafs (tBSPLump* l, io::IReadFile* file); // load the Leafs of the BSP | 314 | void loadLeafs (tBSPLump* l, io::IReadFile* file); // load the Leafs of the BSP |
315 | void loadLeafFaces (tBSPLump* l, io::IReadFile* file); // load the Faces of the Leafs of the BSP | 315 | void loadLeafFaces (tBSPLump* l, io::IReadFile* file); // load the Faces of the Leafs of the BSP |
316 | void loadVisData (tBSPLump* l, io::IReadFile* file); // load the visibility data of the clusters | 316 | void loadVisData (tBSPLump* l, io::IReadFile* file); // load the visibility data of the clusters |
317 | void loadEntities (tBSPLump* l, io::IReadFile* file); // load the entities | 317 | void loadEntities (tBSPLump* l, io::IReadFile* file); // load the entities |
318 | void loadModels (tBSPLump* l, io::IReadFile* file); // load the models | 318 | void loadModels (tBSPLump* l, io::IReadFile* file); // load the models |
319 | void loadMeshVerts (tBSPLump* l, io::IReadFile* file); // load the mesh vertices | 319 | void loadMeshVerts (tBSPLump* l, io::IReadFile* file); // load the mesh vertices |
320 | void loadBrushes (tBSPLump* l, io::IReadFile* file); // load the brushes of the BSP | 320 | void loadBrushes (tBSPLump* l, io::IReadFile* file); // load the brushes of the BSP |
321 | void loadBrushSides (tBSPLump* l, io::IReadFile* file); // load the brushsides of the BSP | 321 | void loadBrushSides (tBSPLump* l, io::IReadFile* file); // load the brushsides of the BSP |
322 | void loadLeafBrushes(tBSPLump* l, io::IReadFile* file); // load the brushes of the leaf | 322 | void loadLeafBrushes(tBSPLump* l, io::IReadFile* file); // load the brushes of the leaf |
323 | void loadFogs (tBSPLump* l, io::IReadFile* file); // load the shaders | 323 | void loadFogs (tBSPLump* l, io::IReadFile* file); // load the shaders |
324 | 324 | ||
325 | //bi-quadratic bezier patches | 325 | //bi-quadratic bezier patches |
326 | void createCurvedSurface_bezier(SMeshBufferLightMap* meshBuffer, | 326 | void createCurvedSurface_bezier(SMeshBufferLightMap* meshBuffer, |
327 | s32 faceIndex, s32 patchTesselation, s32 storevertexcolor); | 327 | s32 faceIndex, s32 patchTesselation, s32 storevertexcolor); |
328 | 328 | ||
329 | void createCurvedSurface_nosubdivision(SMeshBufferLightMap* meshBuffer, | 329 | void createCurvedSurface_nosubdivision(SMeshBufferLightMap* meshBuffer, |
330 | s32 faceIndex, s32 patchTesselation, s32 storevertexcolor); | 330 | s32 faceIndex, s32 patchTesselation, s32 storevertexcolor); |
331 | 331 | ||
332 | struct S3DVertex2TCoords_64 | 332 | struct S3DVertex2TCoords_64 |
333 | { | 333 | { |
334 | core::vector3d<f64> Pos; | 334 | core::vector3d<f64> Pos; |
335 | core::vector3d<f64> Normal; | 335 | core::vector3d<f64> Normal; |
336 | video::SColorf Color; | 336 | video::SColorf Color; |
337 | core::vector2d<f64> TCoords; | 337 | core::vector2d<f64> TCoords; |
338 | core::vector2d<f64> TCoords2; | 338 | core::vector2d<f64> TCoords2; |
339 | 339 | ||
340 | void copy( video::S3DVertex2TCoords &dest ) const; | 340 | void copy( video::S3DVertex2TCoords &dest ) const; |
341 | 341 | ||
342 | S3DVertex2TCoords_64() {} | 342 | S3DVertex2TCoords_64() {} |
343 | S3DVertex2TCoords_64(const core::vector3d<f64>& pos, const core::vector3d<f64>& normal, const video::SColorf& color, | 343 | S3DVertex2TCoords_64(const core::vector3d<f64>& pos, const core::vector3d<f64>& normal, const video::SColorf& color, |
344 | const core::vector2d<f64>& tcoords, const core::vector2d<f64>& tcoords2) | 344 | const core::vector2d<f64>& tcoords, const core::vector2d<f64>& tcoords2) |
345 | : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} | 345 | : Pos(pos), Normal(normal), Color(color), TCoords(tcoords), TCoords2(tcoords2) {} |
346 | 346 | ||
347 | S3DVertex2TCoords_64 getInterpolated_quadratic(const S3DVertex2TCoords_64& v2, | 347 | S3DVertex2TCoords_64 getInterpolated_quadratic(const S3DVertex2TCoords_64& v2, |
348 | const S3DVertex2TCoords_64& v3, const f64 d) const | 348 | const S3DVertex2TCoords_64& v3, const f64 d) const |
349 | { | 349 | { |
350 | return S3DVertex2TCoords_64 ( | 350 | return S3DVertex2TCoords_64 ( |
351 | Pos.getInterpolated_quadratic ( v2.Pos, v3.Pos, d ), | 351 | Pos.getInterpolated_quadratic ( v2.Pos, v3.Pos, d ), |
352 | Normal.getInterpolated_quadratic ( v2.Normal, v3.Normal, d ), | 352 | Normal.getInterpolated_quadratic ( v2.Normal, v3.Normal, d ), |
353 | Color.getInterpolated_quadratic ( v2.Color, v3.Color, (f32) d ), | 353 | Color.getInterpolated_quadratic ( v2.Color, v3.Color, (f32) d ), |
354 | TCoords.getInterpolated_quadratic ( v2.TCoords, v3.TCoords, d ), | 354 | TCoords.getInterpolated_quadratic ( v2.TCoords, v3.TCoords, d ), |
355 | TCoords2.getInterpolated_quadratic ( v2.TCoords2, v3.TCoords2, d )); | 355 | TCoords2.getInterpolated_quadratic ( v2.TCoords2, v3.TCoords2, d )); |
356 | } | 356 | } |
357 | }; | 357 | }; |
358 | 358 | ||
359 | inline void copy( video::S3DVertex2TCoords * dest, const tBSPVertex * source, | 359 | inline void copy( video::S3DVertex2TCoords * dest, const tBSPVertex * source, |
360 | s32 vertexcolor ) const; | 360 | s32 vertexcolor ) const; |
361 | void copy( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const; | 361 | void copy( S3DVertex2TCoords_64 * dest, const tBSPVertex * source, s32 vertexcolor ) const; |
362 | 362 | ||
363 | 363 | ||
364 | struct SBezier | 364 | struct SBezier |
365 | { | 365 | { |
366 | SMeshBufferLightMap *Patch; | 366 | SMeshBufferLightMap *Patch; |
367 | S3DVertex2TCoords_64 control[9]; | 367 | S3DVertex2TCoords_64 control[9]; |
368 | 368 | ||
369 | void tesselate(s32 level); | 369 | void tesselate(s32 level); |
370 | 370 | ||
371 | private: | 371 | private: |
372 | s32 Level; | 372 | s32 Level; |
373 | 373 | ||
374 | core::array<S3DVertex2TCoords_64> column[3]; | 374 | core::array<S3DVertex2TCoords_64> column[3]; |
375 | 375 | ||
376 | }; | 376 | }; |
377 | SBezier Bezier; | 377 | SBezier Bezier; |
378 | 378 | ||
379 | quake3::Q3LevelLoadParameter LoadParam; | 379 | quake3::Q3LevelLoadParameter LoadParam; |
380 | 380 | ||
381 | tBSPLump Lumps[kMaxLumps]; | 381 | tBSPLump Lumps[kMaxLumps]; |
382 | 382 | ||
383 | tBSPTexture* Textures; | 383 | tBSPTexture* Textures; |
384 | s32 NumTextures; | 384 | s32 NumTextures; |
385 | 385 | ||
386 | tBSPLightmap* LightMaps; | 386 | tBSPLightmap* LightMaps; |
387 | s32 NumLightMaps; | 387 | s32 NumLightMaps; |
388 | 388 | ||
389 | tBSPVertex* Vertices; | 389 | tBSPVertex* Vertices; |
390 | s32 NumVertices; | 390 | s32 NumVertices; |
391 | 391 | ||
392 | tBSPFace* Faces; | 392 | tBSPFace* Faces; |
393 | s32 NumFaces; | 393 | s32 NumFaces; |
394 | 394 | ||
395 | tBSPModel* Models; | 395 | tBSPModel* Models; |
396 | s32 NumModels; | 396 | s32 NumModels; |
397 | 397 | ||
398 | tBSPPlane* Planes; | 398 | tBSPPlane* Planes; |
399 | s32 NumPlanes; | 399 | s32 NumPlanes; |
400 | 400 | ||
401 | tBSPNode* Nodes; | 401 | tBSPNode* Nodes; |
402 | s32 NumNodes; | 402 | s32 NumNodes; |
403 | 403 | ||
404 | tBSPLeaf* Leafs; | 404 | tBSPLeaf* Leafs; |
405 | s32 NumLeafs; | 405 | s32 NumLeafs; |
406 | 406 | ||
407 | s32 *LeafFaces; | 407 | s32 *LeafFaces; |
408 | s32 NumLeafFaces; | 408 | s32 NumLeafFaces; |
409 | 409 | ||
410 | s32 *MeshVerts; // The vertex offsets for a mesh | 410 | s32 *MeshVerts; // The vertex offsets for a mesh |
411 | s32 NumMeshVerts; | 411 | s32 NumMeshVerts; |
412 | 412 | ||
413 | tBSPBrush* Brushes; | 413 | tBSPBrush* Brushes; |
414 | s32 NumBrushes; | 414 | s32 NumBrushes; |
415 | 415 | ||
416 | scene::SMesh** BrushEntities; | 416 | scene::SMesh** BrushEntities; |
417 | 417 | ||
418 | scene::SMesh* Mesh[quake3::E_Q3_MESH_SIZE]; | 418 | scene::SMesh* Mesh[quake3::E_Q3_MESH_SIZE]; |
419 | video::IVideoDriver* Driver; | 419 | video::IVideoDriver* Driver; |
420 | core::stringc LevelName; | 420 | core::stringc LevelName; |
421 | io::IFileSystem* FileSystem; // needs because there are no file extenstions stored in .bsp files. | 421 | io::IFileSystem* FileSystem; // needs because there are no file extenstions stored in .bsp files. |
422 | 422 | ||
423 | // Additional content | 423 | // Additional content |
424 | scene::ISceneManager* SceneManager; | 424 | scene::ISceneManager* SceneManager; |
425 | enum eToken | 425 | enum eToken |
426 | { | 426 | { |
427 | Q3_TOKEN_UNRESOLVED = 0, | 427 | Q3_TOKEN_UNRESOLVED = 0, |
428 | Q3_TOKEN_EOF = 1, | 428 | Q3_TOKEN_EOF = 1, |
429 | Q3_TOKEN_START_LIST, | 429 | Q3_TOKEN_START_LIST, |
430 | Q3_TOKEN_END_LIST, | 430 | Q3_TOKEN_END_LIST, |
431 | Q3_TOKEN_ENTITY, | 431 | Q3_TOKEN_ENTITY, |
432 | Q3_TOKEN_TOKEN, | 432 | Q3_TOKEN_TOKEN, |
433 | Q3_TOKEN_EOL, | 433 | Q3_TOKEN_EOL, |
434 | Q3_TOKEN_COMMENT, | 434 | Q3_TOKEN_COMMENT, |
435 | Q3_TOKEN_MATH_DIVIDE, | 435 | Q3_TOKEN_MATH_DIVIDE, |
436 | Q3_TOKEN_MATH_ADD, | 436 | Q3_TOKEN_MATH_ADD, |
437 | Q3_TOKEN_MATH_MULTIPY | 437 | Q3_TOKEN_MATH_MULTIPY |
438 | }; | 438 | }; |
439 | struct SQ3Parser | 439 | struct SQ3Parser |
440 | { | 440 | { |
441 | const c8 *source; | 441 | const c8 *source; |
442 | u32 sourcesize; | 442 | u32 sourcesize; |
443 | u32 index; | 443 | u32 index; |
444 | core::stringc token; | 444 | core::stringc token; |
445 | eToken tokenresult; | 445 | eToken tokenresult; |
446 | }; | 446 | }; |
447 | SQ3Parser Parser; | 447 | SQ3Parser Parser; |
448 | 448 | ||
449 | 449 | ||
450 | typedef void( CQ3LevelMesh::*tParserCallback ) ( quake3::SVarGroupList *& groupList, eToken token ); | 450 | typedef void( CQ3LevelMesh::*tParserCallback ) ( quake3::SVarGroupList *& groupList, eToken token ); |
451 | void parser_parse( const void * data, u32 size, tParserCallback callback ); | 451 | void parser_parse( const void * data, u32 size, tParserCallback callback ); |
452 | void parser_nextToken(); | 452 | void parser_nextToken(); |
453 | 453 | ||
454 | void dumpVarGroup( const quake3::SVarGroup * group, s32 stack ) const; | 454 | void dumpVarGroup( const quake3::SVarGroup * group, s32 stack ) const; |
455 | 455 | ||
456 | void scriptcallback_entity( quake3::SVarGroupList *& grouplist, eToken token ); | 456 | void scriptcallback_entity( quake3::SVarGroupList *& grouplist, eToken token ); |
457 | void scriptcallback_shader( quake3::SVarGroupList *& grouplist, eToken token ); | 457 | void scriptcallback_shader( quake3::SVarGroupList *& grouplist, eToken token ); |
458 | void scriptcallback_config( quake3::SVarGroupList *& grouplist, eToken token ); | 458 | void scriptcallback_config( quake3::SVarGroupList *& grouplist, eToken token ); |
459 | 459 | ||
460 | core::array < quake3::IShader > Shader; | 460 | core::array < quake3::IShader > Shader; |
461 | core::array < quake3::IShader > Entity; //quake3::tQ3EntityList Entity; | 461 | core::array < quake3::IShader > Entity; //quake3::tQ3EntityList Entity; |
462 | 462 | ||
463 | 463 | ||
464 | quake3::tStringList ShaderFile; | 464 | quake3::tStringList ShaderFile; |
465 | void InitShader(); | 465 | void InitShader(); |
466 | void ReleaseShader(); | 466 | void ReleaseShader(); |
467 | void ReleaseEntity(); | 467 | void ReleaseEntity(); |
468 | 468 | ||
469 | 469 | ||
470 | s32 setShaderMaterial( video::SMaterial & material, const tBSPFace * face ) const; | 470 | s32 setShaderMaterial( video::SMaterial & material, const tBSPFace * face ) const; |
471 | s32 setShaderFogMaterial( video::SMaterial &material, const tBSPFace * face ) const; | 471 | s32 setShaderFogMaterial( video::SMaterial &material, const tBSPFace * face ) const; |
472 | 472 | ||
473 | struct SToBuffer | 473 | struct SToBuffer |
474 | { | 474 | { |
475 | s32 takeVertexColor; | 475 | s32 takeVertexColor; |
476 | u32 index; | 476 | u32 index; |
477 | }; | 477 | }; |
478 | 478 | ||
479 | void cleanMeshes(); | 479 | void cleanMeshes(); |
480 | void cleanMesh(SMesh *m, const bool texture0important = false); | 480 | void cleanMesh(SMesh *m, const bool texture0important = false); |
481 | void cleanLoader (); | 481 | void cleanLoader (); |
482 | void calcBoundingBoxes(); | 482 | void calcBoundingBoxes(); |
483 | c8 buf[128]; | 483 | c8 buf[128]; |
484 | f32 FramesPerSecond; | 484 | f32 FramesPerSecond; |
485 | }; | 485 | }; |
486 | 486 | ||
487 | } // end namespace scene | 487 | } // end namespace scene |
488 | } // end namespace irr | 488 | } // end namespace irr |
489 | 489 | ||
490 | #endif | 490 | #endif |
491 | 491 | ||