You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

216 regels
5.7 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2008, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. #ifndef ASSIMP_Q3BSPFILEDATA_H_INC
  34. #define ASSIMP_Q3BSPFILEDATA_H_INC
  35. #include <vector>
  36. namespace Assimp {
  37. namespace Q3BSP {
  38. static const unsigned int CE_BSP_LIGHTMAPWIDTH = 128;
  39. static const unsigned int CE_BSP_LIGHTMAPHEIGHT = 128;
  40. static const unsigned int CE_BSP_LIGHTMAPSIZE = 128*128*3; ///< = 128( width ) * 128 ( height ) * 3 ( channels / RGB ).
  41. static const int VERION_Q3LEVEL = 46; ///< Supported version.
  42. /// Geometric type enumeration
  43. enum Q3BSPGeoType {
  44. Polygon = 1,
  45. Patch,
  46. TriangleMesh,
  47. Billboard
  48. };
  49. /// Integer vector.
  50. struct ceVec3i {
  51. int x, y, z;
  52. ceVec3i(): x( 0 ), y( 0 ), z( 0 ) { /* empty */ }
  53. ceVec3i( int iX, int iY=0, int iZ=0) : x( iX ), y( iY ), z( iZ ) { /* empty */ }
  54. };
  55. /// the file header
  56. struct sQ3BSPHeader {
  57. char strID[ 4 ]; ///< Should be "IBSP"
  58. int iVersion; ///< 46 for standard levels
  59. };
  60. /// Describes an entry.
  61. struct sQ3BSPLump
  62. {
  63. int iOffset; ///< Offset from start pointer of file
  64. int iSize; ///< Size of part
  65. };
  66. struct vec2f
  67. {
  68. float x,y;
  69. };
  70. struct vec3f
  71. {
  72. float x, y, z;
  73. };
  74. /// Vertex of a Q3 level
  75. struct sQ3BSPVertex
  76. {
  77. vec3f vPosition; ///< Position of vertex
  78. vec2f vTexCoord; ///< (u,v) Texturecoordinate of detailtexture
  79. vec2f vLightmap; ///< (u,v) Texturecoordinate of lightmap
  80. vec3f vNormal; ///< vertex normale
  81. unsigned char bColor[ 4 ]; ///< Color in RGBA
  82. };
  83. /// A face in bsp format info
  84. struct sQ3BSPFace
  85. {
  86. int iTextureID; ///< Index in texture array
  87. int iEffect; ///< Index in effect array (-1 = no effect)
  88. int iType; ///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
  89. int iVertexIndex; ///< Start index of polygon
  90. int iNumOfVerts; ///< Number of vertices
  91. int iFaceVertexIndex; ///< Index of first mesh vertex
  92. int iNumOfFaceVerts; ///< number of mesh vertices
  93. int iLightmapID; ///< Index to the light-map array
  94. int iLMapCorner[ 2 ]; ///< edge of the light-map in texture
  95. int iLMapSize[ 2 ]; ///< Size of the light-map stored on the texture
  96. vec3f vLMapPos; ///< 3D origin of the light-map
  97. vec3f vLMapVecs[ 2 ]; ///< 3D-s-t-vectors
  98. vec3f vNormal; ///< Polygon normals
  99. int patchWidth, patchHeight; ///< bezier patch
  100. };
  101. /// A quake3 texture name.
  102. struct sQ3BSPTexture {
  103. char strName[ 64 ]; ///< Name of the texture without extension
  104. int iFlags; ///< Not used
  105. int iContents; ///< Not used
  106. };
  107. /// A light-map of the level, size 128 x 128, RGB components.
  108. struct sQ3BSPLightmap {
  109. unsigned char bLMapData[ CE_BSP_LIGHTMAPSIZE ];
  110. sQ3BSPLightmap() {
  111. ::memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE );
  112. }
  113. };
  114. struct SubPatch {
  115. std::vector<size_t> indices;
  116. int lightmapID;
  117. };
  118. enum eLumps {
  119. kEntities = 0,
  120. kTextures,
  121. kPlanes,
  122. kNodes,
  123. kLeafs,
  124. kLeafFaces,
  125. kLeafBrushes,
  126. kModels,
  127. kBrushes,
  128. kBrushSides,
  129. kVertices,
  130. kMeshVerts,
  131. kShaders,
  132. kFaces,
  133. kLightmaps,
  134. kLightVolumes,
  135. kVisData,
  136. kMaxLumps
  137. };
  138. struct Q3BSPModel {
  139. std::vector<unsigned char> m_Data;
  140. std::vector<sQ3BSPLump*> m_Lumps;
  141. std::vector<sQ3BSPVertex*> m_Vertices;
  142. std::vector<sQ3BSPFace*> m_Faces;
  143. std::vector<int> m_Indices;
  144. std::vector<sQ3BSPTexture*> m_Textures;
  145. std::vector<sQ3BSPLightmap*> m_Lightmaps;
  146. std::vector<char> m_EntityData;
  147. std::string m_ModelName;
  148. Q3BSPModel() :
  149. m_Data(),
  150. m_Lumps(),
  151. m_Vertices(),
  152. m_Faces(),
  153. m_Indices(),
  154. m_Textures(),
  155. m_Lightmaps(),
  156. m_EntityData(),
  157. m_ModelName( "" )
  158. {
  159. // empty
  160. }
  161. ~Q3BSPModel() {
  162. for ( unsigned int i=0; i<m_Lumps.size(); i++ ) {
  163. delete m_Lumps[ i ];
  164. }
  165. for ( unsigned int i=0; i<m_Vertices.size(); i++ ) {
  166. delete m_Vertices[ i ];
  167. }
  168. for ( unsigned int i=0; i<m_Faces.size(); i++ ) {
  169. delete m_Faces[ i ];
  170. }
  171. for ( unsigned int i=0; i<m_Textures.size(); i++ ) {
  172. delete m_Textures[ i ];
  173. }
  174. for ( unsigned int i=0; i<m_Lightmaps.size(); i++ ) {
  175. delete m_Lightmaps[ i ];
  176. }
  177. m_Lumps.clear();
  178. m_Vertices.clear();
  179. m_Faces.clear();
  180. m_Textures.clear();
  181. m_Lightmaps.clear();
  182. }
  183. };
  184. } // Namespace Q3BSP
  185. } // Namespace Assimp
  186. #endif // ASSIMP_Q3BSPFILEDATA_H_INC