BsMeshImportOptions.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. namespace BansheeEngine
  7. {
  8. /** @addtogroup Importer
  9. * @{
  10. */
  11. /** Controls what type of collision mesh should be imported during mesh import. */
  12. enum class CollisionMeshType
  13. {
  14. None, /**< No collision mesh will be imported. */
  15. Normal, /**< Normal triangle mesh will be imported. */
  16. Convex /**< A convex hull will be generated from the source mesh. */
  17. };
  18. /** Contains information about a piece of imported animation that will be used for generating its own AnimationClip. */
  19. struct AnimationSplitInfo : IReflectable
  20. {
  21. AnimationSplitInfo() { }
  22. String name;
  23. UINT32 startFrame = 0;
  24. UINT32 endFrame = 0;
  25. bool isAdditive = false;
  26. /************************************************************************/
  27. /* SERIALIZATION */
  28. /************************************************************************/
  29. public:
  30. friend class AnimationSplitInfoRTTI;
  31. static RTTITypeBase* getRTTIStatic();
  32. RTTITypeBase* getRTTI() const override;
  33. };
  34. /**
  35. * Contains import options you may use to control how is a mesh imported from some external format into engine format.
  36. */
  37. class BS_CORE_EXPORT MeshImportOptions : public ImportOptions
  38. {
  39. public:
  40. MeshImportOptions();
  41. /** Sets whether the texture data is also stored in CPU memory. */
  42. void setCPUReadable(bool readable) { mCPUReadable = readable; }
  43. /** Retrieves whether the texture data is also stored in CPU memory. */
  44. bool getCPUReadable() const { return mCPUReadable; }
  45. /** Sets a value that controls should mesh normals be imported if available. */
  46. void setImportNormals(bool import) { mImportNormals = import; }
  47. /** Retrieves a value that controls should mesh normals be imported if available. */
  48. bool getImportNormals() const { return mImportNormals; }
  49. /** Sets a value that controls should mesh tangents/bitangents be imported if available. */
  50. void setImportTangents(bool import) { mImportTangents = import; }
  51. /** Retrieves a value that controls should mesh tangent/bitangent be imported if available. */
  52. bool getImportTangents() const { return mImportTangents; }
  53. /** Sets a value that controls should mesh blend shapes be imported if available. */
  54. void setImportBlendShapes(bool import) { mImportBlendShapes = import; }
  55. /** Retrieves a value that controls should mesh blend shapes be imported if available. */
  56. bool getImportBlendShapes() const { return mImportBlendShapes; }
  57. /**
  58. * Sets a value that controls should mesh skin data like bone weights, indices and bind poses be imported if
  59. * available.
  60. */
  61. void setImportSkin(bool import) { mImportSkin = import; }
  62. /**
  63. * Retrieves a value that controls should mesh skin data like bone weights, indices and bind poses be imported if
  64. * available.
  65. */
  66. bool getImportSkin() const { return mImportSkin; }
  67. /** Sets a value that controls should animation clips be imported if available. */
  68. void setImportAnimation(bool import) { mImportAnimation = import; }
  69. /** Retrieves a value that controls should animation clips be imported if available. */
  70. bool getImportAnimation() const { return mImportAnimation; }
  71. /** Sets a value that will uniformly scale the imported mesh by the specified value. */
  72. void setImportScale(float import) { mImportScale = import; }
  73. /** Retrieves a value that will uniformly scale the imported mesh by the specified value. */
  74. float getImportScale() const { return mImportScale; }
  75. /** Sets a value that controls what type (if any) of collision mesh should be imported. */
  76. void setCollisionMeshType(CollisionMeshType type) { mCollisionMeshType = type; }
  77. /** Retrieves a value that controls what type (if any) of collision mesh should be imported. */
  78. CollisionMeshType getCollisionMeshType() const { return mCollisionMeshType; }
  79. /**
  80. * Registers an animation split info that determines how will the source animation clip be split. If not splits
  81. * are present the data will be imported as one clip, but if splits are present the data will be split according
  82. * to the split infos.
  83. */
  84. void addAnimationClipSplit(const AnimationSplitInfo& splitInfo) { mAnimationSplits.push_back(splitInfo); }
  85. /** Returns in how many pieces should the imported animation clip be split info. */
  86. UINT32 getNumAnimationClipSplits() const { return (UINT32)mAnimationSplits.size(); }
  87. /** Returns information about an animation split at the specified index. */
  88. const AnimationSplitInfo& getAnimationClipSplit(UINT32 idx) const { return mAnimationSplits[idx]; }
  89. /** Removes an animation split info at the specified index. */
  90. void removeAnimationClipSplit(UINT32 idx) { mAnimationSplits.erase(mAnimationSplits.begin() + idx); }
  91. /** Returns a copy of the animation splits array. */
  92. Vector<AnimationSplitInfo> getAnimationClipSplits() const { return mAnimationSplits; }
  93. private:
  94. bool mCPUReadable;
  95. bool mImportNormals;
  96. bool mImportTangents;
  97. bool mImportBlendShapes;
  98. bool mImportSkin;
  99. bool mImportAnimation;
  100. float mImportScale;
  101. CollisionMeshType mCollisionMeshType;
  102. Vector<AnimationSplitInfo> mAnimationSplits;
  103. /************************************************************************/
  104. /* SERIALIZATION */
  105. /************************************************************************/
  106. public:
  107. friend class MeshImportOptionsRTTI;
  108. static RTTITypeBase* getRTTIStatic();
  109. RTTITypeBase* getRTTI() const override;
  110. };
  111. /** @} */
  112. }