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 "Scene/BsComponent.h" |
7 | |
8 | namespace bs |
9 | { |
10 | /** @addtogroup Components-Core |
11 | * @{ |
12 | */ |
13 | |
14 | /** |
15 | * Component that maps animation for specific bone also be applied to the SceneObject this component is attached to. |
16 | * The component will attach to the first found parent Animation component. |
17 | */ |
18 | class BS_CORE_EXPORT BS_SCRIPT_EXPORT(m:Animation,n:Bone) CBone : public Component |
19 | { |
20 | public: |
21 | CBone(const HSceneObject& parent); |
22 | virtual ~CBone() = default; |
23 | |
24 | /** Determines the name of the bone the component is referencing. */ |
25 | BS_SCRIPT_EXPORT(n:Name,pr:setter) |
26 | void setBoneName(const String& name); |
27 | |
28 | /** @copydoc setBoneName */ |
29 | BS_SCRIPT_EXPORT(n:Name,pr:getter) |
30 | const String& getBoneName() const { return mBoneName; } |
31 | |
32 | /** @name Internal |
33 | * @{ |
34 | */ |
35 | |
36 | /** |
37 | * Changes the parent animation of this component. |
38 | * |
39 | * @param[in] animation New animation parent, can be null. |
40 | * @param[in] isInternal If true the bone will just be changed internally, but parent animation will not be |
41 | * notified. |
42 | */ |
43 | void _setParent(const HAnimation& animation, bool isInternal = false); |
44 | |
45 | /** @} */ |
46 | private: |
47 | /** Attempts to find the parent Animation component and registers itself with it. */ |
48 | void updateParentAnimation(); |
49 | |
50 | /************************************************************************/ |
51 | /* COMPONENT OVERRIDES */ |
52 | /************************************************************************/ |
53 | protected: |
54 | friend class SceneObject; |
55 | |
56 | /** @copydoc Component::onDestroyed() */ |
57 | void onDestroyed() override; |
58 | |
59 | /** @copydoc Component::onDisabled() */ |
60 | void onDisabled() override; |
61 | |
62 | /** @copydoc Component::onEnabled() */ |
63 | void onEnabled() override; |
64 | |
65 | /** @copydoc Component::onTransformChanged() */ |
66 | void onTransformChanged(TransformChangedFlags flags) override; |
67 | protected: |
68 | using Component::destroyInternal; |
69 | |
70 | String mBoneName; |
71 | HAnimation mParent; |
72 | |
73 | /************************************************************************/ |
74 | /* RTTI */ |
75 | /************************************************************************/ |
76 | public: |
77 | friend class CBoneRTTI; |
78 | static RTTITypeBase* getRTTIStatic(); |
79 | RTTITypeBase* getRTTI() const override; |
80 | |
81 | protected: |
82 | CBone(); // Serialization only |
83 | }; |
84 | |
85 | /** @} */ |
86 | } |