1 | #include "StdAfx.h" |
---|
2 | |
---|
3 | #include <ode/ode.h> |
---|
4 | #include "jointslider.h" |
---|
5 | |
---|
6 | namespace ODEManaged |
---|
7 | { |
---|
8 | |
---|
9 | //Constructors |
---|
10 | |
---|
11 | JointSlider::JointSlider(void) : Joint(){} |
---|
12 | |
---|
13 | |
---|
14 | JointSlider::JointSlider(World &world) |
---|
15 | { |
---|
16 | if(this->_id) dJointDestroy(this->_id); |
---|
17 | _id = dJointCreateSlider(world.Id(), 0); |
---|
18 | } |
---|
19 | |
---|
20 | |
---|
21 | JointSlider::JointSlider(World &world, JointGroup &jointGroup) |
---|
22 | { |
---|
23 | if(this->_id) dJointDestroy(this->_id); |
---|
24 | _id = dJointCreateSlider(world.Id(), jointGroup.Id()); |
---|
25 | } |
---|
26 | |
---|
27 | |
---|
28 | //Destructor |
---|
29 | |
---|
30 | JointSlider::~JointSlider(void){} |
---|
31 | |
---|
32 | |
---|
33 | //Methods |
---|
34 | |
---|
35 | //Overloaded Create |
---|
36 | void JointSlider::Create(World &world, JointGroup &jointGroup) |
---|
37 | { |
---|
38 | if(this->_id) dJointDestroy(this->_id); |
---|
39 | _id = dJointCreateSlider(world.Id(), jointGroup.Id()); |
---|
40 | } |
---|
41 | |
---|
42 | void JointSlider::Create(World &world) |
---|
43 | { |
---|
44 | if(this->_id) dJointDestroy(this->_id); |
---|
45 | _id = dJointCreateSlider(world.Id(), 0); |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | //Overloaded Attach |
---|
50 | void JointSlider::Attach(Body &body1, Body &body2) |
---|
51 | { |
---|
52 | dJointAttach(this->_id, body1.Id(), body2.Id()); |
---|
53 | } |
---|
54 | |
---|
55 | void JointSlider::Attach(Body &body1) |
---|
56 | { |
---|
57 | dJointAttach(this->_id, body1.Id(), 0); |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | //SetAxis |
---|
62 | void JointSlider::SetAxis(double x, double y, double z) |
---|
63 | { |
---|
64 | dJointSetSliderAxis(this->_id, x, y, z); |
---|
65 | } |
---|
66 | |
---|
67 | //GetAxis |
---|
68 | Vector3 JointSlider::GetAxis(void) |
---|
69 | { |
---|
70 | Vector3 retVal; |
---|
71 | dVector3 temp; |
---|
72 | dJointGetSliderAxis(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 | //Movement Parameters |
---|
81 | |
---|
82 | //SetAllMovParams |
---|
83 | void JointSlider::SetAllMovParams(double LoStop, double HiStop, |
---|
84 | double Velocity, double MaxForce, |
---|
85 | double FudgeFactor, double Bounce, |
---|
86 | double StopERP, double StopCFM) |
---|
87 | { |
---|
88 | if (LoStop <= 0) |
---|
89 | dJointSetHingeParam(this->_id, dParamLoStop, LoStop); |
---|
90 | |
---|
91 | if (HiStop >= 0) |
---|
92 | dJointSetHingeParam(this->_id, dParamHiStop, HiStop); |
---|
93 | |
---|
94 | dJointSetSliderParam(this->_id, dParamVel, Velocity); |
---|
95 | dJointSetSliderParam(this->_id, dParamFMax, MaxForce); |
---|
96 | dJointSetSliderParam(this->_id, dParamFudgeFactor, FudgeFactor); |
---|
97 | dJointSetSliderParam(this->_id, dParamBounce, Bounce); |
---|
98 | dJointSetSliderParam(this->_id, dParamStopERP, StopERP); |
---|
99 | dJointSetSliderParam(this->_id, dParamStopCFM, StopCFM); |
---|
100 | } |
---|
101 | |
---|
102 | } |
---|