BsMeshImportOptions.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 BansheeEngine
  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 setCPUReadable(bool readable) { mCPUReadable = readable; }
  58. /** Retrieves whether the texture data is also stored in CPU memory. */
  59. bool getCPUReadable() const { return mCPUReadable; }
  60. /** Sets a value that controls should mesh normals be imported if available. */
  61. void setImportNormals(bool import) { mImportNormals = import; }
  62. /** Retrieves a value that controls should mesh normals be imported if available. */
  63. bool getImportNormals() const { return mImportNormals; }
  64. /** Sets a value that controls should mesh tangents/bitangents be imported if available. */
  65. void setImportTangents(bool import) { mImportTangents = import; }
  66. /** Retrieves a value that controls should mesh tangent/bitangent be imported if available. */
  67. bool getImportTangents() const { return mImportTangents; }
  68. /** Sets a value that controls should mesh blend shapes be imported if available. */
  69. void setImportBlendShapes(bool import) { mImportBlendShapes = import; }
  70. /** Retrieves a value that controls should mesh blend shapes be imported if available. */
  71. bool getImportBlendShapes() const { return mImportBlendShapes; }
  72. /**
  73. * Sets a value that controls should mesh skin data like bone weights, indices and bind poses be imported if
  74. * available.
  75. */
  76. void setImportSkin(bool import) { mImportSkin = import; }
  77. /**
  78. * Retrieves a value that controls should mesh skin data like bone weights, indices and bind poses be imported if
  79. * available.
  80. */
  81. bool getImportSkin() const { return mImportSkin; }
  82. /** Sets a value that controls should animation clips be imported if available. */
  83. void setImportAnimation(bool import) { mImportAnimation = import; }
  84. /** Retrieves a value that controls should animation clips be imported if available. */
  85. bool getImportAnimation() const { return mImportAnimation; }
  86. /** Sets a value that will uniformly scale the imported mesh by the specified value. */
  87. void setImportScale(float import) { mImportScale = import; }
  88. /** Retrieves a value that will uniformly scale the imported mesh by the specified value. */
  89. float getImportScale() const { return mImportScale; }
  90. /** Sets a value that controls what type (if any) of collision mesh should be imported. */
  91. void setCollisionMeshType(CollisionMeshType type) { mCollisionMeshType = type; }
  92. /** Retrieves a value that controls what type (if any) of collision mesh should be imported. */
  93. CollisionMeshType getCollisionMeshType() const { return mCollisionMeshType; }
  94. /**
  95. * Registers animation split infos that determine how will the source animation clip be split. If no splits
  96. * are present the data will be imported as one clip, but if splits are present the data will be split according
  97. * to the split infos. Split infos only affect the primary animation clip, other clips will not be split.
  98. */
  99. void setAnimationClipSplits(const Vector<AnimationSplitInfo>& splitInfos) { mAnimationSplits = splitInfos; }
  100. /** Returns a copy of the animation splits array. @see setAnimationClipSplits. */
  101. Vector<AnimationSplitInfo> getAnimationClipSplits() const { return mAnimationSplits; }
  102. /** Assigns a set of events that will be added to the animation clip, if animation import is enabled. */
  103. void setAnimationEvents(const Vector<ImportedAnimationEvents>& events) { mAnimationEvents = events; }
  104. /** Returns a copy of the animation events array. @see setAnimationEvents. */
  105. Vector<ImportedAnimationEvents> getAnimationEvents() const { return mAnimationEvents; }
  106. /**
  107. * Enables or disables keyframe reduction. Keyframe reduction will reduce the number of key-frames in an animation
  108. * clip by removing identical keyframes, and therefore reducing the size of the clip.
  109. */
  110. void setKeyFrameReduction(bool enabled) { mReduceKeyFrames = enabled; }
  111. /**
  112. * Checks is keyframe reduction enabled.
  113. *
  114. * @see setKeyFrameReduction
  115. */
  116. bool getKeyFrameReduction() const { return mReduceKeyFrames; }
  117. /**
  118. * Enables or disables import of root motion curves. When enabled, any animation curves in imported animations
  119. * affecting the root bone will be available through a set of separate curves in AnimationClip, and they won't be
  120. * evaluated through normal animation process. Instead it is expected that the user evaluates the curves manually
  121. * and applies them as required.
  122. */
  123. void setImportRootMotion(bool enabled) { mImportRootMotion = enabled; }
  124. /**
  125. * Checks is root motion import enabled.
  126. *
  127. * @see setImportRootMotion
  128. */
  129. bool getImportRootMotion() const { return mImportRootMotion; }
  130. private:
  131. bool mCPUReadable;
  132. bool mImportNormals;
  133. bool mImportTangents;
  134. bool mImportBlendShapes;
  135. bool mImportSkin;
  136. bool mImportAnimation;
  137. bool mReduceKeyFrames;
  138. bool mImportRootMotion;
  139. float mImportScale;
  140. CollisionMeshType mCollisionMeshType;
  141. Vector<AnimationSplitInfo> mAnimationSplits;
  142. Vector<ImportedAnimationEvents> mAnimationEvents;
  143. /************************************************************************/
  144. /* SERIALIZATION */
  145. /************************************************************************/
  146. public:
  147. friend class MeshImportOptionsRTTI;
  148. static RTTITypeBase* getRTTIStatic();
  149. RTTITypeBase* getRTTI() const override;
  150. };
  151. /** @} */
  152. }