Fixed: A fix by Francesco Cat applied (mistakes made during code style improvements...
[ode.git] / contrib / DotNetManaged / JointHinge.cpp
blob85d420bdffc4a14231293eb5de1174c64cc7509c
1 #include "stdafx.h"
3 #include <ode/ode.h>
4 #include "jointhinge.h"
6 namespace ODEManaged
9 //Constructors
11 JointHinge::JointHinge(void) : Joint(){}
14 JointHinge::JointHinge(World &world)
16 if(this->_id) dJointDestroy(this->_id);
17 _id = dJointCreateHinge(world.Id(), 0);
21 JointHinge::JointHinge(World &world, JointGroup &jointGroup)
23 if(this->_id) dJointDestroy(this->_id);
24 _id = dJointCreateHinge(world.Id(), jointGroup.Id());
28 //Destructor
30 JointHinge::~JointHinge(void){}
33 //Methods
35 //Overloaded Create
36 void JointHinge::Create(World &world, JointGroup &jointGroup)
38 if(this->_id) dJointDestroy(this->_id);
39 _id = dJointCreateHinge(world.Id(), jointGroup.Id());
42 void JointHinge::Create(World &world)
44 if(this->_id) dJointDestroy(this->_id);
45 _id = dJointCreateHinge(world.Id(), 0);
49 //Overloaded Attach
50 void JointHinge::Attach(Body &body1, Body &body2)
52 dJointAttach(this->_id, body1.Id(), body2.Id());
55 void JointHinge::Attach(Body &body1)
57 dJointAttach(this->_id, body1.Id(), 0);
61 //SetAxis
62 void JointHinge::SetAxis(double x, double y, double z)
64 dJointSetHingeAxis(this->_id, x, y, z);
67 //GetAxis
68 Vector3 JointHinge::GetAxis(void)
70 Vector3 retVal;
71 dVector3 temp;
72 dJointGetHingeAxis(this->_id, temp);
73 retVal.x = temp[0];
74 retVal.y = temp[1];
75 retVal.z = temp[2];
76 return retVal;
80 //SetAnchor
81 void JointHinge::SetAnchor(double x, double y, double z)
83 dJointSetHingeAnchor(this->_id, x, y, z);
86 //GetAnchor
87 Vector3 JointHinge::GetAnchor(void)
89 Vector3 retVal;
90 dVector3 temp;
91 dJointGetHingeAnchor(this->_id, temp);
92 retVal.x = temp[0];
93 retVal.y = temp[1];
94 retVal.z = temp[2];
95 return retVal;
99 //Movement Parameters
101 //SetAllMovParams
102 void JointHinge::SetAllMovParams(double LoStop, double HiStop,
103 double Velocity, double MaxForce,
104 double FudgeFactor, double Bounce,
105 double StopERP, double StopCFM)
107 if (LoStop > -3.141592653 && LoStop <= 0)
108 dJointSetHingeParam(this->_id, dParamLoStop, LoStop);
110 if (HiStop < 3.141592653 && HiStop >= 0)
111 dJointSetHingeParam(this->_id, dParamHiStop, HiStop);
113 dJointSetHingeParam(this->_id, dParamVel, Velocity);
114 dJointSetHingeParam(this->_id, dParamFMax, MaxForce);
115 dJointSetHingeParam(this->_id, dParamFudgeFactor, FudgeFactor);
116 dJointSetHingeParam(this->_id, dParamBounce, Bounce);
117 dJointSetHingeParam(this->_id, dParamStopERP, StopERP);
118 dJointSetHingeParam(this->_id, dParamStopCFM, StopCFM);