BsMeshImportOptions.h 7.7 KB

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