ConstraintFriction2D.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 friction constraint component.
  8. class URHO3D_API ConstraintFriction2D : public Constraint2D
  9. {
  10. URHO3D_OBJECT(ConstraintFriction2D, Constraint2D);
  11. public:
  12. /// Construct.
  13. explicit ConstraintFriction2D(Context* context);
  14. /// Destruct.
  15. ~ConstraintFriction2D() override;
  16. /// Register object factory.
  17. /// @nobind
  18. static void RegisterObject(Context* context);
  19. /// Set anchor.
  20. /// @property
  21. void SetAnchor(const Vector2& anchor);
  22. /// Set max force.
  23. /// @property
  24. void SetMaxForce(float maxForce);
  25. /// Set max torque.
  26. /// @property
  27. void SetMaxTorque(float maxTorque);
  28. /// Return anchor.
  29. /// @property
  30. const Vector2& GetAnchor() const { return anchor_; }
  31. /// Set max force.
  32. /// @property
  33. float GetMaxForce() const { return jointDef_.maxForce; }
  34. /// Set max torque.
  35. /// @property
  36. float GetMaxTorque() const { return jointDef_.maxTorque; }
  37. private:
  38. /// Return joint def.
  39. b2JointDef* GetJointDef() override;
  40. /// Box2D joint def.
  41. b2FrictionJointDef jointDef_;
  42. /// Anchor.
  43. Vector2 anchor_;
  44. };
  45. }