MDCFileData.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2015, 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. // Modified by Lasse Oorni for Urho3D
  34. /** @file Defines the helper data structures for importing MDC files
  35. **********************************************************************
  36. File format specification:
  37. http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf
  38. **********************************************************************
  39. */
  40. #ifndef AI_MDCFILEHELPER_H_INC
  41. #define AI_MDCFILEHELPER_H_INC
  42. #include "../include/assimp/types.h"
  43. #include "../include/assimp/mesh.h"
  44. #include "../include/assimp/anim.h"
  45. #include "./../include/assimp/Compiler/pushpack1.h"
  46. // Urho3D: VS2008 compatibility
  47. #if !defined(_MSC_VER) || (_MSC_VER >= 1600)
  48. #include <stdint.h>
  49. #else
  50. #include "../include/assimp/Compiler/pstdint.h"
  51. #endif
  52. namespace Assimp {
  53. namespace MDC {
  54. // to make it easier for us, we test the magic word against both "endianesses"
  55. #define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI")
  56. #define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC")
  57. // common limitations
  58. #define AI_MDC_VERSION 2
  59. #define AI_MDC_MAXQPATH 64
  60. #define AI_MDC_MAX_BONES 128
  61. #define AI_MDC_CVERT_BIAS 127.0f
  62. #define AI_MDC_DELTA_SCALING 4.0f
  63. #define AI_MDC_BASE_SCALING (1.0f / 64.0f)
  64. // ---------------------------------------------------------------------------
  65. /** \brief Data structure for a MDC file's main header
  66. */
  67. struct Header
  68. {
  69. uint32_t ulIdent ;
  70. uint32_t ulVersion ;
  71. char ucName [ AI_MDC_MAXQPATH ] ;
  72. uint32_t ulFlags ;
  73. uint32_t ulNumFrames ;
  74. uint32_t ulNumTags ;
  75. uint32_t ulNumSurfaces ;
  76. uint32_t ulNumSkins ;
  77. uint32_t ulOffsetBorderFrames ;
  78. uint32_t ulOffsetTagNames ;
  79. uint32_t ulOffsetTagFrames ;
  80. uint32_t ulOffsetSurfaces ;
  81. uint32_t ulOffsetEnd ;
  82. } PACK_STRUCT ;
  83. // ---------------------------------------------------------------------------
  84. /** \brief Data structure for a MDC file's surface header
  85. */
  86. struct Surface
  87. {
  88. uint32_t ulIdent ;
  89. char ucName [ AI_MDC_MAXQPATH ] ;
  90. uint32_t ulFlags ;
  91. uint32_t ulNumCompFrames ;
  92. uint32_t ulNumBaseFrames ;
  93. uint32_t ulNumShaders ;
  94. uint32_t ulNumVertices ;
  95. uint32_t ulNumTriangles ;
  96. uint32_t ulOffsetTriangles ;
  97. uint32_t ulOffsetShaders ;
  98. uint32_t ulOffsetTexCoords ;
  99. uint32_t ulOffsetBaseVerts ;
  100. uint32_t ulOffsetCompVerts ;
  101. uint32_t ulOffsetFrameBaseFrames ;
  102. uint32_t ulOffsetFrameCompFrames ;
  103. uint32_t ulOffsetEnd;
  104. Surface()
  105. : ulIdent(),
  106. ulFlags(),
  107. ulNumCompFrames(),
  108. ulNumBaseFrames(),
  109. ulNumShaders(),
  110. ulNumVertices(),
  111. ulNumTriangles(),
  112. ulOffsetTriangles(),
  113. ulOffsetShaders(),
  114. ulOffsetTexCoords(),
  115. ulOffsetBaseVerts(),
  116. ulOffsetCompVerts(),
  117. ulOffsetFrameBaseFrames(),
  118. ulOffsetFrameCompFrames(),
  119. ulOffsetEnd()
  120. {
  121. ucName[AI_MDC_MAXQPATH-1] = '\0';
  122. }
  123. } PACK_STRUCT;
  124. // ---------------------------------------------------------------------------
  125. /** \brief Data structure for a MDC frame
  126. */
  127. struct Frame
  128. {
  129. //! bounding box minimum coords
  130. aiVector3D bboxMin ;
  131. //! bounding box maximum coords
  132. aiVector3D bboxMax ;
  133. //! local origin of the frame
  134. aiVector3D localOrigin ;
  135. //! radius of the BB
  136. float radius ;
  137. //! Name of the frame
  138. char name [ 16 ] ;
  139. } PACK_STRUCT;
  140. // ---------------------------------------------------------------------------
  141. /** \brief Data structure for a MDC triangle
  142. */
  143. struct Triangle
  144. {
  145. uint32_t aiIndices[3];
  146. } PACK_STRUCT;
  147. // ---------------------------------------------------------------------------
  148. /** \brief Data structure for a MDC texture coordinate
  149. */
  150. struct TexturCoord
  151. {
  152. float u,v;
  153. } PACK_STRUCT;
  154. // ---------------------------------------------------------------------------
  155. /** \brief Data structure for a MDC base vertex
  156. */
  157. struct BaseVertex
  158. {
  159. int16_t x,y,z;
  160. uint16_t normal;
  161. } PACK_STRUCT;
  162. // ---------------------------------------------------------------------------
  163. /** \brief Data structure for a MDC compressed vertex
  164. */
  165. struct CompressedVertex
  166. {
  167. uint8_t xd,yd,zd,nd;
  168. } PACK_STRUCT;
  169. // ---------------------------------------------------------------------------
  170. /** \brief Data structure for a MDC shader
  171. */
  172. struct Shader
  173. {
  174. char ucName [ AI_MDC_MAXQPATH ] ;
  175. uint32_t ulPath;
  176. } PACK_STRUCT;
  177. #include "./../include/assimp/Compiler/poppack1.h"
  178. // ---------------------------------------------------------------------------
  179. /** Build a floating point vertex from the compressed data in MDC files
  180. */
  181. void BuildVertex(const Frame& frame,
  182. const BaseVertex& bvert,
  183. const CompressedVertex& cvert,
  184. aiVector3D& vXYZOut,
  185. aiVector3D& vNorOut);
  186. }}
  187. #endif // !! AI_MDCFILEHELPER_H_INC