BsCCapsuleCollider.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "BsCapsuleCollider.h"
  6. #include "BsCCollider.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Components-Core
  10. * @{
  11. */
  12. /**
  13. * @copydoc CapsuleCollider
  14. *
  15. * Wraps CapsuleCollider as a Component.
  16. */
  17. class BS_CORE_EXPORT CCapsuleCollider : public CCollider
  18. {
  19. public:
  20. CCapsuleCollider(const HSceneObject& parent, float radius = 1.0f, float halfHeight = 0.5f);
  21. /** Sets the normal vector of the capsule. It determines how is the capsule oriented. */
  22. void setNormal(const Vector3& normal);
  23. /** Gets the normal vector of the capsule. It determines how is the capsule oriented. */
  24. Vector3 getNormal() const { return mNormal; }
  25. /** Sets the position of the capsule shape, relative to the component's scene object. */
  26. void setCenter(const Vector3& center);
  27. /** Gets the position of the capsule shape, relative to the component's scene object. */
  28. Vector3 getCenter() const { return mLocalPosition; }
  29. /** @copydoc CapsuleCollider::setHalfHeight() */
  30. void setHalfHeight(float halfHeight);
  31. /** @copydoc CapsuleCollider::getHalfHeight() */
  32. float getHalfHeight() const { return mHalfHeight; }
  33. /** @copydoc CapsuleCollider::setRadius() */
  34. void setRadius(float radius);
  35. /** @copydoc CapsuleCollider::getRadius() */
  36. float getRadius() const { return mRadius; }
  37. /** @cond INTERNAL */
  38. /** Returns the capsule collider that this component wraps. */
  39. CapsuleCollider* _getInternal() const { return static_cast<CapsuleCollider*>(mInternal.get()); }
  40. /** @endcond */
  41. /************************************************************************/
  42. /* COMPONENT OVERRIDES */
  43. /************************************************************************/
  44. protected:
  45. friend class SceneObject;
  46. /** @copydoc CCollider::createInternal */
  47. SPtr<Collider> createInternal() override;
  48. protected:
  49. Vector3 mNormal = Vector3::UNIT_Y;
  50. float mRadius = 1.0f;
  51. float mHalfHeight = 0.5f;
  52. /************************************************************************/
  53. /* RTTI */
  54. /************************************************************************/
  55. public:
  56. friend class CCapsuleColliderRTTI;
  57. static RTTITypeBase* getRTTIStatic();
  58. RTTITypeBase* getRTTI() const override;
  59. protected:
  60. CCapsuleCollider() {} // Serialization only
  61. };
  62. /** @} */
  63. }