| 1 | //************************************ bs::framework - Copyright 2018 Marko Pintera **************************************// |
| 2 | //*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********// |
| 3 | #pragma once |
| 4 | |
| 5 | #include "BsCorePrerequisites.h" |
| 6 | #include "Importer/BsImportOptions.h" |
| 7 | #include "Animation/BsAnimationClip.h" |
| 8 | |
| 9 | namespace bs |
| 10 | { |
| 11 | /** @addtogroup Importer |
| 12 | * @{ |
| 13 | */ |
| 14 | |
| 15 | /** Controls what type of collision mesh should be imported during mesh import. */ |
| 16 | enum class BS_SCRIPT_EXPORT(m:Importer,api:bsf,api:bed) CollisionMeshType |
| 17 | { |
| 18 | None, /**< No collision mesh will be imported. */ |
| 19 | Normal, /**< Normal triangle mesh will be imported. */ |
| 20 | Convex /**< A convex hull will be generated from the source mesh. */ |
| 21 | }; |
| 22 | |
| 23 | /** Information about how to split an AnimationClip into multiple separate clips. */ |
| 24 | struct BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Importer,api:bsf,api:bed) AnimationSplitInfo : IReflectable |
| 25 | { |
| 26 | BS_SCRIPT_EXPORT() |
| 27 | AnimationSplitInfo() = default; |
| 28 | |
| 29 | BS_SCRIPT_EXPORT() |
| 30 | AnimationSplitInfo(const String& name, UINT32 startFrame, UINT32 endFrame, bool isAdditive = false) |
| 31 | : name(name), startFrame(startFrame), endFrame(endFrame), isAdditive(isAdditive) |
| 32 | { } |
| 33 | |
| 34 | BS_SCRIPT_EXPORT() |
| 35 | String name; |
| 36 | |
| 37 | BS_SCRIPT_EXPORT() |
| 38 | UINT32 startFrame = 0; |
| 39 | |
| 40 | BS_SCRIPT_EXPORT() |
| 41 | UINT32 endFrame = 0; |
| 42 | |
| 43 | BS_SCRIPT_EXPORT() |
| 44 | bool isAdditive = false; |
| 45 | |
| 46 | /************************************************************************/ |
| 47 | /* SERIALIZATION */ |
| 48 | /************************************************************************/ |
| 49 | public: |
| 50 | friend class AnimationSplitInfoRTTI; |
| 51 | static RTTITypeBase* getRTTIStatic(); |
| 52 | RTTITypeBase* getRTTI() const override; |
| 53 | }; |
| 54 | |
| 55 | /** A set of animation events that will be added to an animation clip during animation import. */ |
| 56 | struct BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Importer,api:bsf,api:bed) ImportedAnimationEvents : IReflectable |
| 57 | { |
| 58 | BS_SCRIPT_EXPORT() |
| 59 | ImportedAnimationEvents() = default; |
| 60 | |
| 61 | BS_SCRIPT_EXPORT() |
| 62 | String name; |
| 63 | |
| 64 | BS_SCRIPT_EXPORT() |
| 65 | Vector<AnimationEvent> events; |
| 66 | |
| 67 | /************************************************************************/ |
| 68 | /* SERIALIZATION */ |
| 69 | /************************************************************************/ |
| 70 | public: |
| 71 | friend class ImportedAnimationEventsRTTI; |
| 72 | static RTTITypeBase* getRTTIStatic(); |
| 73 | RTTITypeBase* getRTTI() const override; |
| 74 | }; |
| 75 | |
| 76 | /** |
| 77 | * Contains import options you may use to control how is a mesh imported from some external format into engine format. |
| 78 | */ |
| 79 | class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Importer,api:bsf,api:bed) MeshImportOptions : public ImportOptions |
| 80 | { |
| 81 | public: |
| 82 | MeshImportOptions() = default; |
| 83 | |
| 84 | /** Determines whether the texture data is also stored in CPU memory. */ |
| 85 | BS_SCRIPT_EXPORT() |
| 86 | bool cpuCached = false; |
| 87 | |
| 88 | /** Determines should mesh normals be imported if available. */ |
| 89 | BS_SCRIPT_EXPORT() |
| 90 | bool importNormals = true; |
| 91 | |
| 92 | /** Determines should mesh tangents and bitangents be imported if available. */ |
| 93 | BS_SCRIPT_EXPORT() |
| 94 | bool importTangents = true; |
| 95 | |
| 96 | /** Determines should mesh blend shapes be imported if available. */ |
| 97 | BS_SCRIPT_EXPORT() |
| 98 | bool importBlendShapes = false; |
| 99 | |
| 100 | /** Determines should mesh skin data like bone weights, indices and bind poses be imported if available. */ |
| 101 | BS_SCRIPT_EXPORT() |
| 102 | bool importSkin = false; |
| 103 | |
| 104 | /** Determines should animation clips be imported if available. */ |
| 105 | BS_SCRIPT_EXPORT() |
| 106 | bool importAnimation = false; |
| 107 | |
| 108 | /** |
| 109 | * Enables or disables keyframe reduction. Keyframe reduction will reduce the number of key-frames in an animation |
| 110 | * clip by removing identical keyframes, and therefore reducing the size of the clip. |
| 111 | */ |
| 112 | BS_SCRIPT_EXPORT() |
| 113 | bool reduceKeyFrames = true; |
| 114 | |
| 115 | /** |
| 116 | * Enables or disables import of root motion curves. When enabled, any animation curves in imported animations |
| 117 | * affecting the root bone will be available through a set of separate curves in AnimationClip, and they won't be |
| 118 | * evaluated through normal animation process. Instead it is expected that the user evaluates the curves manually |
| 119 | * and applies them as required. |
| 120 | */ |
| 121 | BS_SCRIPT_EXPORT() |
| 122 | bool importRootMotion = false; |
| 123 | |
| 124 | /** Uniformly scales the imported mesh by the specified value. */ |
| 125 | BS_SCRIPT_EXPORT() |
| 126 | float importScale = 1.0f; |
| 127 | |
| 128 | /** |
| 129 | * Determines what type (if any) of collision mesh should be imported. If enabled the collision mesh will be |
| 130 | * available as a sub-resource returned by the importer (along with the normal mesh). |
| 131 | */ |
| 132 | BS_SCRIPT_EXPORT() |
| 133 | CollisionMeshType collisionMeshType = CollisionMeshType::None; |
| 134 | |
| 135 | /** |
| 136 | * Animation split infos that determine how will the source animation clip be split. If no splits are present the |
| 137 | * data will be imported as one clip, but if splits are present the data will be split according to the split infos. |
| 138 | * Split infos only affect the primary animation clip, other clips will not be split. |
| 139 | */ |
| 140 | BS_SCRIPT_EXPORT() |
| 141 | Vector<AnimationSplitInfo> animationSplits; |
| 142 | |
| 143 | /** Set of events that will be added to the animation clip, if animation import is enabled. */ |
| 144 | BS_SCRIPT_EXPORT() |
| 145 | Vector<ImportedAnimationEvents> animationEvents; |
| 146 | |
| 147 | /** Creates a new import options object that allows you to customize how are meshes imported. */ |
| 148 | BS_SCRIPT_EXPORT(ec:T) |
| 149 | static SPtr<MeshImportOptions> create(); |
| 150 | |
| 151 | /************************************************************************/ |
| 152 | /* SERIALIZATION */ |
| 153 | /************************************************************************/ |
| 154 | public: |
| 155 | friend class MeshImportOptionsRTTI; |
| 156 | static RTTITypeBase* getRTTIStatic(); |
| 157 | RTTITypeBase* getRTTI() const override; |
| 158 | }; |
| 159 | |
| 160 | /** @} */ |
| 161 | } |