Panda3D

Loading...
Searching...
No Matches
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 */
19INLINE bool OdeBody::
20 is_empty() const {
21 return (_id == 0);
22}
23
24/**
25 * Returns the underlying dBodyID.
26 */
27INLINE dBodyID OdeBody::
28 get_id() const {
29 return _id;
30}
31
32INLINE dReal OdeBody::
33get_auto_disable_linear_threshold() const {
34 return dBodyGetAutoDisableLinearThreshold(_id);
35}
36
37INLINE void OdeBody::
38set_auto_disable_linear_threshold(dReal linear_threshold) {
39 dBodySetAutoDisableLinearThreshold(_id, linear_threshold);
40}
41
42INLINE dReal OdeBody::
43get_auto_disable_angular_threshold() const {
44 return dBodyGetAutoDisableAngularThreshold(_id);
45}
46
47INLINE void OdeBody::
48set_auto_disable_angular_threshold(dReal angular_threshold) {
49 dBodySetAutoDisableAngularThreshold(_id, angular_threshold);
50}
51
52INLINE int OdeBody::
53get_auto_disable_steps() const {
54 return dBodyGetAutoDisableSteps(_id);
55}
56
57INLINE void OdeBody::
58set_auto_disable_steps(int steps) {
59 dBodySetAutoDisableSteps(_id, steps);
60}
61
62INLINE dReal OdeBody::
63get_auto_disable_time() const {
64 return dBodyGetAutoDisableTime(_id);
65}
66
67INLINE void OdeBody::
68set_auto_disable_time(dReal time) {
69 dBodySetAutoDisableTime(_id, time);
70}
71
72INLINE int OdeBody::
73get_auto_disable_flag() const {
74 return dBodyGetAutoDisableFlag(_id);
75}
76
77INLINE void OdeBody::
78set_auto_disable_flag(int do_auto_disable) {
79 dBodySetAutoDisableFlag(_id, do_auto_disable);
80}
81
82INLINE void OdeBody::
83set_auto_disable_defaults() {
84 dBodySetAutoDisableDefaults(_id);
85}
86
87INLINE void OdeBody::
88set_data(void *data) {
89 dBodySetData(_id, data);
90}
91
92INLINE void *OdeBody::
93get_data() const {
94 return dBodyGetData(_id);
95}
96
97INLINE void OdeBody::
98set_position(dReal x, dReal y, dReal z) {
99 dBodySetPosition(_id, x, y, z);
100}
101
102INLINE void OdeBody::
103set_position(const LVecBase3f &pos) {
104 set_position(pos[0], pos[1], pos[2]);
105}
106
107INLINE void OdeBody::
108set_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
116INLINE void OdeBody::
117set_quaternion(const LQuaternionf &q) {
118 dQuaternion quat = { q[0], q[1], q[2], q[3] };
119 dBodySetQuaternion(_id, quat);
120}
121
122INLINE void OdeBody::
123set_linear_vel(dReal x, dReal y, dReal z) {
124 dBodySetLinearVel(_id, x, y, z);
125}
126
127INLINE void OdeBody::
128set_linear_vel(const LVecBase3f &vel) {
129 set_linear_vel(vel[0], vel[1], vel[2]);
130}
131
132INLINE void OdeBody::
133set_angular_vel(dReal x, dReal y, dReal z) {
134 dBodySetAngularVel(_id, x, y, z);
135}
136
137INLINE void OdeBody::
138set_angular_vel(const LVecBase3f &vel) {
139 set_angular_vel(vel[0], vel[1], vel[2]);
140}
141
142INLINE LVecBase3f OdeBody::
143get_position() const {
144 const dReal *res = dBodyGetPosition(_id);
145 return LVecBase3f(res[0], res[1], res[2]);
146}
147
148INLINE LMatrix3f OdeBody::
149get_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
156INLINE LVecBase4f OdeBody::
157get_quaternion() const {
158 const dReal *res = dBodyGetQuaternion(_id);
159 return LVecBase4f(res[0], res[1], res[2], res[3]);
160}
161
162INLINE LVecBase3f OdeBody::
163get_linear_vel() const {
164 const dReal *res = dBodyGetLinearVel(_id);
165 return LVecBase3f(res[0], res[1], res[2]);
166}
167
168INLINE LVecBase3f OdeBody::
169get_angular_vel() const {
170 const dReal *res = dBodyGetAngularVel(_id);
171 return LVecBase3f(res[0], res[1], res[2]);
172}
173
174INLINE void OdeBody::
175set_mass(OdeMass &mass) {
176 dBodySetMass(_id, mass.get_mass_ptr());
177}
178
179INLINE OdeMass OdeBody::
180get_mass() const {
181 OdeMass mass;
182 dBodyGetMass(_id, mass.get_mass_ptr());
183 return mass;
184}
185
186INLINE void OdeBody::
187add_force(dReal fx, dReal fy, dReal fz) {
188 dBodyAddForce(_id, fx, fy, fz);
189}
190
191INLINE void OdeBody::
192add_force(const LVecBase3f &f) {
193 add_force(f[0], f[1], f[2]);
194}
195
196INLINE void OdeBody::
197add_torque(dReal fx, dReal fy, dReal fz) {
198 dBodyAddTorque(_id, fx, fy, fz);
199}
200
201INLINE void OdeBody::
202add_torque(const LVecBase3f &f) {
203 add_torque(f[0], f[1], f[2]);
204}
205
206INLINE void OdeBody::
207add_rel_force(dReal fx, dReal fy, dReal fz) {
208 dBodyAddRelForce(_id, fx, fy, fz);
209}
210
211INLINE void OdeBody::
212add_rel_force(const LVecBase3f &f) {
213 add_rel_force(f[0], f[1], f[2]);
214}
215
216INLINE void OdeBody::
217add_rel_torque(dReal fx, dReal fy, dReal fz) {
218 dBodyAddRelTorque(_id, fx, fy, fz);
219}
220
221INLINE void OdeBody::
222add_rel_torque(const LVecBase3f &f) {
223 add_rel_torque(f[0], f[1], f[2]);
224}
225
226INLINE void OdeBody::
227add_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
231INLINE void OdeBody::
232add_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
236INLINE void OdeBody::
237add_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
241INLINE void OdeBody::
242add_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
246INLINE void OdeBody::
247add_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
251INLINE void OdeBody::
252add_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
256INLINE void OdeBody::
257add_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
261INLINE void OdeBody::
262add_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
266INLINE void OdeBody::
267set_force(dReal x, dReal y, dReal z) {
268 dBodySetForce(_id, x, y, z);
269}
270
271INLINE void OdeBody::
272set_force(const LVecBase3f &f) {
273 set_force(f[0], f[1], f[2]);
274}
275
276INLINE void OdeBody::
277set_torque(dReal x, dReal y, dReal z) {
278 dBodySetTorque(_id, x, y, z);
279}
280
281INLINE void OdeBody::
282set_torque(const LVecBase3f &f) {
283 set_torque(f[0], f[1], f[2]);
284}
285
286INLINE LPoint3f OdeBody::
287get_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
293INLINE LPoint3f OdeBody::
294get_rel_point_pos(const LVecBase3f &pos) const {
295 return get_rel_point_pos(pos[0], pos[1], pos[2]);
296}
297
298INLINE LPoint3f OdeBody::
299get_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
305INLINE LPoint3f OdeBody::
306get_rel_point_vel(const LVecBase3f &pos) const {
307 return get_rel_point_vel(pos[0], pos[1], pos[2]);
308}
309
310INLINE LPoint3f OdeBody::
311get_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
317INLINE LPoint3f OdeBody::
318get_point_vel(const LVecBase3f &pos) const {
319 return get_point_vel(pos[0], pos[1], pos[2]);
320}
321
322INLINE LPoint3f OdeBody::
323get_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
329INLINE LPoint3f OdeBody::
330get_pos_rel_point(const LVecBase3f &pos) const {
331 return get_pos_rel_point(pos[0], pos[1], pos[2]);
332}
333
334INLINE LVecBase3f OdeBody::
335vector_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
341INLINE LVecBase3f OdeBody::
342vector_to_world(const LVecBase3f &pos) const {
343 return vector_to_world(pos[0], pos[1], pos[2]);
344}
345
346INLINE LVecBase3f OdeBody::
347vector_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
353INLINE LVecBase3f OdeBody::
354vector_from_world(const LVecBase3f &pos) const {
355 return vector_from_world(pos[0], pos[1], pos[2]);
356}
357
358INLINE void OdeBody::
359set_finite_rotation_mode(int mode) {
360 dBodySetFiniteRotationMode(_id, mode);
361}
362
363INLINE void OdeBody::
364set_finite_rotation_axis(dReal x, dReal y, dReal z) {
365 dBodySetFiniteRotationAxis(_id, x, y, z);
366}
367
368INLINE void OdeBody::
369set_finite_rotation_axis(const LVecBase3f &axis) {
370 set_finite_rotation_axis(axis[0], axis[1], axis[2]);
371}
372
373INLINE int OdeBody::
374get_finite_rotation_mode() const {
375 return dBodyGetFiniteRotationMode(_id);
376}
377
378INLINE LVecBase3f OdeBody::
379get_finite_rotation_axis() const {
380 dVector3 result;
381 dBodyGetFiniteRotationAxis(_id, result);
382 return LVecBase3f(result[0], result[1], result[2]);
383}
384
385INLINE int OdeBody::
386get_num_joints() const {
387 return dBodyGetNumJoints(_id);
388}
389
390INLINE void OdeBody::
391enable() {
392 dBodyEnable(_id);
393}
394
395INLINE void OdeBody::
396disable() {
397 dBodyDisable(_id);
398}
399
400INLINE int OdeBody::
401is_enabled() const {
402 return dBodyIsEnabled(_id);
403}
404
405INLINE void OdeBody::
406set_gravity_mode(int mode) {
407 dBodySetGravityMode(_id, mode);
408}
409
410INLINE int OdeBody::
411get_gravity_mode() const {
412 return dBodyGetGravityMode(_id);
413}
414
415INLINE int OdeBody::
416compare_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