[216] | 1 | #include "StdAfx.h" |
---|
| 2 | |
---|
| 3 | #include <ode/ode.h> |
---|
| 4 | #include "jointhinge2.h" |
---|
| 5 | |
---|
| 6 | namespace ODEManaged |
---|
| 7 | { |
---|
| 8 | //Constructors |
---|
| 9 | JointHinge2::JointHinge2(void) : Joint(){} |
---|
| 10 | |
---|
| 11 | JointHinge2::JointHinge2(World &world) |
---|
| 12 | { |
---|
| 13 | if(this->_id) dJointDestroy(this->_id); |
---|
| 14 | _id = dJointCreateHinge2(world.Id(),0); |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | JointHinge2::JointHinge2(World &world, JointGroup &jointGroup) |
---|
| 18 | { |
---|
| 19 | if(this->_id) dJointDestroy(this->_id); |
---|
| 20 | _id = dJointCreateHinge2(world.Id(), jointGroup.Id()); |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | //Destructor |
---|
| 24 | JointHinge2::~JointHinge2(void){} |
---|
| 25 | |
---|
| 26 | //CreateHinge2 (overload 1) |
---|
| 27 | void JointHinge2::Create(World &world, JointGroup &jointGroup) |
---|
| 28 | { |
---|
| 29 | if(this->_id) dJointDestroy(this->_id); |
---|
| 30 | _id = dJointCreateHinge2(world.Id(), jointGroup.Id()); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | //CreateHinge2 (overload 2) |
---|
| 34 | void JointHinge2::Create(World &world) |
---|
| 35 | { |
---|
| 36 | if(this->_id) dJointDestroy(this->_id); |
---|
| 37 | _id = dJointCreateHinge2(world.Id(),0); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | //SetAnchor1 |
---|
| 41 | void JointHinge2::SetAnchor (double x, double y ,double z) |
---|
| 42 | { |
---|
| 43 | dJointSetHinge2Anchor(_id, x,y,z); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | //GetAnchor1 |
---|
| 47 | Vector3 JointHinge2::GetAnchor() |
---|
| 48 | { |
---|
| 49 | Vector3 retVal; |
---|
| 50 | dVector3 temp; |
---|
| 51 | dJointGetHinge2Anchor(_id,temp); |
---|
| 52 | retVal.x = temp[0]; |
---|
| 53 | retVal.y = temp[1]; |
---|
| 54 | retVal.z = temp[2]; |
---|
| 55 | return retVal; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | //SetAxis1 |
---|
| 59 | void JointHinge2::SetAxis1 (double x, double y ,double z) |
---|
| 60 | { |
---|
| 61 | dJointSetHinge2Axis1(_id, x,y,z); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | //GetAxis1 |
---|
| 65 | Vector3 JointHinge2::GetAxis1() |
---|
| 66 | { |
---|
| 67 | Vector3 retVal; |
---|
| 68 | dVector3 temp; |
---|
| 69 | dJointGetHinge2Axis1(_id,temp); |
---|
| 70 | retVal.x = temp[0]; |
---|
| 71 | retVal.y = temp[1]; |
---|
| 72 | retVal.z = temp[2]; |
---|
| 73 | return retVal; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | //SetAxis2 |
---|
| 77 | void JointHinge2::SetAxis2 (double x, double y ,double z) |
---|
| 78 | { |
---|
| 79 | dJointSetHinge2Axis2(_id, x,y,z); |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | //GetAxis2 |
---|
| 83 | Vector3 JointHinge2::GetAxis2() |
---|
| 84 | { |
---|
| 85 | Vector3 retVal; |
---|
| 86 | dVector3 temp; |
---|
| 87 | dJointGetHinge2Axis2(_id,temp); |
---|
| 88 | retVal.x = temp[0]; |
---|
| 89 | retVal.y = temp[1]; |
---|
| 90 | retVal.z = temp[2]; |
---|
| 91 | return retVal; |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | //GetAngle1 |
---|
| 95 | double JointHinge2::GetAngle1 () |
---|
| 96 | { |
---|
| 97 | return dJointGetHinge2Angle1(this->_id); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | //GetAngle1Rate |
---|
| 101 | double JointHinge2::GetAngle1Rate () |
---|
| 102 | { |
---|
| 103 | return dJointGetHinge2Angle1Rate(this->_id); |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | ////GetAngle hmm, this doesn't exist |
---|
| 107 | //double JointHinge2::GetAngle2 () |
---|
| 108 | //{ |
---|
| 109 | // return dJointGetHinge2Angle2(this->_id); |
---|
| 110 | //} |
---|
| 111 | |
---|
| 112 | //GetAngle2Rate |
---|
| 113 | double JointHinge2::GetAngle2Rate () |
---|
| 114 | { |
---|
| 115 | return dJointGetHinge2Angle2Rate(this->_id); |
---|
| 116 | } |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | //Attach (overload 1) |
---|
| 120 | void JointHinge2::Attach (Body &body1, Body &body2) |
---|
| 121 | { |
---|
| 122 | dJointAttach(_id, body1.Id(),body2.Id()); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | //Attach (overload 2) |
---|
| 126 | //TODO: possibly add an overload that takes anchor as a param also. |
---|
| 127 | void JointHinge2::Attach (Body &body1) |
---|
| 128 | { |
---|
| 129 | dJointAttach(_id, body1.Id(),0); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | } |
---|