Q3BSPFileData.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /*
  2. Open Asset Import Library (ASSIMP)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2008, ASSIMP Development 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 Development 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. {
  38. namespace Q3BSP
  39. {
  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. enum Q3BSPGeoType
  43. {
  44. Polygon = 1,
  45. Patch,
  46. Mesh,
  47. Billboard
  48. };
  49. /// Integer vector.
  50. struct ceVec3i
  51. {
  52. int x, y, z;
  53. ceVec3i(): x( 0 ), y( 0 ), z( 0 ) { /* empty */ }
  54. ceVec3i( int iX, int iY=0, int iZ=0) : x( iX ), y( iY ), z( iZ ) { /* empty */ }
  55. };
  56. /// Fileheader
  57. struct sQ3BSPHeader
  58. {
  59. char strID[ 4 ]; //!< Should be "IBSP"
  60. int iVersion; //!< 46 for standard levels
  61. };
  62. /// Descripes an entry.
  63. struct sQ3BSPLump
  64. {
  65. int iOffset; ///< Offset from startpointer of file
  66. int iSize; ///< Size fo part
  67. };
  68. struct vec2f
  69. {
  70. float x,y;
  71. };
  72. struct vec3f
  73. {
  74. float x, y, z;
  75. };
  76. /// Vertex of a Q3 level
  77. struct sQ3BSPVertex
  78. {
  79. vec3f vPosition; ///< Position of vertex
  80. vec2f vTexCoord; ///< (u,v) Texturecoordinate of detailtexture
  81. vec2f vLightmap; ///< (u,v) Texturecoordinate of lightmap
  82. vec3f vNormal; ///< vertex normale
  83. unsigned char bColor[ 4 ]; ///< Color in RGBA
  84. };
  85. /// A face in bsp format info
  86. struct sQ3BSPFace
  87. {
  88. int iTextureID; ///< Index in texture array
  89. int iEffect; ///< Index in effectarray (-1 = no effect)
  90. int iType; ///< 1=Polygon, 2=Patch, 3=Mesh, 4=Billboard
  91. int iVertexIndex; ///< Start index of polygon
  92. int iNumOfVerts; ///< Number of vertices
  93. int iFaceVertexIndex; ///< Index of first mesh vertex
  94. int iNumOfFaceVerts; ///< Anzahl der Meshvertices
  95. int iLightmapID; ///< Index to the lightmap array
  96. int iLMapCorner[ 2 ]; ///< Die Ecke der Lightmap in der Textur
  97. int iLMapSize[ 2 ]; ///< Size of the lightmap stored on the texture
  98. vec3f vLMapPos; ///< 3D-Ursprung der Lightmap
  99. vec3f vLMapVecs[ 2 ]; ///< 3D-s-t-Vektoren
  100. vec3f vNormal; ///< Polygonnormale
  101. int patchWidth, patchHeight; ///< bezier patch
  102. };
  103. /// A quake3 texture name.
  104. struct sQ3BSPTexture
  105. {
  106. char strName[ 64 ]; ///< Name of the texture without extention
  107. int iFlags; ///< Not used
  108. int iContents; ///< Not used
  109. };
  110. /// A lightmap of the level, size 128 x 128, RGB components.
  111. struct sQ3BSPLightmap
  112. {
  113. unsigned char bLMapData[ CE_BSP_LIGHTMAPSIZE ];
  114. sQ3BSPLightmap()
  115. {
  116. memset(bLMapData, 0, CE_BSP_LIGHTMAPSIZE );
  117. }
  118. };
  119. struct sRenderVertex
  120. {
  121. vec3f vPosition;
  122. vec2f vTC;
  123. vec2f vTCLightmap;
  124. };
  125. struct SubPatch
  126. {
  127. std::vector<sRenderVertex> controlPoints;
  128. std::vector<sRenderVertex> vertices;
  129. std::vector<size_t> indices;
  130. int lightmapID;
  131. };
  132. enum eLumps
  133. {
  134. kEntities = 0,
  135. kTextures,
  136. kPlanes,
  137. kNodes,
  138. kLeafs,
  139. kLeafFaces,
  140. kLeafBrushes,
  141. kModels,
  142. kBrushes,
  143. kBrushSides,
  144. kVertices,
  145. kMeshVerts,
  146. kShaders,
  147. kFaces,
  148. kLightmaps,
  149. kLightVolumes,
  150. kVisData,
  151. kMaxLumps
  152. };
  153. struct Q3BSPModel
  154. {
  155. std::vector<unsigned char> m_Data;
  156. std::vector<sQ3BSPLump*> m_Lumps;
  157. std::vector<sQ3BSPVertex*> m_Vertices;
  158. std::vector<sQ3BSPFace*> m_Faces;
  159. std::vector<int> m_Indices;
  160. std::vector<sQ3BSPTexture*> m_Textures;
  161. std::vector<sQ3BSPLightmap*> m_Lightmaps;
  162. std::vector<char> m_EntityData;
  163. std::string m_ModelName;
  164. Q3BSPModel() :
  165. m_Data(),
  166. m_Lumps(),
  167. m_Vertices(),
  168. m_Faces(),
  169. m_Indices(),
  170. m_Textures(),
  171. m_Lightmaps(),
  172. m_EntityData()
  173. {
  174. // empty
  175. }
  176. };
  177. }
  178. }
  179. #endif // ASSIMP_Q3BSPFILEDATA_H_INC