aiPostProcess.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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 Definitions for import post processing steps */
  34. #ifndef AI_POSTPROCESS_H_INC
  35. #define AI_POSTPROCESS_H_INC
  36. #include "aiTypes.h"
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. /** Defines the flags for all possible post processing steps. */
  41. enum aiPostProcessSteps
  42. {
  43. /** Calculates the tangents and bitangents for the imported meshes. Does nothing
  44. * if a mesh does not have normals. You might want this post processing step to be
  45. * executed if you plan to use tangent space calculations such as normal mapping
  46. * applied to the meshes. There exists a configuration option,
  47. * #AI_CONFIG_PP_CT_MAX_SMOOTHING_ANGLE that allows you to specify
  48. * an angle maximum for the step.
  49. */
  50. aiProcess_CalcTangentSpace = 1,
  51. /** Identifies and joins identical vertex data sets within all imported meshes.
  52. * After this step is run each mesh does contain only unique vertices anymore,
  53. * so a vertex is possibly used by multiple faces. You propably always want
  54. * to use this post processing step.*/
  55. aiProcess_JoinIdenticalVertices = 2,
  56. /** Converts all the imported data to a left-handed coordinate space such as
  57. * the DirectX coordinate system. By default the data is returned in a right-handed
  58. * coordinate space which for example OpenGL prefers. In this space, +X points to the
  59. * right, +Y points towards the viewer and and +Z points upwards. In the DirectX
  60. * coordinate space +X points to the right, +Y points upwards and +Z points
  61. * away from the viewer.
  62. */
  63. aiProcess_ConvertToLeftHanded = 4,
  64. /** Triangulates all faces of all meshes. By default the imported mesh data might
  65. * contain faces with more than 3 indices. For rendering a mesh you usually need
  66. * all faces to be triangles. This post processing step splits up all higher faces
  67. * to triangles. This step won't modify line and point primitives. If you need
  68. * only triangles, do the following:<br>
  69. * 1. Specify both the aiProcess_Triangulate and the aiProcess_SortByPType
  70. * step. <br>
  71. * 2. Ignore all point and line meshes when you process assimp's output data.
  72. */
  73. aiProcess_Triangulate = 8,
  74. /** Removes some parts of the data structure (animations, materials,
  75. * light sources, cameras, textures, vertex components).
  76. *
  77. * The components to be removed are specified in a separate
  78. * configuration option, #AI_CONFIG_PP_RVC_FLAGS. This is quite useful
  79. * if you don't need all parts of the output structure. Especially vertex
  80. * colors are rarely used today ... . Calling this step to exclude unrequired
  81. * stuff from the pipeline as early as possible results in an increased
  82. * performance and a better optimized output data structure.
  83. * This step is also useful if you want to force Assimp to recompute
  84. * normals or tangents. The corresponding steps don't recompute them if
  85. * they're already there ( loaded from the source asset). By using this
  86. * step you can make sure they are NOT there.
  87. */
  88. aiProcess_RemoveComponent = 0x10,
  89. /** Generates normals for all faces of all meshes. The normals are shared
  90. * between the three vertices of a face. This is ignored
  91. * if normals are already existing. This flag may not be specified together
  92. * with aiProcess_GenSmoothNormals
  93. */
  94. aiProcess_GenNormals = 0x20,
  95. /** Generates smooth normals for all vertices in the mesh. This is ignored
  96. * if normals are already existing. This flag may not be specified together
  97. * with aiProcess_GenNormals. There exists a configuration option,
  98. * #AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE that allows you to specify
  99. * an angle maximum for the step.
  100. */
  101. aiProcess_GenSmoothNormals = 0x40,
  102. /** Splits large meshes into submeshes
  103. * This is quite useful for realtime rendering where the number of vertices
  104. * is usually limited by the video driver.
  105. *
  106. * The split limits can be set through aiSetVertexSplitLimit() and
  107. * aiSetTriangleSplitLimit(). The default values for this are defined
  108. * in the internal SplitLargeMeshes.h header as AI_SLM_DEFAULT_MAX_VERTICES
  109. * and AI_SLM_DEFAULT_MAX_TRIANGLES.
  110. */
  111. aiProcess_SplitLargeMeshes = 0x80,
  112. /** Removes the node graph and pretransforms all vertices with
  113. * the local transformation matrices of their nodes. The output
  114. * scene does still contain nodes, however, there is only a
  115. * root node with childs, each one referencing only one mesh,
  116. * each mesh referencing one material. For rendering, you can
  117. * simply render all meshes in order, you don't need to pay
  118. * attention to local transformations and the node hierarchy.
  119. * Animations are removed during this step.
  120. * This step is intended for applications that have no scenegraph.
  121. * The step CAN cause some problems: if e.g. a mesh of the asset
  122. * contains normals and another, using the same material index, does not,
  123. * they will be brought together, but the first meshes's part of
  124. * the normal list will be zeroed.
  125. */
  126. aiProcess_PreTransformVertices = 0x100,
  127. /** Limits the number of bones simultaneously affecting a single vertex
  128. * to a maximum value. If any vertex is affected by more than that number
  129. * of bones, the least important vertex weights are removed and the remaining
  130. * vertex weights are renormalized so that the weights still sum up to 1.
  131. * The default bone weight limit is 4 (defined as AI_LMW_MAX_WEIGHTS in
  132. * LimitBoneWeightsProcess.h), but you can use the aiSetBoneWeightLimit
  133. * function to supply your own limit to the post processing step.
  134. *
  135. * If you intend to perform the skinning in hardware, this post processing step
  136. * might be of interest for you.
  137. */
  138. aiProcess_LimitBoneWeights = 0x200,
  139. /** Validates the aiScene data structure before it is returned.
  140. * This makes sure that all indices are valid, all animations and
  141. * bones are linked correctly, all material are correct and so on ...
  142. * This is primarily intended for our internal debugging stuff,
  143. * however, it could be of interest for applications like editors
  144. * where stability is more important than loading performance.
  145. */
  146. aiProcess_ValidateDataStructure = 0x400,
  147. /** Reorders triangles for vertex cache locality and thus better performance.
  148. * The step tries to improve the ACMR (average post-transform vertex cache
  149. * miss ratio) for all meshes. The step runs in O(n) and is roughly
  150. * basing on the algorithm described in this paper:
  151. * http://www.cs.princeton.edu/gfx/pubs/Sander_2007_%3ETR/tipsy.pdf
  152. */
  153. aiProcess_ImproveCacheLocality = 0x800,
  154. /** Searches for redundant materials and removes them.
  155. *
  156. * This is especially useful in combination with the PretransformVertices
  157. * and OptimizeGraph steps. Both steps join small meshes, but they
  158. * can't do that if two meshes have different materials.
  159. */
  160. aiProcess_RemoveRedundantMaterials = 0x1000,
  161. /** This step tries to determine which meshes have normal vectors
  162. * that are facing inwards. The algorithm is simple but effective:
  163. * the bounding box of all vertices + their normals is compared against
  164. * the volume of the bounding box of all vertices without their normals.
  165. * This works well for most objects, problems might occur with planar
  166. * surfaces. However, the step tries to filter such cases.
  167. * The step inverts all infacing normals. Generally it is recommended
  168. * to enable this step, although the result is not always correct.
  169. */
  170. aiProcess_FixInfacingNormals = 0x2000,
  171. /** This step performs some optimizations on the node graph.
  172. *
  173. * It is incompatible to the PreTransformVertices-Step. Some configuration
  174. * options exist, see aiConfig.h for more details.
  175. * Generally, two actions are available:<br>
  176. * 1. Remove animation nodes and data from the scene. This allows other
  177. * steps for further optimizations.<br>
  178. * 2. Combine very small meshes to larger ones. Only if the meshes
  179. * are used by the same node or by nodes on the same hierarchy (with
  180. * equal local transformations). Unlike PreTransformVertices, the
  181. * OptimizeGraph-step doesn't transform vertices from one space
  182. * another (at least with the default configuration).<br>
  183. *
  184. * It is recommended to have this step run with the default configuration.
  185. */
  186. aiProcess_OptimizeGraph = 0x4000,
  187. /** This step splits meshes with more than one primitive type in
  188. * homogenous submeshes.
  189. *
  190. * The step is executed after the triangulation step. After the step
  191. * returns, just one bit is set in aiMesh::mPrimitiveTypes. This is
  192. * especially useful for real-time rendering where point and line
  193. * primitives are often ignored or rendered separately.
  194. * You can use the AI_CONFIG_PP_SBP_REMOVE option to specify which
  195. * primitive types you need. This can be used to easily exclude
  196. * lines and points, which are rarely used, from the import.
  197. */
  198. aiProcess_SortByPType = 0x8000,
  199. /** This step searches all meshes for degenerated primitives and
  200. * converts them to proper lines or points.
  201. *
  202. * A face is degenerated if one or more of its faces are identical.
  203. */
  204. aiProcess_FindDegenerates = 0x10000,
  205. /** This step searches all meshes for invalid data, such as zeroed
  206. * normal vectors or invalid UV coords and removes them.
  207. *
  208. * This is especially useful for normals. If they are invalid, and
  209. * the step recognizes this, they will be removed and can later
  210. * be computed by one of the other steps.<br>
  211. * The step will also remove meshes that are infinitely small.
  212. */
  213. aiProcess_FindInvalidData = 0x20000,
  214. /** This step converts non-UV mappings (such as spherical or
  215. * cylindrical) to proper UV mapping channels.
  216. *
  217. * Most applications will support UV mapping only, so you will
  218. * propably want to specify this step in every case.
  219. */
  220. aiProcess_GenUVCoords = 0x40000,
  221. /** This step pretransforms UV coordinates by the UV transformations
  222. * (such as scalings or rotations).
  223. *
  224. * UV transformations are specified per-texture - see the
  225. * AI_MATKEY_UVTRANSFORM key for more information on this topic.
  226. * This step finds all textures with transformed input UV
  227. * coordinates and generates a new, transformed, UV channel for it.
  228. * Most applications won't support UV transformations, so you will
  229. * propably want to specify this step in every case.
  230. */
  231. aiProcess_TransformUVCoords = 0x80000,
  232. };
  233. /** @def AI_POSTPROCESS_DEFAULT_REALTIME_FASTEST
  234. * @brief Default postprocess configuration targeted at realtime applications
  235. * which need to load models as fast as possible.
  236. *
  237. * If you're using DirectX, don't forget to combine this value with
  238. * the #aiProcess_ConvertToLeftHanded step.
  239. */
  240. #define AI_POSTPROCESS_DEFAULT_REALTIME_FASTEST \
  241. aiProcess_CalcTangentSpace | \
  242. aiProcess_GenNormals | \
  243. aiProcess_JoinIdenticalVertices | \
  244. aiProcess_Triangulate | \
  245. aiProcess_GenUVCoords
  246. /** @def AI_POSTPROCESS_DEFAULT_REALTIME
  247. * @brief Default postprocess configuration targeted at realtime applications.
  248. * Unlike AI_POSTPROCESS_DEFAULT_REALTIME_FASTEST, this configuration
  249. * performs some extra optimizations.
  250. *
  251. * If you're using DirectX, don't forget to combine this value with
  252. * the #aiProcess_ConvertToLeftHanded step.
  253. */
  254. #define AI_POSTPROCESS_DEFAULT_REALTIME \
  255. aiProcess_CalcTangentSpace | \
  256. aiProcess_GenSmoothNormals | \
  257. aiProcess_JoinIdenticalVertices | \
  258. aiProcess_ImproveCacheLocality | \
  259. aiProcess_LimitBoneWeights | \
  260. aiProcess_RemoveRedundantMaterials | \
  261. aiProcess_SplitLargeMeshes | \
  262. aiProcess_OptimizeGraph | \
  263. aiProcess_Triangulate | \
  264. aiProcess_GenUVCoords
  265. #ifdef __cplusplus
  266. } // end of extern "C"
  267. #endif
  268. #endif // AI_POSTPROCESS_H_INC