BsCBone.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 CBone : public Component
  16. {
  17. public:
  18. CBone(const HSceneObject& parent);
  19. virtual ~CBone() {}
  20. /** Changes the name of the bone the component is referencing. */
  21. void setBoneName(const String& name);
  22. /** Returns the name of the bone the component is referencing. */
  23. const String& getBoneName() const { return mBoneName; }
  24. /** @name Internal
  25. * @{
  26. */
  27. /**
  28. * Changes the parent animation of this component.
  29. *
  30. * @param[in] animation New animation parent, can be null.
  31. * @param[in] isInternal If true the bone will just be changed internally, but parent animation will not be
  32. * notified.
  33. */
  34. void _setParent(const HAnimation& animation, bool isInternal = false);
  35. /** @} */
  36. private:
  37. /** Attempts to find the parent Animation component and registers itself with it. */
  38. void updateParentAnimation();
  39. /************************************************************************/
  40. /* COMPONENT OVERRIDES */
  41. /************************************************************************/
  42. protected:
  43. friend class SceneObject;
  44. /** @copydoc Component::onDestroyed() */
  45. void onDestroyed() override;
  46. /** @copydoc Component::onDisabled() */
  47. void onDisabled() override;
  48. /** @copydoc Component::onEnabled() */
  49. void onEnabled() override;
  50. /** @copydoc Component::onTransformChanged() */
  51. void onTransformChanged(TransformChangedFlags flags) override;
  52. protected:
  53. using Component::destroyInternal;
  54. String mBoneName;
  55. HAnimation mParent;
  56. /************************************************************************/
  57. /* RTTI */
  58. /************************************************************************/
  59. public:
  60. friend class CBoneRTTI;
  61. static RTTITypeBase* getRTTIStatic();
  62. RTTITypeBase* getRTTI() const override;
  63. protected:
  64. CBone() {} // Serialization only
  65. };
  66. /** @} */
  67. }