ConstraintPulley2D.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (c) 2008-2023 the Urho3D project
  2. // License: MIT
  3. #pragma once
  4. #include "../Physics2D/Constraint2D.h"
  5. namespace Urho3D
  6. {
  7. /// 2D pulley constraint component.
  8. class URHO3D_API ConstraintPulley2D : public Constraint2D
  9. {
  10. URHO3D_OBJECT(ConstraintPulley2D, Constraint2D);
  11. public:
  12. /// Construct.
  13. explicit ConstraintPulley2D(Context* context);
  14. /// Destruct.
  15. ~ConstraintPulley2D() override;
  16. /// Register object factory.
  17. /// @nobind
  18. static void RegisterObject(Context* context);
  19. /// Set other body ground anchor point.
  20. /// @property
  21. void SetOwnerBodyGroundAnchor(const Vector2& groundAnchor);
  22. /// Set other body ground anchor point.
  23. /// @property
  24. void SetOtherBodyGroundAnchor(const Vector2& groundAnchor);
  25. /// Set owner body anchor point.
  26. /// @property
  27. void SetOwnerBodyAnchor(const Vector2& anchor);
  28. /// Set other body anchor point.
  29. /// @property
  30. void SetOtherBodyAnchor(const Vector2& anchor);
  31. /// Set ratio.
  32. /// @property
  33. void SetRatio(float ratio);
  34. /// Return owner body ground anchor.
  35. /// @property
  36. const Vector2& GetOwnerBodyGroundAnchor() const { return ownerBodyGroundAnchor_; }
  37. /// return other body ground anchor.
  38. /// @property
  39. const Vector2& GetOtherBodyGroundAnchor() const { return otherBodyGroundAnchor_; }
  40. /// Return owner body anchor.
  41. /// @property
  42. const Vector2& GetOwnerBodyAnchor() const { return ownerBodyAnchor_; }
  43. /// Return other body anchor.
  44. /// @property
  45. const Vector2& GetOtherBodyAnchor() const { return otherBodyAnchor_; }
  46. /// Return ratio.
  47. /// @property
  48. float GetRatio() const { return jointDef_.ratio; }
  49. private:
  50. /// Return Joint def.
  51. b2JointDef* GetJointDef() override;
  52. /// Box2D joint def.
  53. b2PulleyJointDef jointDef_;
  54. /// Owner body ground anchor.
  55. Vector2 ownerBodyGroundAnchor_;
  56. /// Other body ground anchor.
  57. Vector2 otherBodyGroundAnchor_;
  58. /// Owner body anchor.
  59. Vector2 ownerBodyAnchor_;
  60. /// Other body anchor.
  61. Vector2 otherBodyAnchor_;
  62. };
  63. }