BsJoint.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "BsFJoint.h"
  6. namespace BansheeEngine
  7. {
  8. class BS_CORE_EXPORT Joint
  9. {
  10. public:
  11. virtual ~Joint() { }
  12. inline Rigidbody* getBody(JointBody body) const;
  13. inline void setBody(JointBody body, Rigidbody* value);
  14. inline Vector3 getPosition(JointBody body) const;
  15. inline Quaternion getRotation(JointBody body) const;
  16. inline void setTransform(JointBody body, const Vector3& position, const Quaternion& rotation);
  17. inline float getBreakForce() const;
  18. inline void setBreakForce(float force);
  19. inline float getBreakTorque() const;
  20. inline void setBreakToque(float torque);
  21. inline bool getEnableCollision() const;
  22. inline void setEnableCollision(bool value);
  23. Event<void()> onJointBreak;
  24. protected:
  25. FJoint* mInternal = nullptr;
  26. };
  27. struct Spring
  28. {
  29. Spring() { }
  30. Spring(float stiffness, float damping)
  31. :stiffness(stiffness), damping(damping)
  32. { }
  33. float stiffness = 0.0f;
  34. float damping = 0.0f;
  35. };
  36. struct LimitLinearRange
  37. {
  38. LimitLinearRange()
  39. { }
  40. LimitLinearRange(float lower, float upper, float contactDist = -1.0f)
  41. :lower(lower), upper(upper), contactDist(contactDist)
  42. { }
  43. LimitLinearRange(float lower, float upper, const Spring& spring)
  44. :lower(lower), upper(upper), spring(spring)
  45. { }
  46. float lower = 0.0f;
  47. float upper = 0.0f;
  48. float contactDist = -1.0f;
  49. float restitution = 0.0f;
  50. Spring spring;
  51. };
  52. struct LimitLinear
  53. {
  54. LimitLinear()
  55. { }
  56. LimitLinear(float extent, float contactDist = -1.0f)
  57. :extent(extent), contactDist(contactDist)
  58. { }
  59. LimitLinear(float extent,const Spring& spring)
  60. :extent(extent), spring(spring)
  61. { }
  62. float extent = 0.0f;
  63. float contactDist = -1.0f;
  64. float restitution = 0.0f;
  65. Spring spring;
  66. };
  67. struct LimitAngularRange
  68. {
  69. LimitAngularRange()
  70. { }
  71. LimitAngularRange(Radian lower, Radian upper, float contactDist = -1.0f)
  72. :lower(lower), upper(upper), contactDist(contactDist)
  73. { }
  74. LimitAngularRange(Radian lower, Radian upper, const Spring& spring)
  75. :lower(lower), upper(upper), spring(spring)
  76. { }
  77. Radian lower = Radian(0.0f);
  78. Radian upper = Radian(0.0f);
  79. float contactDist = -1.0f;
  80. float restitution = 0.0f;
  81. Spring spring;
  82. };
  83. struct LimitConeRange
  84. {
  85. LimitConeRange()
  86. { }
  87. LimitConeRange(Radian yLimitAngle, Radian zLimitAngle, float contactDist = -1.0f)
  88. :yLimitAngle(yLimitAngle), zLimitAngle(zLimitAngle), contactDist(contactDist)
  89. { }
  90. LimitConeRange(Radian yLimitAngle, Radian zLimitAngle, const Spring& spring)
  91. :yLimitAngle(yLimitAngle), zLimitAngle(zLimitAngle), spring(spring)
  92. { }
  93. Radian yLimitAngle = Radian(Math::PI * 0.5f);
  94. Radian zLimitAngle = Radian(Math::PI * 0.5f);
  95. float contactDist = -1.0f;
  96. float restitution = 0.0f;
  97. Spring spring;
  98. };
  99. }