Panda3D
odeHinge2Joint.I
1 // Filename: odeHinge2Joint.I
2 // Created by: joswilso (27Dec06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 INLINE void OdeHinge2Joint::
17 set_anchor(dReal x, dReal y, dReal z) {
18  dJointSetHinge2Anchor(_id, x, y, z);
19 }
20 
21 INLINE void OdeHinge2Joint::
22 set_anchor(const LVecBase3f &anchor) {
23  dJointSetHinge2Anchor(_id, anchor[0], anchor[1], anchor[2]);
24 }
25 
26 INLINE void OdeHinge2Joint::
27 set_axis1(dReal x, dReal y, dReal z) {
28  dJointSetHinge2Axis1(_id, x, y, z);
29 }
30 
31 INLINE void OdeHinge2Joint::
32 set_axis1(const LVecBase3f &axis) {
33  dJointSetHinge2Axis1(_id, axis[0], axis[1], axis[2]);
34 }
35 
36 INLINE void OdeHinge2Joint::
37 set_axis2(dReal x, dReal y, dReal z) {
38  dJointSetHinge2Axis2(_id, x, y, z);
39 }
40 
41 INLINE void OdeHinge2Joint::
42 set_axis2(const LVecBase3f &axis) {
43  dJointSetHinge2Axis2(_id, axis[0], axis[1], axis[2]);
44 }
45 
46 INLINE void OdeHinge2Joint::
47 add_torques(dReal torque1, dReal torque2) {
48  dJointAddHinge2Torques(_id, torque1, torque2);
49 }
50 
51 INLINE LVecBase3f OdeHinge2Joint::
52 get_anchor() const {
53  dVector3 result;
54  dJointGetHinge2Anchor(_id, result);
55  return LVecBase3f(result[0], result[1], result[2]);
56 }
57 
58 INLINE LVecBase3f OdeHinge2Joint::
59 get_anchor2() const {
60  dVector3 result;
61  dJointGetHinge2Anchor2(_id, result);
62  return LVecBase3f(result[0], result[1], result[2]);
63 }
64 
65 INLINE LVecBase3f OdeHinge2Joint::
66 get_axis1() const {
67  dVector3 result;
68  dJointGetHinge2Axis1(_id, result);
69  return LVecBase3f(result[0], result[1], result[2]);
70 }
71 
72 INLINE LVecBase3f OdeHinge2Joint::
73 get_axis2() const {
74  dVector3 result;
75  dJointGetHinge2Axis2(_id, result);
76  return LVecBase3f(result[0], result[1], result[2]);
77 }
78 
79 INLINE dReal OdeHinge2Joint::
80 get_angle1() const {
81  return dJointGetHinge2Angle1(_id);
82 }
83 
84 INLINE dReal OdeHinge2Joint::
85 get_angle1_rate() const {
86  return dJointGetHinge2Angle1Rate(_id);
87 }
88 
89 INLINE dReal OdeHinge2Joint::
90 get_angle2_rate() const {
91  return dJointGetHinge2Angle2Rate(_id);
92 }
93 
94 INLINE void OdeHinge2Joint::
95 set_param_lo_stop(int axis, dReal val) {
96  nassertv( _id != 0 );
97  nassertv( 0 <= axis && axis <= 1 );
98  if ( axis == 0 ) {
99  dJointSetHinge2Param(_id, dParamLoStop, val);
100  } else if ( axis == 1 ) {
101  dJointSetHinge2Param(_id, dParamLoStop2, val);
102  }
103 }
104 
105 INLINE void OdeHinge2Joint::
106 set_param_hi_stop(int axis, dReal val) {
107  nassertv( _id != 0 );
108  nassertv( 0 <= axis && axis <= 1 );
109  if ( axis == 0 ) {
110  dJointSetHinge2Param(_id, dParamHiStop, val);
111  } else if ( axis == 1 ) {
112  dJointSetHinge2Param(_id, dParamHiStop2, val);
113  }
114 }
115 
116 INLINE void OdeHinge2Joint::
117 set_param_vel(int axis, dReal val) {
118  nassertv( _id != 0 );
119  nassertv( 0 <= axis && axis <= 1 );
120  if ( axis == 0 ) {
121  dJointSetHinge2Param(_id, dParamVel, val);
122  } else if ( axis == 1 ) {
123  dJointSetHinge2Param(_id, dParamVel2, val);
124  }
125 }
126 
127 INLINE void OdeHinge2Joint::
128 set_param_f_max(int axis, dReal val) {
129  nassertv( _id != 0 );
130  nassertv( 0 <= axis && axis <= 1 );
131  if ( axis == 0 ) {
132  dJointSetHinge2Param(_id, dParamFMax, val);
133  } else if ( axis == 1 ) {
134  dJointSetHinge2Param(_id, dParamFMax2, val);
135  }
136 }
137 
138 INLINE void OdeHinge2Joint::
139 set_param_fudge_factor(int axis, dReal val) {
140  nassertv( _id != 0 );
141  nassertv( 0 <= axis && axis <= 1 );
142  if ( axis == 0 ) {
143  dJointSetHinge2Param(_id, dParamFudgeFactor, val);
144  } else if ( axis == 1 ) {
145  dJointSetHinge2Param(_id, dParamFudgeFactor2, val);
146  }
147 }
148 
149 INLINE void OdeHinge2Joint::
150 set_param_bounce(int axis, dReal val) {
151  nassertv( _id != 0 );
152  nassertv( 0 <= axis && axis <= 1 );
153  if ( axis == 0 ) {
154  dJointSetHinge2Param(_id, dParamBounce, val);
155  } else if ( axis == 1 ) {
156  dJointSetHinge2Param(_id, dParamBounce2, val);
157  }
158 }
159 
160 INLINE void OdeHinge2Joint::
161 set_param_CFM(int axis, dReal val) {
162  nassertv( _id != 0 );
163  nassertv( 0 <= axis && axis <= 1 );
164  if ( axis == 0 ) {
165  dJointSetHinge2Param(_id, dParamCFM, val);
166  } else if ( axis == 1 ) {
167  dJointSetHinge2Param(_id, dParamCFM2, val);
168  }
169 }
170 
171 INLINE void OdeHinge2Joint::
172 set_param_stop_ERP(int axis, dReal val) {
173  nassertv( _id != 0 );
174  nassertv( 0 <= axis && axis <= 1 );
175  if ( axis == 0 ) {
176  dJointSetHinge2Param(_id, dParamStopERP, val);
177  } else if ( axis == 1 ) {
178  dJointSetHinge2Param(_id, dParamStopERP2, val);
179  }
180 }
181 
182 INLINE void OdeHinge2Joint::
183 set_param_stop_CFM(int axis, dReal val) {
184  nassertv( _id != 0 );
185  nassertv( 0 <= axis && axis <= 1 );
186  if ( axis == 0 ) {
187  dJointSetHinge2Param(_id, dParamStopCFM, val);
188  } else if ( axis == 1 ) {
189  dJointSetHinge2Param(_id, dParamStopCFM2, val);
190  }
191 }
192 
193 INLINE void OdeHinge2Joint::
194 set_param_suspension_ERP(int axis, dReal val) {
195  nassertv( _id != 0 );
196  nassertv( 0 <= axis && axis <= 1 );
197  if ( axis == 0 ) {
198  dJointSetHinge2Param(_id, dParamSuspensionERP, val);
199  } else if ( axis == 1 ) {
200  dJointSetHinge2Param(_id, dParamSuspensionERP2, val);
201  }
202 }
203 
204 INLINE void OdeHinge2Joint::
205 set_param_suspension_CFM(int axis, dReal val) {
206  nassertv( _id != 0 );
207  nassertv( 0 <= axis && axis <= 1 );
208  if ( axis == 0 ) {
209  dJointSetHinge2Param(_id, dParamSuspensionCFM, val);
210  } else if ( axis == 1 ) {
211  dJointSetHinge2Param(_id, dParamSuspensionCFM2, val);
212  }
213 }
214 
215 INLINE dReal OdeHinge2Joint::
216 get_param_lo_stop(int axis) const {
217  nassertr( _id != 0, 0 );
218  nassertr( 0 <= axis && axis <= 1, 0 );
219  if ( axis == 0 ) {
220  return dJointGetHinge2Param(_id, dParamLoStop);
221  } else if ( axis == 1 ) {
222  return dJointGetHinge2Param(_id, dParamLoStop2);
223  }
224  return 0;
225 }
226 
227 INLINE dReal OdeHinge2Joint::
228 get_param_hi_stop(int axis) const {
229  nassertr( _id != 0, 0 );
230  nassertr( 0 <= axis && axis <= 1, 0 );
231  if ( axis == 0 ) {
232  return dJointGetHinge2Param(_id, dParamHiStop);
233  } else if ( axis == 1 ) {
234  return dJointGetHinge2Param(_id, dParamHiStop2);
235  }
236  return 0;
237 }
238 
239 INLINE dReal OdeHinge2Joint::
240 get_param_vel(int axis) const {
241  nassertr( _id != 0, 0 );
242  nassertr( 0 <= axis && axis <= 1, 0 );
243  if ( axis == 0 ) {
244  return dJointGetHinge2Param(_id, dParamVel);
245  } else if ( axis == 1 ) {
246  return dJointGetHinge2Param(_id, dParamVel2);
247  }
248  return 0;
249 }
250 
251 INLINE dReal OdeHinge2Joint::
252 get_param_f_max(int axis) const {
253  nassertr( _id != 0, 0 );
254  nassertr( 0 <= axis && axis <= 1, 0 );
255  if ( axis == 0 ) {
256  return dJointGetHinge2Param(_id, dParamFMax);
257  } else if ( axis == 1 ) {
258  return dJointGetHinge2Param(_id, dParamFMax2);
259  }
260  return 0;
261 }
262 
263 INLINE dReal OdeHinge2Joint::
264 get_param_fudge_factor(int axis) const {
265  nassertr( _id != 0, 0 );
266  nassertr( 0 <= axis && axis <= 1, 0 );
267  if ( axis == 0 ) {
268  return dJointGetHinge2Param(_id, dParamFudgeFactor);
269  } else if ( axis == 1 ) {
270  return dJointGetHinge2Param(_id, dParamFudgeFactor2);
271  }
272  return 0;
273 }
274 
275 INLINE dReal OdeHinge2Joint::
276 get_param_bounce(int axis) const {
277  nassertr( _id != 0, 0 );
278  nassertr( 0 <= axis && axis <= 1, 0 );
279  if ( axis == 0 ) {
280  return dJointGetHinge2Param(_id, dParamBounce);
281  } else if ( axis == 1 ) {
282  return dJointGetHinge2Param(_id, dParamBounce2);
283  }
284  return 0;
285 }
286 
287 INLINE dReal OdeHinge2Joint::
288 get_param_CFM(int axis) const {
289  nassertr( _id != 0, 0 );
290  nassertr( 0 <= axis && axis <= 1, 0 );
291  if ( axis == 0 ) {
292  return dJointGetHinge2Param(_id, dParamCFM);
293  } else if ( axis == 1 ) {
294  return dJointGetHinge2Param(_id, dParamCFM2);
295  }
296  return 0;
297 }
298 
299 INLINE dReal OdeHinge2Joint::
300 get_param_stop_ERP(int axis) const {
301  nassertr( _id != 0, 0 );
302  nassertr( 0 <= axis && axis <= 1, 0 );
303  if ( axis == 0 ) {
304  return dJointGetHinge2Param(_id, dParamStopERP);
305  } else if ( axis == 1 ) {
306  return dJointGetHinge2Param(_id, dParamStopERP2);
307  }
308  return 0;
309 }
310 
311 INLINE dReal OdeHinge2Joint::
312 get_param_stop_CFM(int axis) const {
313  nassertr( _id != 0, 0 );
314  nassertr( 0 <= axis && axis <= 1, 0 );
315  if ( axis == 0 ) {
316  return dJointGetHinge2Param(_id, dParamStopCFM);
317  } else if ( axis == 1 ) {
318  return dJointGetHinge2Param(_id, dParamStopCFM2);
319  }
320  return 0;
321 }
322 
323 INLINE dReal OdeHinge2Joint::
324 get_param_suspension_ERP(int axis) const {
325  nassertr( _id != 0, 0 );
326  nassertr( 0 <= axis && axis <= 1, 0 );
327  if ( axis == 0 ) {
328  return dJointGetHinge2Param(_id, dParamSuspensionERP);
329  } else if ( axis == 1 ) {
330  return dJointGetHinge2Param(_id, dParamSuspensionERP2);
331  }
332  return 0;
333 }
334 
335 INLINE dReal OdeHinge2Joint::
336 get_param_suspension_CFM(int axis) const {
337  nassertr( _id != 0, 0 );
338  nassertr( 0 <= axis && axis <= 1, 0 );
339  if ( axis == 0 ) {
340  return dJointGetHinge2Param(_id, dParamSuspensionCFM);
341  } else if ( axis == 1 ) {
342  return dJointGetHinge2Param(_id, dParamSuspensionCFM2);
343  }
344  return 0;
345 }
346 
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105