Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

204 lignes
5.6 KiB

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