JointBall.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "StdAfx.h"
  2. #include <ode/ode.h>
  3. #include "jointball.h"
  4. namespace ODEManaged
  5. {
  6. //Constructors
  7. JointBall::JointBall(void) : Joint(){}
  8. JointBall::JointBall(World &world)
  9. {
  10. if(this->_id) dJointDestroy(this->_id);
  11. _id = dJointCreateBall(world.Id(), 0);
  12. }
  13. JointBall::JointBall(World &world, JointGroup &jointGroup)
  14. {
  15. if(this->_id) dJointDestroy(this->_id);
  16. _id = dJointCreateBall(world.Id(), jointGroup.Id());
  17. }
  18. //Destructor
  19. JointBall::~JointBall(void){}
  20. //Methods
  21. //Overloaded Create
  22. void JointBall::Create(World &world, JointGroup &jointGroup)
  23. {
  24. if(this->_id) dJointDestroy(this->_id);
  25. _id = dJointCreateBall(world.Id(), jointGroup.Id());
  26. }
  27. void JointBall::Create(World &world)
  28. {
  29. if(this->_id) dJointDestroy(this->_id);
  30. _id = dJointCreateBall(world.Id(), 0);
  31. }
  32. //Overloaded Attach
  33. void JointBall::Attach(Body &body1, Body &body2)
  34. {
  35. dJointAttach(this->_id, body1.Id(), body2.Id());
  36. }
  37. void JointBall::Attach(Body &body1)
  38. {
  39. dJointAttach(this->_id, body1.Id(), 0);
  40. }
  41. //SetAnchor
  42. void JointBall::SetAnchor(double x, double y ,double z)
  43. {
  44. dJointSetBallAnchor(this->_id, x, y, z);
  45. }
  46. //GetAnchor
  47. Vector3 JointBall::GetAnchor(void)
  48. {
  49. Vector3 retVal;
  50. dVector3 temp;
  51. dJointGetBallAnchor(this->_id,temp);
  52. retVal.x = temp[0];
  53. retVal.y = temp[1];
  54. retVal.z = temp[2];
  55. return retVal;
  56. }
  57. }