btMultiBodyGearConstraint.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. Bullet Continuous Collision Detection and Physics Library
  3. Copyright (c) 2013 Erwin Coumans http://bulletphysics.org
  4. This software is provided 'as-is', without any express or implied warranty.
  5. In no event will the authors be held liable for any damages arising from the use of this software.
  6. Permission is granted to anyone to use this software for any purpose,
  7. including commercial applications, and to alter it and redistribute it freely,
  8. subject to the following restrictions:
  9. 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  10. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  11. 3. This notice may not be removed or altered from any source distribution.
  12. */
  13. ///This file was written by Erwin Coumans
  14. #ifndef BT_MULTIBODY_GEAR_CONSTRAINT_H
  15. #define BT_MULTIBODY_GEAR_CONSTRAINT_H
  16. #include "btMultiBodyConstraint.h"
  17. class btMultiBodyGearConstraint : public btMultiBodyConstraint
  18. {
  19. protected:
  20. btRigidBody* m_rigidBodyA;
  21. btRigidBody* m_rigidBodyB;
  22. btVector3 m_pivotInA;
  23. btVector3 m_pivotInB;
  24. btMatrix3x3 m_frameInA;
  25. btMatrix3x3 m_frameInB;
  26. btScalar m_gearRatio;
  27. int m_gearAuxLink;
  28. btScalar m_erp;
  29. btScalar m_relativePositionTarget;
  30. public:
  31. //btMultiBodyGearConstraint(btMultiBody* body, int link, btRigidBody* bodyB, const btVector3& pivotInA, const btVector3& pivotInB, const btMatrix3x3& frameInA, const btMatrix3x3& frameInB);
  32. btMultiBodyGearConstraint(btMultiBody* bodyA, int linkA, btMultiBody* bodyB, int linkB, const btVector3& pivotInA, const btVector3& pivotInB, const btMatrix3x3& frameInA, const btMatrix3x3& frameInB);
  33. virtual ~btMultiBodyGearConstraint();
  34. virtual void finalizeMultiDof();
  35. virtual int getIslandIdA() const;
  36. virtual int getIslandIdB() const;
  37. virtual void createConstraintRows(btMultiBodyConstraintArray& constraintRows,
  38. btMultiBodyJacobianData& data,
  39. const btContactSolverInfo& infoGlobal);
  40. const btVector3& getPivotInA() const
  41. {
  42. return m_pivotInA;
  43. }
  44. void setPivotInA(const btVector3& pivotInA)
  45. {
  46. m_pivotInA = pivotInA;
  47. }
  48. const btVector3& getPivotInB() const
  49. {
  50. return m_pivotInB;
  51. }
  52. virtual void setPivotInB(const btVector3& pivotInB)
  53. {
  54. m_pivotInB = pivotInB;
  55. }
  56. const btMatrix3x3& getFrameInA() const
  57. {
  58. return m_frameInA;
  59. }
  60. void setFrameInA(const btMatrix3x3& frameInA)
  61. {
  62. m_frameInA = frameInA;
  63. }
  64. const btMatrix3x3& getFrameInB() const
  65. {
  66. return m_frameInB;
  67. }
  68. virtual void setFrameInB(const btMatrix3x3& frameInB)
  69. {
  70. m_frameInB = frameInB;
  71. }
  72. virtual void debugDraw(class btIDebugDraw* drawer)
  73. {
  74. //todo(erwincoumans)
  75. }
  76. virtual void setGearRatio(btScalar gearRatio)
  77. {
  78. m_gearRatio = gearRatio;
  79. }
  80. virtual void setGearAuxLink(int gearAuxLink)
  81. {
  82. m_gearAuxLink = gearAuxLink;
  83. }
  84. virtual void setRelativePositionTarget(btScalar relPosTarget)
  85. {
  86. m_relativePositionTarget = relPosTarget;
  87. }
  88. virtual void setErp(btScalar erp)
  89. {
  90. m_erp = erp;
  91. }
  92. };
  93. #endif //BT_MULTIBODY_GEAR_CONSTRAINT_H