PostProcessStep.java 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (ASSIMP)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2008, ASSIMP Development Team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the ASSIMP team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the ASSIMP Development Team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. package assimp;
  35. /**
  36. * Enumeration class that defines postprocess steps that can be executed on a model
  37. * after it has been loaded. All PPSteps are implemented in C++, so their performance
  38. * is awesome. Most steps are O(n * log(n)).
  39. *
  40. * @author Aramis (Alexander Gessler)
  41. * @version 1.0
  42. */
  43. public class PostProcessStep {
  44. /**
  45. * Default vertex split limit for the SplitLargeMeshes process
  46. */
  47. public static final int DEFAULT_VERTEX_SPLIT_LIMIT = 1000000;
  48. /**
  49. * Default triangle split limit for the SplitLargeMeshes process
  50. */
  51. public static final int DEFAULT_TRIANGLE_SPLIT_LIMIT = 1000000;
  52. private static int s_iVertexSplitLimit = DEFAULT_VERTEX_SPLIT_LIMIT;
  53. private static int s_iTriangleSplitLimit = DEFAULT_TRIANGLE_SPLIT_LIMIT;
  54. /**
  55. * Identifies and joins identical vertex data sets within all imported
  56. * meshes. After this step is run each mesh does contain only unique
  57. * vertices anymore, so a vertex is possibly used by multiple faces.
  58. * You propably always want to use this post processing step.
  59. */
  60. public static final PostProcessStep JoinIdenticalVertices =
  61. new PostProcessStep("JoinIdenticalVertices");
  62. /**
  63. * Splits large meshes into submeshes
  64. * This is quite useful for realtime rendering where the number of
  65. * vertices is usually limited by the video driver.
  66. * <p/>
  67. * The split limits can be set through SetVertexSplitLimit() and
  68. * SetTriangleSplitLimit(). The default values are
  69. * <code>DEFAULT_VERTEX_SPLIT_LIMIT</code> and
  70. * <code>DEFAULT_TRIANGLE_SPLIT_LIMIT</code>
  71. */
  72. public static final PostProcessStep SplitLargeMeshes =
  73. new PostProcessStep("SplitLargeMeshes");
  74. /**
  75. * Omits all normals found in the file. This can be used together
  76. * with either the <code>GenSmoothNormals</code> or the
  77. * <code>GenFaceNormal</code> step to force the recomputation of the
  78. * normals. If none of the two flags is specified, the output mesh
  79. * won't have normals
  80. */
  81. public static final PostProcessStep KillNormals =
  82. new PostProcessStep("KillNormals");
  83. /**
  84. * Generates smooth normals for all vertices in the mesh. This is
  85. * ignored if normals are already existing. This step may not be used
  86. * together with <code>GenFaceNormals</code>
  87. */
  88. public static final PostProcessStep GenSmoothNormals =
  89. new PostProcessStep("GenSmoothNormals");
  90. /**
  91. * Generates normals for all faces of all meshes. The normals are
  92. * shared between the three vertices of a face. This is ignored
  93. * if normals are already existing. This step may not be used together
  94. * with <code>GenSmoothNormals</code>
  95. */
  96. public static final PostProcessStep GenFaceNormals =
  97. new PostProcessStep("GenFaceNormals");
  98. /**
  99. * Calculates the tangents and bitangents for the imported meshes. Does
  100. * nothing if a mesh does not have normals. You might want this post
  101. * processing step to be executed if you plan to use tangent space
  102. * calculations such as normal mapping applied to the meshes.
  103. */
  104. public static final PostProcessStep CalcTangentSpace =
  105. new PostProcessStep("CalcTangentSpace");
  106. /**
  107. * Converts all the imported data to a left-handed coordinate space
  108. * such as the DirectX coordinate system. By default the data is
  109. * returned in a right-handed coordinate space which for example
  110. * OpenGL prefers. In this space, +X points to the right, +Y points towards
  111. * the viewer and and +Z points upwards. In the DirectX coordinate space
  112. * +X points to the right, +Y points upwards and +Z points away from
  113. * the viewer.
  114. */
  115. public static final PostProcessStep ConvertToLeftHanded =
  116. new PostProcessStep("ConvertToLeftHanded ");
  117. /**
  118. * Removes the node graph and pretransforms all vertices with the local
  119. * transformation matrices of their nodes. The output scene does still
  120. * contain nodes, however, there is only a root node with childs, each
  121. * one referencing only one mesh, each mesh referencing one material.
  122. * For rendering, you can simply render all meshes in order, you don't
  123. * need to pay attention to local transformations and the node hierarchy.
  124. * Animations are removed during this step.
  125. */
  126. public static final PostProcessStep PreTransformVertices =
  127. new PostProcessStep("PreTransformVertices");
  128. /**
  129. * Set the vertex split limit for the "SplitLargeMeshes" process
  130. * If a mesh exceeds this limit it will be splitted
  131. *
  132. * @param limit New vertex split limit. Pass 0xffffffff to disable
  133. * a vertex split limit. However, splitting by triangles is still active
  134. * then.
  135. * @return Old vertex split limit
  136. */
  137. public static synchronized int setVertexSplitLimit(int limit) {
  138. if (s_iVertexSplitLimit != limit) {
  139. // send to the JNI bridge ...
  140. s_iVertexSplitLimit = limit;
  141. _NativeSetVertexSplitLimit(limit);
  142. }
  143. return limit;
  144. }
  145. /**
  146. * Set the triangle split limit for the "SplitLargeMeshes" process
  147. * If a mesh exceeds this limit it will be splitted
  148. *
  149. * @param limit new triangle split limit. Pass 0xffffffff to disable
  150. * a triangle split limit. However, splitting by vertices is still active
  151. * then.
  152. * @return Old triangle split limit
  153. */
  154. public static synchronized int setTriangleSplitLimit(int limit) {
  155. if (s_iTriangleSplitLimit != limit) {
  156. // send to the JNI bridge ...
  157. s_iTriangleSplitLimit = limit;
  158. _NativeSetTriangleSplitLimit(limit);
  159. }
  160. return limit;
  161. }
  162. /**
  163. * JNI bridge call. For internal use only
  164. *
  165. * @param limit New vertex split limit
  166. */
  167. private native static void _NativeSetVertexSplitLimit(int limit);
  168. /**
  169. * JNI bridge call. For internal use only
  170. *
  171. * @param limit New triangle split limit
  172. */
  173. private native static void _NativeSetTriangleSplitLimit(int limit);
  174. private final String myName; // for debug only
  175. private PostProcessStep(String name) {
  176. myName = name;
  177. }
  178. public String toString() {
  179. return myName;
  180. }
  181. }