BsFJoint.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 "BsVector3.h"
  6. #include "BsQuaternion.h"
  7. namespace BansheeEngine
  8. {
  9. /** @addtogroup Physics
  10. * @{
  11. */
  12. /** Specifies first or second body referenced by a Joint. */
  13. enum class JointBody
  14. {
  15. Target, /**< Body the joint is influencing. */
  16. Anchor /**< Body the joint is attached to (if any). */
  17. };
  18. /** @} */
  19. /** @addtogroup Physics-Internal
  20. * @{
  21. */
  22. /** Provides common functionality used by all Joint types. */
  23. class BS_CORE_EXPORT FJoint
  24. {
  25. public:
  26. FJoint(const JOINT_DESC& desc) { }
  27. virtual ~FJoint() { }
  28. /** Returns one of the bodies managed by the joint. */
  29. virtual Rigidbody* getBody(JointBody body) const = 0;
  30. /** Sets a body managed by the joint. One of the bodies must be movable (non-kinematic). */
  31. virtual void setBody(JointBody body, Rigidbody* value) = 0;
  32. /** Returns the position relative to the body, at which the body is anchored to the joint. */
  33. virtual Vector3 getPosition(JointBody body) const = 0;
  34. /** Returns the rotation relative to the body, at which the body is anchored to the joint. */
  35. virtual Quaternion getRotation(JointBody body) const = 0;
  36. /** Sets the position and rotation relative to the body, at which the body is anchored to the joint. */
  37. virtual void setTransform(JointBody body, const Vector3& position, const Quaternion& rotation) = 0;
  38. /**
  39. * Returns the maximum force the joint can apply before breaking. Broken joints no longer participate in physics
  40. * simulation.
  41. */
  42. virtual float getBreakForce() const = 0;
  43. /**
  44. * Sets the maximum force the joint can apply before breaking. Broken joints no longer participate in physics
  45. * simulation.
  46. */
  47. virtual void setBreakForce(float force) = 0;
  48. /**
  49. * Returns the maximum torque the joint can apply before breaking. Broken joints no longer participate in physics
  50. * simulation.
  51. */
  52. virtual float getBreakTorque() const = 0;
  53. /**
  54. * Sets the maximum torque the joint can apply before breaking. Broken joints no longer participate in physics
  55. * simulation.
  56. */
  57. virtual void setBreakTorque(float torque) = 0;
  58. /** Checks whether collisions between the two bodies managed by the joint are enabled. */
  59. virtual bool getEnableCollision() const = 0;
  60. /** Sets whether collision between the two bodies managed by the joint are enabled. */
  61. virtual void setEnableCollision(bool value) = 0;
  62. };
  63. /** @} */
  64. }