BsMeshImportOptions.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsCorePrerequisites.h"
  5. #include "BsImportOptions.h"
  6. #include "BsAnimationClip.h"
  7. namespace bs
  8. {
  9. /** @addtogroup Importer
  10. * @{
  11. */
  12. /** Controls what type of collision mesh should be imported during mesh import. */
  13. enum class CollisionMeshType
  14. {
  15. None, /**< No collision mesh will be imported. */
  16. Normal, /**< Normal triangle mesh will be imported. */
  17. Convex /**< A convex hull will be generated from the source mesh. */
  18. };
  19. /** Information about how to split an AnimationClip into multiple separate clips. */
  20. struct BS_CORE_EXPORT AnimationSplitInfo : IReflectable
  21. {
  22. AnimationSplitInfo() { }
  23. String name;
  24. UINT32 startFrame = 0;
  25. UINT32 endFrame = 0;
  26. bool isAdditive = false;
  27. /************************************************************************/
  28. /* SERIALIZATION */
  29. /************************************************************************/
  30. public:
  31. friend class AnimationSplitInfoRTTI;
  32. static RTTITypeBase* getRTTIStatic();
  33. RTTITypeBase* getRTTI() const override;
  34. };
  35. /** A set of animation events that will be added to an animation clip during animation import. */
  36. struct BS_CORE_EXPORT ImportedAnimationEvents : IReflectable
  37. {
  38. ImportedAnimationEvents() { }
  39. String name;
  40. Vector<AnimationEvent> events;
  41. /************************************************************************/
  42. /* SERIALIZATION */
  43. /************************************************************************/
  44. public:
  45. friend class ImportedAnimationEventsRTTI;
  46. static RTTITypeBase* getRTTIStatic();
  47. RTTITypeBase* getRTTI() const override;
  48. };
  49. /**
  50. * Contains import options you may use to control how is a mesh imported from some external format into engine format.
  51. */
  52. class BS_CORE_EXPORT MeshImportOptions : public ImportOptions
  53. {
  54. public:
  55. MeshImportOptions();
  56. /** Sets whether the texture data is also stored in CPU memory. */
  57. void setCPUCached(bool cached) { mCPUCached = cached; }
  58. /** Retrieves whether the texture data is also stored in CPU memory. */
  59. bool getCPUCached() const { return mCPUCached; }
  60. /** Sets whether the texture data can be read directly from the GPU. */
  61. void setCPUReadable(bool readable) { mCPUReadable = readable; }
  62. /** Retrieves whether the texture data can be read directly from the GPU. */
  63. bool getCPUReadable() const { return mCPUReadable; }
  64. /** Sets a value that controls should mesh normals be imported if available. */
  65. void setImportNormals(bool import) { mImportNormals = import; }
  66. /** Retrieves a value that controls should mesh normals be imported if available. */
  67. bool getImportNormals() const { return mImportNormals; }
  68. /** Sets a value that controls should mesh tangents/bitangents be imported if available. */
  69. void setImportTangents(bool import) { mImportTangents = import; }
  70. /** Retrieves a value that controls should mesh tangent/bitangent be imported if available. */
  71. bool getImportTangents() const { return mImportTangents; }
  72. /** Sets a value that controls should mesh blend shapes be imported if available. */
  73. void setImportBlendShapes(bool import) { mImportBlendShapes = import; }
  74. /** Retrieves a value that controls should mesh blend shapes be imported if available. */
  75. bool getImportBlendShapes() const { return mImportBlendShapes; }
  76. /**
  77. * Sets a value that controls should mesh skin data like bone weights, indices and bind poses be imported if
  78. * available.
  79. */
  80. void setImportSkin(bool import) { mImportSkin = import; }
  81. /**
  82. * Retrieves a value that controls should mesh skin data like bone weights, indices and bind poses be imported if
  83. * available.
  84. */
  85. bool getImportSkin() const { return mImportSkin; }
  86. /** Sets a value that controls should animation clips be imported if available. */
  87. void setImportAnimation(bool import) { mImportAnimation = import; }
  88. /** Retrieves a value that controls should animation clips be imported if available. */
  89. bool getImportAnimation() const { return mImportAnimation; }
  90. /** Sets a value that will uniformly scale the imported mesh by the specified value. */
  91. void setImportScale(float import) { mImportScale = import; }
  92. /** Retrieves a value that will uniformly scale the imported mesh by the specified value. */
  93. float getImportScale() const { return mImportScale; }
  94. /** Sets a value that controls what type (if any) of collision mesh should be imported. */
  95. void setCollisionMeshType(CollisionMeshType type) { mCollisionMeshType = type; }
  96. /** Retrieves a value that controls what type (if any) of collision mesh should be imported. */
  97. CollisionMeshType getCollisionMeshType() const { return mCollisionMeshType; }
  98. /**
  99. * Registers animation split infos that determine how will the source animation clip be split. If no splits
  100. * are present the data will be imported as one clip, but if splits are present the data will be split according
  101. * to the split infos. Split infos only affect the primary animation clip, other clips will not be split.
  102. */
  103. void setAnimationClipSplits(const Vector<AnimationSplitInfo>& splitInfos) { mAnimationSplits = splitInfos; }
  104. /** Returns a copy of the animation splits array. @see setAnimationClipSplits. */
  105. Vector<AnimationSplitInfo> getAnimationClipSplits() const { return mAnimationSplits; }
  106. /** Assigns a set of events that will be added to the animation clip, if animation import is enabled. */
  107. void setAnimationEvents(const Vector<ImportedAnimationEvents>& events) { mAnimationEvents = events; }
  108. /** Returns a copy of the animation events array. @see setAnimationEvents. */
  109. Vector<ImportedAnimationEvents> getAnimationEvents() const { return mAnimationEvents; }
  110. /**
  111. * Enables or disables keyframe reduction. Keyframe reduction will reduce the number of key-frames in an animation
  112. * clip by removing identical keyframes, and therefore reducing the size of the clip.
  113. */
  114. void setKeyFrameReduction(bool enabled) { mReduceKeyFrames = enabled; }
  115. /**
  116. * Checks is keyframe reduction enabled.
  117. *
  118. * @see setKeyFrameReduction
  119. */
  120. bool getKeyFrameReduction() const { return mReduceKeyFrames; }
  121. /**
  122. * Enables or disables import of root motion curves. When enabled, any animation curves in imported animations
  123. * affecting the root bone will be available through a set of separate curves in AnimationClip, and they won't be
  124. * evaluated through normal animation process. Instead it is expected that the user evaluates the curves manually
  125. * and applies them as required.
  126. */
  127. void setImportRootMotion(bool enabled) { mImportRootMotion = enabled; }
  128. /**
  129. * Checks is root motion import enabled.
  130. *
  131. * @see setImportRootMotion
  132. */
  133. bool getImportRootMotion() const { return mImportRootMotion; }
  134. /** Creates a new import options object that allows you to customize how are meshes imported. */
  135. static SPtr<MeshImportOptions> create();
  136. private:
  137. bool mCPUCached;
  138. bool mImportNormals;
  139. bool mImportTangents;
  140. bool mImportBlendShapes;
  141. bool mImportSkin;
  142. bool mImportAnimation;
  143. bool mReduceKeyFrames;
  144. bool mImportRootMotion;
  145. float mImportScale;
  146. bool mCPUReadable;
  147. CollisionMeshType mCollisionMeshType;
  148. Vector<AnimationSplitInfo> mAnimationSplits;
  149. Vector<ImportedAnimationEvents> mAnimationEvents;
  150. /************************************************************************/
  151. /* SERIALIZATION */
  152. /************************************************************************/
  153. public:
  154. friend class MeshImportOptionsRTTI;
  155. static RTTITypeBase* getRTTIStatic();
  156. RTTITypeBase* getRTTI() const override;
  157. };
  158. /** @} */
  159. }