aiPostProcess.h 13 KB

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