Q3BSPFileData.h 5.1 KB

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