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