Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

197 rindas
7.5 KiB

  1. #ifndef INCLUDED_ASSBIN_CHUNKS_H
  2. #define INCLUDED_ASSBIN_CHUNKS_H
  3. #define ASSBIN_VERSION_MAJOR 1
  4. #define ASSBIN_VERSION_MINOR 0
  5. /**
  6. @page assfile .ASS File formats
  7. @section over Overview
  8. Assimp provides its own interchange format, which is intended to applications which need
  9. to serialize 3D-models and to reload them quickly. Assimp's file formats are designed to
  10. be read by Assimp itself. They encode additional information needed by Assimp to optimize
  11. its postprocessing pipeline. If you once apply specific steps to a scene, then save it
  12. and reread it from an ASS format using the same post processing settings, they won't
  13. be executed again.
  14. The format comes in two flavours: XML and binary - both of them hold a complete dump of
  15. the 'aiScene' data structure returned by the APIs. The focus for the binary format
  16. (<tt>.assbin</tt>) is fast loading. Optional deflate compression helps reduce file size. The XML
  17. flavour, <tt>.assxml</tt> or simply .xml, is just a plain-to-xml conversion of aiScene.
  18. ASSBIN is Assimp's binary interchange format. assimp_cmd (<tt>&lt;root&gt;/tools/assimp_cmd</tt>) is able to
  19. write it and the core library provides a loader for it.
  20. @section assxml XML File format
  21. The format is pretty much self-explanatory due to its similarity to the in-memory aiScene structure.
  22. With few exceptions, C structures are wrapped in XML elements.
  23. The DTD for ASSXML can be found in <tt>&lt;root&gt;/doc/AssXML_Scheme.xml</tt>. Or have look
  24. at the output files generated by assimp_cmd.
  25. @section assbin Binary file format
  26. The ASSBIN file format is composed of chunks to represent the hierarchical aiScene data structure.
  27. This makes the format extensible and allows backward-compatibility with future data structure
  28. versions. The <tt>&lt;root&gt;/code/assbin_chunks.h</tt> header contains some magic constants
  29. for use by stand-alone ASSBIN loaders. Also, Assimp's own file writer can be found
  30. in <tt>&lt;root&gt;/tools/assimp_cmd/WriteDumb.cpp</tt> (yes, the 'b' is no typo ...).
  31. @verbatim
  32. -------------------------------------------------------------------------------
  33. 1. File structure:
  34. -------------------------------------------------------------------------------
  35. ----------------------
  36. | Header (500 bytes) |
  37. ----------------------
  38. | Variable chunks |
  39. ----------------------
  40. -------------------------------------------------------------------------------
  41. 2. Definitions:
  42. -------------------------------------------------------------------------------
  43. integer is four bytes wide, stored in little-endian byte order.
  44. short is two bytes wide, stored in little-endian byte order.
  45. byte is a single byte.
  46. string is an integer n followed by n UTF-8 characters, not terminated by zero
  47. float is an IEEE 754 single-precision floating-point value
  48. double is an IEEE 754 double-precision floating-point value
  49. t[n] is an array of n elements of type t
  50. -------------------------------------------------------------------------------
  51. 2. Header:
  52. -------------------------------------------------------------------------------
  53. byte[44] Magic identification string for ASSBIN files.
  54. 'ASSIMP.binary'
  55. integer Major version of the Assimp library which wrote the file
  56. integer Minor version of the Assimp library which wrote the file
  57. match these against ASSBIN_VERSION_MAJOR and ASSBIN_VERSION_MINOR
  58. integer SVN revision of the Assimp library (intended for our internal
  59. debugging - if you write Ass files from your own APPs, set this value to 0.
  60. integer Assimp compile flags
  61. short 0 for normal files, 1 for shortened dumps for regression tests
  62. these should have the file extension assbin.regress
  63. short 1 if the data after the header is compressed with the DEFLATE algorithm,
  64. 0 for uncompressed files.
  65. For compressed files, the first integer after the header is
  66. always the uncompressed data size
  67. byte[256] Zero-terminated source file name, UTF-8
  68. byte[128] Zero-terminated command line parameters passed to assimp_cmd, UTF-8
  69. byte[64] Reserved for future use
  70. ---> Total length: 512 bytes
  71. -------------------------------------------------------------------------------
  72. 3. Chunks:
  73. -------------------------------------------------------------------------------
  74. integer Magic chunk ID (ASSBIN_CHUNK_XXX)
  75. integer Chunk data length, in bytes
  76. (unknown chunks are possible, a good reader skips over them)
  77. byte[n] length-of-chunk bytes of data, depending on the chunk type
  78. Chunks can contain nested chunks. Nested chunks are ALWAYS at the end of the chunk,
  79. their size is included in length-of-chunk.
  80. The chunk layout for all ASSIMP data structures is derived from their C declarations.
  81. The general 'rule' to get from Assimp headers to the serialized layout is:
  82. 1. POD members (i.e. aiMesh::mPrimitiveTypes, aiMesh::mNumVertices),
  83. in order of declaration.
  84. 2. Array-members (aiMesh::mFaces, aiMesh::mVertices, aiBone::mWeights),
  85. in order of declaration.
  86. 2. Object array members (i.e aiMesh::mBones, aiScene::mMeshes) are stored in
  87. subchunks directly following the data written in 1.) and 2.)
  88. Of course, there are some exceptions to this general order:
  89. [[aiScene]]
  90. - The root node holding the scene structure is naturally stored in
  91. a ASSBIN_CHUNK_AINODE subchunk following 1.) and 2.) (which is
  92. empty for aiScene).
  93. [[aiMesh]]
  94. - mTextureCoords and mNumUVComponents are serialized as follows:
  95. [number of used uv channels times]
  96. integer mNumUVComponents[n]
  97. float mTextureCoords[n][mNumUVComponents[n]]
  98. -> more than AI_MAX_TEXCOORD_CHANNELS can be stored. This allows Assimp
  99. builds with different settings for AI_MAX_TEXCOORD_CHANNELS to exchange
  100. data. Unlike the in-memory format, only the used components of the
  101. UV coordinates are written to disk. If mNumUVComponents[0] is 1, the
  102. corresponding mTextureCoords array consists of mNumTextureCoords*1
  103. single floats.
  104. - The array member block of aiMesh is prefixed with an integer that specifies
  105. the kinds of vertex components actually present in the mesh. This is a
  106. bitwise combination of the ASSBIN_MESH_HAS_xxx constants.
  107. [[aiFace]]
  108. - mNumIndices is stored as short
  109. - mIndices are written as short, if aiMesh::mNumVertices<65536
  110. [[aiNode]]
  111. - mParent is omitted
  112. [[aiLight]]
  113. - mAttenuationXXX not written if aiLight::mType == aiLightSource_DIRECTIONAL
  114. - mAngleXXX not written if aiLight::mType != aiLightSource_SPOT
  115. [[aiMaterial]]
  116. - mNumAllocated is omitted, for obvious reasons :-)
  117. @endverbatim*/
  118. #define ASSBIN_HEADER_LENGTH 512
  119. // these are the magic chunk identifiers for the binary ASS file format
  120. #define ASSBIN_CHUNK_AICAMERA 0x1234
  121. #define ASSBIN_CHUNK_AILIGHT 0x1235
  122. #define ASSBIN_CHUNK_AITEXTURE 0x1236
  123. #define ASSBIN_CHUNK_AIMESH 0x1237
  124. #define ASSBIN_CHUNK_AINODEANIM 0x1238
  125. #define ASSBIN_CHUNK_AISCENE 0x1239
  126. #define ASSBIN_CHUNK_AIBONE 0x123a
  127. #define ASSBIN_CHUNK_AIANIMATION 0x123b
  128. #define ASSBIN_CHUNK_AINODE 0x123c
  129. #define ASSBIN_CHUNK_AIMATERIAL 0x123d
  130. #define ASSBIN_CHUNK_AIMATERIALPROPERTY 0x123e
  131. #define ASSBIN_MESH_HAS_POSITIONS 0x1
  132. #define ASSBIN_MESH_HAS_NORMALS 0x2
  133. #define ASSBIN_MESH_HAS_TANGENTS_AND_BITANGENTS 0x4
  134. #define ASSBIN_MESH_HAS_TEXCOORD_BASE 0x100
  135. #define ASSBIN_MESH_HAS_COLOR_BASE 0x10000
  136. #define ASSBIN_MESH_HAS_TEXCOORD(n) (ASSBIN_MESH_HAS_TEXCOORD_BASE << n)
  137. #define ASSBIN_MESH_HAS_COLOR(n) (ASSBIN_MESH_HAS_COLOR_BASE << n)
  138. #endif // INCLUDED_ASSBIN_CHUNKS_H