BsCCapsuleCollider.h 2.7 KB

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