2
0

BsCBone.h 2.5 KB

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