Q3BSPFileData.h 5.1 KB

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