Panda3D

odeBody.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 odeBody.I
10 * @author joswilso
11 * @date 2006-12-27
12 */
13
14 /**
15 * Returns true if the ID is 0, meaning the OdeBody does not point to a valid
16 * body. It is an error to call a method on an empty body. Note that an
17 * empty OdeBody also evaluates to False.
18 */
19 INLINE bool OdeBody::
20 is_empty() const {
21 return (_id == 0);
22 }
23
24 /**
25 * Returns the underlying dBodyID.
26 */
27 INLINE dBodyID OdeBody::
28 get_id() const {
29 return _id;
30 }
31
32 INLINE dReal OdeBody::
33 get_auto_disable_linear_threshold() const {
34 return dBodyGetAutoDisableLinearThreshold(_id);
35 }
36
37 INLINE void OdeBody::
38 set_auto_disable_linear_threshold(dReal linear_threshold) {
39 dBodySetAutoDisableLinearThreshold(_id, linear_threshold);
40 }
41
42 INLINE dReal OdeBody::
43 get_auto_disable_angular_threshold() const {
44 return dBodyGetAutoDisableAngularThreshold(_id);
45 }
46
47 INLINE void OdeBody::
48 set_auto_disable_angular_threshold(dReal angular_threshold) {
49 dBodySetAutoDisableAngularThreshold(_id, angular_threshold);
50 }
51
52 INLINE int OdeBody::
53 get_auto_disable_steps() const {
54 return dBodyGetAutoDisableSteps(_id);
55 }
56
57 INLINE void OdeBody::
58 set_auto_disable_steps(int steps) {
59 dBodySetAutoDisableSteps(_id, steps);
60 }
61
62 INLINE dReal OdeBody::
63 get_auto_disable_time() const {
64 return dBodyGetAutoDisableTime(_id);
65 }
66
67 INLINE void OdeBody::
68 set_auto_disable_time(dReal time) {
69 dBodySetAutoDisableTime(_id, time);
70 }
71
72 INLINE int OdeBody::
73 get_auto_disable_flag() const {
74 return dBodyGetAutoDisableFlag(_id);
75 }
76
77 INLINE void OdeBody::
78 set_auto_disable_flag(int do_auto_disable) {
79 dBodySetAutoDisableFlag(_id, do_auto_disable);
80 }
81
82 INLINE void OdeBody::
83 set_auto_disable_defaults() {
84 dBodySetAutoDisableDefaults(_id);
85 }
86
87 INLINE void OdeBody::
88 set_data(void *data) {
89 dBodySetData(_id, data);
90 }
91
92 INLINE void *OdeBody::
93 get_data() const {
94 return dBodyGetData(_id);
95 }
96
97 INLINE void OdeBody::
98 set_position(dReal x, dReal y, dReal z) {
99 dBodySetPosition(_id, x, y, z);
100 }
101
102 INLINE void OdeBody::
103 set_position(const LVecBase3f &pos) {
104 set_position(pos[0], pos[1], pos[2]);
105 }
106
107 INLINE void OdeBody::
108 set_rotation(const LMatrix3f &r) {
109 dMatrix3 mat3 = { r(0, 0), r(0, 1), r(0, 2), 0,
110 r(1, 0), r(1, 1), r(1, 2), 0,
111 r(2, 0), r(2, 1), r(2, 2), 0 };
112
113 dBodySetRotation(_id, mat3);
114 }
115
116 INLINE void OdeBody::
117 set_quaternion(const LQuaternionf &q) {
118 dQuaternion quat = { q[0], q[1], q[2], q[3] };
119 dBodySetQuaternion(_id, quat);
120 }
121
122 INLINE void OdeBody::
123 set_linear_vel(dReal x, dReal y, dReal z) {
124 dBodySetLinearVel(_id, x, y, z);
125 }
126
127 INLINE void OdeBody::
128 set_linear_vel(const LVecBase3f &vel) {
129 set_linear_vel(vel[0], vel[1], vel[2]);
130 }
131
132 INLINE void OdeBody::
133 set_angular_vel(dReal x, dReal y, dReal z) {
134 dBodySetAngularVel(_id, x, y, z);
135 }
136
137 INLINE void OdeBody::
138 set_angular_vel(const LVecBase3f &vel) {
139 set_angular_vel(vel[0], vel[1], vel[2]);
140 }
141
142 INLINE LVecBase3f OdeBody::
143 get_position() const {
144 const dReal *res = dBodyGetPosition(_id);
145 return LVecBase3f(res[0], res[1], res[2]);
146 }
147
148 INLINE LMatrix3f OdeBody::
149 get_rotation() const {
150 const dReal *rot = dBodyGetRotation(_id);
151 return LMatrix3f(rot[0], rot[1], rot[2],
152 rot[4], rot[5], rot[6],
153 rot[8], rot[9], rot[10]);
154 }
155
156 INLINE LVecBase4f OdeBody::
157 get_quaternion() const {
158 const dReal *res = dBodyGetQuaternion(_id);
159 return LVecBase4f(res[0], res[1], res[2], res[3]);
160 }
161
162 INLINE LVecBase3f OdeBody::
163 get_linear_vel() const {
164 const dReal *res = dBodyGetLinearVel(_id);
165 return LVecBase3f(res[0], res[1], res[2]);
166 }
167
168 INLINE LVecBase3f OdeBody::
169 get_angular_vel() const {
170 const dReal *res = dBodyGetAngularVel(_id);
171 return LVecBase3f(res[0], res[1], res[2]);
172 }
173
174 INLINE void OdeBody::
175 set_mass(OdeMass &mass) {
176 dBodySetMass(_id, mass.get_mass_ptr());
177 }
178
179 INLINE OdeMass OdeBody::
180 get_mass() const {
181 OdeMass mass;
182 dBodyGetMass(_id, mass.get_mass_ptr());
183 return mass;
184 }
185
186 INLINE void OdeBody::
187 add_force(dReal fx, dReal fy, dReal fz) {
188 dBodyAddForce(_id, fx, fy, fz);
189 }
190
191 INLINE void OdeBody::
192 add_force(const LVecBase3f &f) {
193 add_force(f[0], f[1], f[2]);
194 }
195
196 INLINE void OdeBody::
197 add_torque(dReal fx, dReal fy, dReal fz) {
198 dBodyAddTorque(_id, fx, fy, fz);
199 }
200
201 INLINE void OdeBody::
202 add_torque(const LVecBase3f &f) {
203 add_torque(f[0], f[1], f[2]);
204 }
205
206 INLINE void OdeBody::
207 add_rel_force(dReal fx, dReal fy, dReal fz) {
208 dBodyAddRelForce(_id, fx, fy, fz);
209 }
210
211 INLINE void OdeBody::
212 add_rel_force(const LVecBase3f &f) {
213 add_rel_force(f[0], f[1], f[2]);
214 }
215
216 INLINE void OdeBody::
217 add_rel_torque(dReal fx, dReal fy, dReal fz) {
218 dBodyAddRelTorque(_id, fx, fy, fz);
219 }
220
221 INLINE void OdeBody::
222 add_rel_torque(const LVecBase3f &f) {
223 add_rel_torque(f[0], f[1], f[2]);
224 }
225
226 INLINE void OdeBody::
227 add_force_at_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) {
228 dBodyAddForceAtPos(_id, fx, fy, fz, px, py, pz);
229 }
230
231 INLINE void OdeBody::
232 add_force_at_pos(const LVecBase3f &f, const LVecBase3f &pos) {
233 add_force_at_pos(f[0], f[1], f[2], pos[0], pos[1], pos[2]);
234 }
235
236 INLINE void OdeBody::
237 add_force_at_rel_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) {
238 dBodyAddForceAtRelPos(_id, fx, fy, fz, px, py, pz);
239 }
240
241 INLINE void OdeBody::
242 add_force_at_rel_pos(const LVecBase3f &f, const LVecBase3f &pos) {
243 add_force_at_rel_pos(f[0], f[1], f[2], pos[0], pos[1], pos[2]);
244 }
245
246 INLINE void OdeBody::
247 add_rel_force_at_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) {
248 dBodyAddRelForceAtPos(_id, fx, fy, fz, px, py, pz);
249 }
250
251 INLINE void OdeBody::
252 add_rel_force_at_pos(const LVecBase3f &f, const LVecBase3f &pos) {
253 add_rel_force_at_pos(f[0], f[1], f[2], pos[0], pos[1], pos[2]);
254 }
255
256 INLINE void OdeBody::
257 add_rel_force_at_rel_pos(dReal fx, dReal fy, dReal fz, dReal px, dReal py, dReal pz) {
258 dBodyAddRelForceAtRelPos(_id, fx, fy, fz, px, py, pz);
259 }
260
261 INLINE void OdeBody::
262 add_rel_force_at_rel_pos(const LVecBase3f &f, const LVecBase3f &pos) {
263 add_rel_force_at_rel_pos(f[0], f[1], f[2], pos[0], pos[1], pos[2]);
264 }
265
266 INLINE void OdeBody::
267 set_force(dReal x, dReal y, dReal z) {
268 dBodySetForce(_id, x, y, z);
269 }
270
271 INLINE void OdeBody::
272 set_force(const LVecBase3f &f) {
273 set_force(f[0], f[1], f[2]);
274 }
275
276 INLINE void OdeBody::
277 set_torque(dReal x, dReal y, dReal z) {
278 dBodySetTorque(_id, x, y, z);
279 }
280
281 INLINE void OdeBody::
282 set_torque(const LVecBase3f &f) {
283 set_torque(f[0], f[1], f[2]);
284 }
285
286 INLINE LPoint3f OdeBody::
287 get_rel_point_pos(dReal px, dReal py, dReal pz) const {
288 dVector3 result;
289 dBodyGetRelPointPos(_id, px, py, pz, result);
290 return LPoint3f(result[0], result[1], result[2]);
291 }
292
293 INLINE LPoint3f OdeBody::
294 get_rel_point_pos(const LVecBase3f &pos) const {
295 return get_rel_point_pos(pos[0], pos[1], pos[2]);
296 }
297
298 INLINE LPoint3f OdeBody::
299 get_rel_point_vel(dReal px, dReal py, dReal pz) const {
300 dVector3 result;
301 dBodyGetRelPointVel(_id, px, py, pz, result);
302 return LPoint3f(result[0], result[1], result[2]);
303 }
304
305 INLINE LPoint3f OdeBody::
306 get_rel_point_vel(const LVecBase3f &pos) const {
307 return get_rel_point_vel(pos[0], pos[1], pos[2]);
308 }
309
310 INLINE LPoint3f OdeBody::
311 get_point_vel(dReal px, dReal py, dReal pz) const {
312 dVector3 result;
313 dBodyGetPointVel(_id, px, py, pz, result);
314 return LPoint3f(result[0], result[1], result[2]);
315 }
316
317 INLINE LPoint3f OdeBody::
318 get_point_vel(const LVecBase3f &pos) const {
319 return get_point_vel(pos[0], pos[1], pos[2]);
320 }
321
322 INLINE LPoint3f OdeBody::
323 get_pos_rel_point(dReal px, dReal py, dReal pz) const {
324 dVector3 result;
325 dBodyGetPosRelPoint(_id, px, py, pz, result);
326 return LPoint3f(result[0], result[1], result[2]);
327 }
328
329 INLINE LPoint3f OdeBody::
330 get_pos_rel_point(const LVecBase3f &pos) const {
331 return get_pos_rel_point(pos[0], pos[1], pos[2]);
332 }
333
334 INLINE LVecBase3f OdeBody::
335 vector_to_world(dReal px, dReal py, dReal pz) const {
336 dVector3 result;
337 dBodyVectorToWorld(_id, px, py, pz, result);
338 return LVecBase3f(result[0], result[1], result[2]);
339 }
340
341 INLINE LVecBase3f OdeBody::
342 vector_to_world(const LVecBase3f &pos) const {
343 return vector_to_world(pos[0], pos[1], pos[2]);
344 }
345
346 INLINE LVecBase3f OdeBody::
347 vector_from_world(dReal px, dReal py, dReal pz) const {
348 dVector3 result;
349 dBodyVectorFromWorld(_id, px, py, pz, result);
350 return LVecBase3f(result[0], result[1], result[2]);
351 }
352
353 INLINE LVecBase3f OdeBody::
354 vector_from_world(const LVecBase3f &pos) const {
355 return vector_from_world(pos[0], pos[1], pos[2]);
356 }
357
358 INLINE void OdeBody::
359 set_finite_rotation_mode(int mode) {
360 dBodySetFiniteRotationMode(_id, mode);
361 }
362
363 INLINE void OdeBody::
364 set_finite_rotation_axis(dReal x, dReal y, dReal z) {
365 dBodySetFiniteRotationAxis(_id, x, y, z);
366 }
367
368 INLINE void OdeBody::
369 set_finite_rotation_axis(const LVecBase3f &axis) {
370 set_finite_rotation_axis(axis[0], axis[1], axis[2]);
371 }
372
373 INLINE int OdeBody::
374 get_finite_rotation_mode() const {
375 return dBodyGetFiniteRotationMode(_id);
376 }
377
378 INLINE LVecBase3f OdeBody::
379 get_finite_rotation_axis() const {
380 dVector3 result;
381 dBodyGetFiniteRotationAxis(_id, result);
382 return LVecBase3f(result[0], result[1], result[2]);
383 }
384
385 INLINE int OdeBody::
386 get_num_joints() const {
387 return dBodyGetNumJoints(_id);
388 }
389
390 INLINE void OdeBody::
391 enable() {
392 dBodyEnable(_id);
393 }
394
395 INLINE void OdeBody::
396 disable() {
397 dBodyDisable(_id);
398 }
399
400 INLINE int OdeBody::
401 is_enabled() const {
402 return dBodyIsEnabled(_id);
403 }
404
405 INLINE void OdeBody::
406 set_gravity_mode(int mode) {
407 dBodySetGravityMode(_id, mode);
408 }
409
410 INLINE int OdeBody::
411 get_gravity_mode() const {
412 return dBodyGetGravityMode(_id);
413 }
414
415 INLINE int OdeBody::
416 compare_to(const OdeBody &other) const {
417 if (_id != other._id) {
418 return _id < other._id ? -1 : 1;
419 }
420 return 0;
421 }
OdeBody
Definition: odeBody.h:32
OdeBody::get_id
dBodyID get_id() const
Returns the underlying dBodyID.
Definition: odeBody.I:28
OdeBody::is_empty
bool is_empty() const
Returns true if the ID is 0, meaning the OdeBody does not point to a valid body.
Definition: odeBody.I:20
OdeMass
Definition: odeMass.h:26