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