2
0

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 for MDR - not validated for the moment
  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. } PACK_STRUCT;
  72. // ---------------------------------------------------------------------------
  73. /** \brief Data structure for a triangle in a MDR file
  74. */
  75. struct Triangle
  76. {
  77. uint32_t indexes[3];
  78. } PACK_STRUCT;
  79. // ---------------------------------------------------------------------------
  80. /** \brief Data structure for a surface in a MDR file
  81. */
  82. struct Surface
  83. {
  84. uint32_t ident;
  85. char name[AI_MDR_MAXQPATH]; // polyset name
  86. char shader[AI_MDR_MAXQPATH];
  87. uint32_t shaderIndex;
  88. int32_t ofsHeader; // this will be a negative number
  89. uint32_t numVerts;
  90. uint32_t ofsVerts;
  91. uint32_t numTriangles;
  92. uint32_t ofsTriangles;
  93. // Bone references are a set of ints representing all the bones
  94. // present in any vertex weights for this surface. This is
  95. // needed because a model may have surfaces that need to be
  96. // drawn at different sort times, and we don't want to have
  97. // to re-interpolate all the bones for each surface.
  98. uint32_t numBoneReferences;
  99. uint32_t ofsBoneReferences;
  100. uint32_t ofsEnd; // next surface follows
  101. } PACK_STRUCT;
  102. // ---------------------------------------------------------------------------
  103. /** \brief Data structure for a bone in a MDR file
  104. */
  105. struct Bone
  106. {
  107. float matrix[3][4];
  108. } PACK_STRUCT;
  109. // ---------------------------------------------------------------------------
  110. /** \brief Data structure for a frame in a MDR file
  111. */
  112. struct Frame {
  113. aiVector3D bounds0,bounds1; // bounds of all surfaces of all LOD's for this frame
  114. aiVector3D localOrigin; // midpoint of bounds, used for sphere cull
  115. float radius; // dist from localOrigin to corner
  116. char name[16];
  117. // bones follow here
  118. } PACK_STRUCT;
  119. // ---------------------------------------------------------------------------
  120. /** \brief Data structure for a compressed bone in a MDR file
  121. */
  122. struct CompBone
  123. {
  124. unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple
  125. } PACK_STRUCT;
  126. // ---------------------------------------------------------------------------
  127. /** \brief Data structure for a compressed frame in a MDR file
  128. */
  129. struct CompFrame
  130. {
  131. aiVector3D bounds0,bounds1; // bounds of all surfaces of all LOD's for this frame
  132. aiVector3D localOrigin; // midpoint of bounds, used for sphere cull
  133. float radius; // dist from localOrigin to corner
  134. } PACK_STRUCT;
  135. // ---------------------------------------------------------------------------
  136. /** \brief Data structure for a LOD in a MDR file
  137. */
  138. struct LOD
  139. {
  140. uint32_t numSurfaces;
  141. uint32_t ofsSurfaces; // first surface, others follow
  142. uint32_t ofsEnd; // next lod follows
  143. } ;
  144. // ---------------------------------------------------------------------------
  145. /** \brief Data structure for a tag (= attachment) in a MDR file
  146. */
  147. struct Tag
  148. {
  149. uint32_t boneIndex;
  150. char name[32];
  151. } PACK_STRUCT;
  152. // ---------------------------------------------------------------------------
  153. /** \brief Header data structure for a MDR file
  154. */
  155. struct Header
  156. {
  157. int32_t ident;
  158. int32_t version;
  159. char name[AI_MDR_MAXQPATH];
  160. // frames and bones are shared by all levels of detail
  161. int32_t numFrames;
  162. int32_t numBones;
  163. int32_t ofsFrames;
  164. // each level of detail has completely separate sets of surfaces
  165. int32_t numLODs;
  166. int32_t ofsLODs;
  167. int32_t numTags;
  168. int32_t ofsTags;
  169. int32_t ofsEnd;
  170. } PACK_STRUCT;
  171. #include "./../include/Compiler/poppack1.h"
  172. }}
  173. #endif // !! AI_MDRFILEHELPER_H_INC