aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp
diff options
context:
space:
mode:
authordan miller2007-10-19 05:24:38 +0000
committerdan miller2007-10-19 05:24:38 +0000
commitf205de7847da7ae1c10212d82e7042d0100b4ce0 (patch)
tree9acc9608a6880502aaeda43af52c33e278e95b9c /libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp
parenttrying to fix my screwup part deux (diff)
downloadopensim-SC_OLD-f205de7847da7ae1c10212d82e7042d0100b4ce0.zip
opensim-SC_OLD-f205de7847da7ae1c10212d82e7042d0100b4ce0.tar.gz
opensim-SC_OLD-f205de7847da7ae1c10212d82e7042d0100b4ce0.tar.bz2
opensim-SC_OLD-f205de7847da7ae1c10212d82e7042d0100b4ce0.tar.xz
from the start... checking in ode-0.9
Diffstat (limited to 'libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp')
-rw-r--r--libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp121
1 files changed, 121 insertions, 0 deletions
diff --git a/libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp b/libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp
new file mode 100644
index 0000000..85d420b
--- /dev/null
+++ b/libraries/ode-0.9/contrib/DotNetManaged/JointHinge.cpp
@@ -0,0 +1,121 @@
1#include "stdafx.h"
2
3#include <ode/ode.h>
4#include "jointhinge.h"
5
6namespace ODEManaged
7{
8
9 //Constructors
10
11 JointHinge::JointHinge(void) : Joint(){}
12
13
14 JointHinge::JointHinge(World &world)
15 {
16 if(this->_id) dJointDestroy(this->_id);
17 _id = dJointCreateHinge(world.Id(), 0);
18 }
19
20
21 JointHinge::JointHinge(World &world, JointGroup &jointGroup)
22 {
23 if(this->_id) dJointDestroy(this->_id);
24 _id = dJointCreateHinge(world.Id(), jointGroup.Id());
25 }
26
27
28 //Destructor
29
30 JointHinge::~JointHinge(void){}
31
32
33 //Methods
34
35 //Overloaded Create
36 void JointHinge::Create(World &world, JointGroup &jointGroup)
37 {
38 if(this->_id) dJointDestroy(this->_id);
39 _id = dJointCreateHinge(world.Id(), jointGroup.Id());
40 }
41
42 void JointHinge::Create(World &world)
43 {
44 if(this->_id) dJointDestroy(this->_id);
45 _id = dJointCreateHinge(world.Id(), 0);
46 }
47
48
49 //Overloaded Attach
50 void JointHinge::Attach(Body &body1, Body &body2)
51 {
52 dJointAttach(this->_id, body1.Id(), body2.Id());
53 }
54
55 void JointHinge::Attach(Body &body1)
56 {
57 dJointAttach(this->_id, body1.Id(), 0);
58 }
59
60
61 //SetAxis
62 void JointHinge::SetAxis(double x, double y, double z)
63 {
64 dJointSetHingeAxis(this->_id, x, y, z);
65 }
66
67 //GetAxis
68 Vector3 JointHinge::GetAxis(void)
69 {
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;
77 }
78
79
80 //SetAnchor
81 void JointHinge::SetAnchor(double x, double y, double z)
82 {
83 dJointSetHingeAnchor(this->_id, x, y, z);
84 }
85
86 //GetAnchor
87 Vector3 JointHinge::GetAnchor(void)
88 {
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;
96 }
97
98
99 //Movement Parameters
100
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)
106 {
107 if (LoStop > -3.141592653 && LoStop <= 0)
108 dJointSetHingeParam(this->_id, dParamLoStop, LoStop);
109
110 if (HiStop < 3.141592653 && HiStop >= 0)
111 dJointSetHingeParam(this->_id, dParamHiStop, HiStop);
112
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);
119 }
120
121}