MDRFileData.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 MDR files */
  34. #ifndef AI_MDRFILEHELPER_H_INC
  35. #define AI_MDRFILEHELPER_H_INC
  36. #include "../include/aiTypes.h"
  37. #include "../include/aiMesh.h"
  38. #include "../include/aiAnim.h"
  39. #include "./../include/Compiler/pushpack1.h"
  40. namespace Assimp {
  41. namespace MDR {
  42. // to make it easier for ourselfes, we test the magic word against both "endianesses"
  43. #define MDR_MAKE(string) ((uint32_t)((string[0] << 24) + (string[1] << 16) + (string[2] << 8) + string[3]))
  44. #define AI_MDR_MAGIC_NUMBER_BE MDR_MAKE("RDM5")
  45. #define AI_MDR_MAGIC_NUMBER_LE MDR_MAKE("5MDR")
  46. // common limitations
  47. #define AI_MDR_VERSION 2
  48. #define AI_MDR_MAXQPATH 64
  49. #define AI_MDR_MAX_BONES 128
  50. // ---------------------------------------------------------------------------
  51. /** \brief Data structure for a vertex weight in a MDR file
  52. */
  53. struct Weight
  54. {
  55. //! these are indexes into the boneReferences
  56. //! not the global per-frame bone list
  57. uint32_t boneIndex;
  58. //! weight of this bone
  59. float boneWeight;
  60. //! offset of this bone
  61. aiVector3D offset;
  62. } PACK_STRUCT;
  63. // ---------------------------------------------------------------------------
  64. /** \brief Data structure for a vertex in a MDR file
  65. */
  66. struct Vertex
  67. {
  68. aiVector3D normal;
  69. aiVector2D texCoords;
  70. uint32_t numWeights;
  71. Weight weights[1]; // variable sized
  72. } PACK_STRUCT;
  73. // ---------------------------------------------------------------------------
  74. /** \brief Data structure for a triangle in a MDR file
  75. */
  76. struct Triangle
  77. {
  78. uint32_t indexes[3];
  79. } PACK_STRUCT;
  80. // ---------------------------------------------------------------------------
  81. /** \brief Data structure for a surface in a MDR file
  82. */
  83. struct Surface
  84. {
  85. uint32_t ident;
  86. char name[AI_MDR_MAXQPATH]; // polyset name
  87. char shader[AI_MDR_MAXQPATH];
  88. uint32_t shaderIndex;
  89. int32_t ofsHeader; // this will be a negative number
  90. uint32_t numVerts;
  91. uint32_t ofsVerts;
  92. uint32_t numTriangles;
  93. uint32_t ofsTriangles;
  94. // Bone references are a set of ints representing all the bones
  95. // present in any vertex weights for this surface. This is
  96. // needed because a model may have surfaces that need to be
  97. // drawn at different sort times, and we don't want to have
  98. // to re-interpolate all the bones for each surface.
  99. uint32_t numBoneReferences;
  100. uint32_t ofsBoneReferences;
  101. uint32_t ofsEnd; // next surface follows
  102. } PACK_STRUCT;
  103. // ---------------------------------------------------------------------------
  104. /** \brief Data structure for a bone in a MDR file
  105. */
  106. struct Bone
  107. {
  108. float matrix[3][4];
  109. } PACK_STRUCT;
  110. // ---------------------------------------------------------------------------
  111. /** \brief Data structure for a frame in a MDR file
  112. */
  113. struct Frame {
  114. aiVector3D bounds[2]; // bounds of all surfaces of all LOD's for this frame
  115. aiVector3D localOrigin; // midpoint of bounds, used for sphere cull
  116. float radius; // dist from localOrigin to corner
  117. char name[16];
  118. Bone bones[1]; // [numBones]
  119. } PACK_STRUCT;
  120. // ---------------------------------------------------------------------------
  121. /** \brief Data structure for a compressed bone in a MDR file
  122. */
  123. struct CompBone
  124. {
  125. unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
  126. } PACK_STRUCT;
  127. // ---------------------------------------------------------------------------
  128. /** \brief Data structure for a compressed frame in a MDR file
  129. */
  130. struct CompFrame
  131. {
  132. aiVector3D bounds[2]; // bounds of all surfaces of all LOD's for this frame
  133. aiVector3D localOrigin; // midpoint of bounds, used for sphere cull
  134. float radius; // dist from localOrigin to corner
  135. CompBone bones[1]; // [numBones]
  136. } PACK_STRUCT;
  137. // ---------------------------------------------------------------------------
  138. /** \brief Data structure for a LOD in a MDR file
  139. */
  140. struct LOD
  141. {
  142. uint32_t numSurfaces;
  143. uint32_t ofsSurfaces; // first surface, others follow
  144. uint32_t ofsEnd; // next lod follows
  145. } ;
  146. // ---------------------------------------------------------------------------
  147. /** \brief Data structure for a tag (= attachment) in a MDR file
  148. */
  149. struct Tag
  150. {
  151. uint32_t boneIndex;
  152. char name[32];
  153. } PACK_STRUCT;
  154. // ---------------------------------------------------------------------------
  155. /** \brief Header data structure for a MDR file
  156. */
  157. struct Header
  158. {
  159. uint32_t ident;
  160. uint32_t version;
  161. char name[AI_MDR_MAXQPATH];
  162. // frames and bones are shared by all levels of detail
  163. int32_t numFrames;
  164. uint32_t numBones;
  165. uint32_t ofsFrames;
  166. // each level of detail has completely separate sets of surfaces
  167. uint32_t numLODs;
  168. uint32_t ofsLODs;
  169. uint32_t numTags;
  170. uint32_t ofsTags;
  171. uint32_t ofsEnd;
  172. } PACK_STRUCT;
  173. #include "./../include/Compiler/poppack1.h"
  174. };
  175. };
  176. #endif // !! AI_MDRFILEHELPER_H_INC