MDCFileData.h 5.8 KB

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