Panda3D
physxD6JointDesc.cxx
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 physxD6JointDesc.cxx
10  * @author enn0x
11  * @date 2009-10-01
12  */
13 
14 #include "physxD6JointDesc.h"
15 #include "physxManager.h"
16 #include "physxJointDriveDesc.h"
18 
19 /**
20  *
21  */
22 void PhysxD6JointDesc::
23 set_x_motion(PhysxD6JointMotion xMotion) {
24 
25  _desc.xMotion = (NxD6JointMotion)xMotion;
26 }
27 
28 /**
29  *
30  */
31 void PhysxD6JointDesc::
32 set_y_motion(PhysxD6JointMotion yMotion) {
33 
34  _desc.yMotion = (NxD6JointMotion)yMotion;
35 }
36 
37 /**
38  *
39  */
40 void PhysxD6JointDesc::
41 set_z_motion(PhysxD6JointMotion zMotion) {
42 
43  _desc.zMotion = (NxD6JointMotion)zMotion;
44 }
45 
46 /**
47  *
48  */
49 void PhysxD6JointDesc::
50 set_swing1_motion(PhysxD6JointMotion swing1Motion) {
51 
52  _desc.swing1Motion = (NxD6JointMotion)swing1Motion;
53 }
54 
55 /**
56  *
57  */
58 void PhysxD6JointDesc::
59 set_swing2_motion(PhysxD6JointMotion swing2Motion) {
60 
61  _desc.swing2Motion = (NxD6JointMotion)swing2Motion;
62 }
63 
64 /**
65  *
66  */
67 void PhysxD6JointDesc::
68 set_twist_motion(PhysxD6JointMotion twistMotion) {
69 
70  _desc.twistMotion = (NxD6JointMotion)twistMotion;
71 }
72 
73 /**
74  *
75  */
76 void PhysxD6JointDesc::
77 set_x_drive(const PhysxJointDriveDesc &drive) {
78 
79  _desc.xDrive = drive._desc;
80 }
81 
82 /**
83  *
84  */
85 void PhysxD6JointDesc::
86 set_y_drive(const PhysxJointDriveDesc &drive) {
87 
88  _desc.yDrive = drive._desc;
89 }
90 
91 /**
92  *
93  */
94 void PhysxD6JointDesc::
95 set_z_drive(const PhysxJointDriveDesc &drive) {
96 
97  _desc.zDrive = drive._desc;
98 }
99 
100 /**
101  *
102  */
103 void PhysxD6JointDesc::
104 set_swing_drive(const PhysxJointDriveDesc &drive) {
105 
106  _desc.swingDrive = drive._desc;
107 }
108 
109 /**
110  *
111  */
112 void PhysxD6JointDesc::
113 set_twist_drive(const PhysxJointDriveDesc &drive) {
114 
115  _desc.twistDrive = drive._desc;
116 }
117 
118 /**
119  *
120  */
121 void PhysxD6JointDesc::
122 set_slerp_drive(const PhysxJointDriveDesc &drive) {
123 
124  _desc.slerpDrive = drive._desc;
125 }
126 
127 /**
128  * Sets or clears a single D6JointFlag flag.
129  */
131 set_flag(PhysxD6JointFlag flag, bool value) {
132 
133  if (value == true) {
134  _desc.flags |= flag;
135  }
136  else {
137  _desc.flags &= ~(flag);
138  }
139 }
140 
141 /**
142  *
143  */
144 void PhysxD6JointDesc::
145 set_linear_limit(const PhysxJointLimitSoftDesc &limit) {
146 
147  _desc.linearLimit = limit._desc;
148 }
149 
150 /**
151  *
152  */
153 void PhysxD6JointDesc::
154 set_swing1_limit(const PhysxJointLimitSoftDesc &limit) {
155 
156  _desc.swing1Limit = limit._desc;
157 }
158 
159 /**
160  *
161  */
162 void PhysxD6JointDesc::
163 set_swing2_limit(const PhysxJointLimitSoftDesc &limit) {
164 
165  _desc.swing2Limit = limit._desc;
166 }
167 
168 /**
169  *
170  */
171 void PhysxD6JointDesc::
172 set_twist_limit_low(const PhysxJointLimitSoftDesc &limit) {
173 
174  _desc.twistLimit.low = limit._desc;
175 }
176 
177 /**
178  *
179  */
180 void PhysxD6JointDesc::
181 set_twist_limit_high(const PhysxJointLimitSoftDesc &limit) {
182 
183  _desc.twistLimit.high = limit._desc;
184 }
185 
186 /**
187  *
188  */
189 void PhysxD6JointDesc::
190 set_projection_distance(float distance) {
191 
192  _desc.projectionDistance = distance;
193 }
194 
195 /**
196  *
197  */
198 void PhysxD6JointDesc::
199 set_projection_angle(float angle) {
200 
201  _desc.projectionAngle = angle;
202 }
203 
204 /**
205  *
206  */
207 void PhysxD6JointDesc::
208 set_gear_ratio(float ratio) {
209 
210  _desc.gearRatio = ratio;
211 }
212 
213 /**
214  *
215  */
216 void PhysxD6JointDesc::
217 set_drive_position(const LPoint3f &pos) {
218 
219  nassertv(!pos.is_nan());
220  _desc.drivePosition = PhysxManager::point3_to_nxVec3(pos);
221 }
222 
223 /**
224  *
225  */
226 void PhysxD6JointDesc::
227 set_drive_linear_velocity(const LVector3f &v) {
228 
229  nassertv(!v.is_nan());
230  _desc.driveLinearVelocity = PhysxManager::vec3_to_nxVec3(v);
231 }
232 
233 /**
234  *
235  */
236 void PhysxD6JointDesc::
237 set_drive_angular_velocity(const LVector3f &v) {
238 
239  nassertv(!v.is_nan());
240  _desc.driveAngularVelocity = PhysxManager::vec3_to_nxVec3(v);
241 }
242 
243 /**
244  *
245  */
246 void PhysxD6JointDesc::
247 set_drive_orientation(const LQuaternionf &quat) {
248 
249  _desc.driveOrientation = PhysxManager::quat_to_nxQuat(quat);
250 }
251 
252 /**
253  * Use this to enable joint projection. Default is PM_none.
254  */
256 set_projection_mode(PhysxProjectionMode mode) {
257 
258  _desc.projectionMode = (NxJointProjectionMode)mode;
259 }
260 
261 /**
262  *
263  */
264 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
265 get_x_motion() const {
266 
267  return (PhysxD6JointMotion)_desc.xMotion;
268 }
269 
270 /**
271  *
272  */
273 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
274 get_y_motion() const {
275 
276  return (PhysxD6JointMotion)_desc.yMotion;
277 }
278 
279 /**
280  *
281  */
282 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
283 get_z_motion() const {
284 
285  return (PhysxD6JointMotion)_desc.zMotion;
286 }
287 
288 /**
289  *
290  */
291 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
292 get_swing1_motion() const {
293 
294  return (PhysxD6JointMotion)_desc.swing1Motion;
295 }
296 
297 /**
298  *
299  */
300 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
301 get_swing2_motion() const {
302 
303  return (PhysxD6JointMotion)_desc.swing2Motion;
304 }
305 
306 /**
307  *
308  */
309 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
310 get_twist_motion() const {
311 
312  return (PhysxD6JointMotion)_desc.twistMotion;
313 }
314 
315 /**
316  *
317  */
318 PhysxJointDriveDesc PhysxD6JointDesc::
319 get_x_drive() const {
320 
321  PhysxJointDriveDesc value;
322  value._desc = _desc.xDrive;
323  return value;
324 }
325 
326 /**
327  *
328  */
329 PhysxJointDriveDesc PhysxD6JointDesc::
330 get_y_drive() const {
331 
332  PhysxJointDriveDesc value;
333  value._desc = _desc.yDrive;
334  return value;
335 }
336 
337 /**
338  *
339  */
340 PhysxJointDriveDesc PhysxD6JointDesc::
341 get_z_drive() const {
342 
343  PhysxJointDriveDesc value;
344  value._desc = _desc.zDrive;
345  return value;
346 }
347 
348 /**
349  *
350  */
351 PhysxJointDriveDesc PhysxD6JointDesc::
352 get_swing_drive() const {
353 
354  PhysxJointDriveDesc value;
355  value._desc = _desc.swingDrive;
356  return value;
357 }
358 
359 /**
360  *
361  */
362 PhysxJointDriveDesc PhysxD6JointDesc::
363 get_twist_drive() const {
364 
365  PhysxJointDriveDesc value;
366  value._desc = _desc.twistDrive;
367  return value;
368 }
369 
370 /**
371  *
372  */
373 PhysxJointDriveDesc PhysxD6JointDesc::
374 get_slerp_drive() const {
375 
376  PhysxJointDriveDesc value;
377  value._desc = _desc.slerpDrive;
378  return value;
379 }
380 
381 /**
382  *
383  */
384 bool PhysxD6JointDesc::
385 get_flag(PhysxD6JointFlag flag) const {
386 
387  return (_desc.flags & flag) ? true : false;
388 }
389 
390 /**
391  *
392  */
393 PhysxJointLimitSoftDesc PhysxD6JointDesc::
394 get_linear_limit() const {
395 
397  value._desc = _desc.linearLimit;
398  return value;
399 }
400 
401 /**
402  *
403  */
404 PhysxJointLimitSoftDesc PhysxD6JointDesc::
405 get_swing1_limit() const {
406 
408  value._desc = _desc.swing1Limit;
409  return value;
410 }
411 
412 /**
413  *
414  */
415 PhysxJointLimitSoftDesc PhysxD6JointDesc::
416 get_swing2_limit() const {
417 
419  value._desc = _desc.swing2Limit;
420  return value;
421 }
422 
423 /**
424  *
425  */
426 PhysxJointLimitSoftDesc PhysxD6JointDesc::
427 get_twist_limit_low() const {
428 
430  value._desc = _desc.twistLimit.low;
431  return value;
432 }
433 
434 /**
435  *
436  */
437 PhysxJointLimitSoftDesc PhysxD6JointDesc::
438 get_twist_limit_high() const {
439 
441  value._desc = _desc.twistLimit.high;
442  return value;
443 }
444 
445 /**
446  *
447  */
448 float PhysxD6JointDesc::
449 get_projection_distance() const {
450 
451  return _desc.projectionDistance;
452 }
453 
454 /**
455  *
456  */
457 float PhysxD6JointDesc::
458 get_projection_angle() const {
459 
460  return _desc.projectionAngle;
461 }
462 
463 /**
464  *
465  */
466 float PhysxD6JointDesc::
467 get_gear_ratio() const {
468 
469  return _desc.gearRatio;
470 }
471 
472 /**
473  *
474  */
475 LPoint3f PhysxD6JointDesc::
476 get_drive_position() const {
477 
478  return PhysxManager::nxVec3_to_point3(_desc.drivePosition);
479 }
480 
481 /**
482  *
483  */
484 LVector3f PhysxD6JointDesc::
485 get_drive_linear_velocity() const {
486 
487  return PhysxManager::nxVec3_to_vec3(_desc.driveLinearVelocity);
488 }
489 
490 /**
491  *
492  */
493 LVector3f PhysxD6JointDesc::
494 get_drive_angular_velocity() const {
495 
496  return PhysxManager::nxVec3_to_vec3(_desc.driveAngularVelocity);
497 }
498 
499 /**
500  *
501  */
502 LQuaternionf PhysxD6JointDesc::
503 get_drive_orientation() const {
504 
505  return PhysxManager::nxQuat_to_quat(_desc.driveOrientation);
506 }
507 
508 /**
509  *
510  */
511 PhysxEnums::PhysxProjectionMode PhysxD6JointDesc::
512 get_projection_mode() const {
513 
514  return (PhysxProjectionMode)_desc.projectionMode;
515 }
Describes a joint limit.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_flag(PhysxD6JointFlag flag, bool value)
Sets or clears a single D6JointFlag flag.
void set_projection_mode(PhysxProjectionMode mode)
Use this to enable joint projection.
static NxQuat quat_to_nxQuat(const LQuaternionf &q)
Converts from LQuaternionf to NxQuat.
Definition: physxManager.I:99
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:63
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Used to describe drive properties for a PhysxD6Joint.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LQuaternionf nxQuat_to_quat(const NxQuat &q)
Converts from NxQuat to LQuaternionf.
Definition: physxManager.I:110
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:72
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.