BsCCapsuleCollider.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. /** @name Internal
  38. * @{
  39. */
  40. /** Returns the capsule collider that this component wraps. */
  41. CapsuleCollider* _getInternal() const { return static_cast<CapsuleCollider*>(mInternal.get()); }
  42. /** @} */
  43. /************************************************************************/
  44. /* COMPONENT OVERRIDES */
  45. /************************************************************************/
  46. protected:
  47. friend class SceneObject;
  48. /** @copydoc CCollider::createInternal */
  49. SPtr<Collider> createInternal() override;
  50. protected:
  51. Vector3 mNormal = Vector3::UNIT_Y;
  52. float mRadius = 1.0f;
  53. float mHalfHeight = 0.5f;
  54. /************************************************************************/
  55. /* RTTI */
  56. /************************************************************************/
  57. public:
  58. friend class CCapsuleColliderRTTI;
  59. static RTTITypeBase* getRTTIStatic();
  60. RTTITypeBase* getRTTI() const override;
  61. protected:
  62. CCapsuleCollider() {} // Serialization only
  63. };
  64. /** @} */
  65. }