Panda3D
physxD6JointDesc.cxx
1 // Filename: physxD6JointDesc.cxx
2 // Created by: enn0x (01Octp09)
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 #include "physxD6JointDesc.h"
16 #include "physxManager.h"
17 #include "physxJointDriveDesc.h"
18 #include "physxJointLimitSoftDesc.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: PhysxD6JointDesc::set_x_motion
22 // Access: Published
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 void PhysxD6JointDesc::
26 set_x_motion(PhysxD6JointMotion xMotion) {
27 
28  _desc.xMotion = (NxD6JointMotion)xMotion;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: PhysxD6JointDesc::set_y_motion
33 // Access: Published
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 void PhysxD6JointDesc::
37 set_y_motion(PhysxD6JointMotion yMotion) {
38 
39  _desc.yMotion = (NxD6JointMotion)yMotion;
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PhysxD6JointDesc::set_z_motion
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 void PhysxD6JointDesc::
48 set_z_motion(PhysxD6JointMotion zMotion) {
49 
50  _desc.zMotion = (NxD6JointMotion)zMotion;
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: PhysxD6JointDesc::set_swing1_motion
55 // Access: Published
56 // Description:
57 ////////////////////////////////////////////////////////////////////
58 void PhysxD6JointDesc::
59 set_swing1_motion(PhysxD6JointMotion swing1Motion) {
60 
61  _desc.swing1Motion = (NxD6JointMotion)swing1Motion;
62 }
63 
64 ////////////////////////////////////////////////////////////////////
65 // Function: PhysxD6JointDesc::set_swing2_motion
66 // Access: Published
67 // Description:
68 ////////////////////////////////////////////////////////////////////
69 void PhysxD6JointDesc::
70 set_swing2_motion(PhysxD6JointMotion swing2Motion) {
71 
72  _desc.swing2Motion = (NxD6JointMotion)swing2Motion;
73 }
74 
75 ////////////////////////////////////////////////////////////////////
76 // Function: PhysxD6JointDesc::set_twist_motion
77 // Access: Published
78 // Description:
79 ////////////////////////////////////////////////////////////////////
80 void PhysxD6JointDesc::
81 set_twist_motion(PhysxD6JointMotion twistMotion) {
82 
83  _desc.twistMotion = (NxD6JointMotion)twistMotion;
84 }
85 
86 ////////////////////////////////////////////////////////////////////
87 // Function: PhysxD6JointDesc::set_x_drive
88 // Access: Published
89 // Description:
90 ////////////////////////////////////////////////////////////////////
91 void PhysxD6JointDesc::
92 set_x_drive(const PhysxJointDriveDesc &drive) {
93 
94  _desc.xDrive = drive._desc;
95 }
96 
97 ////////////////////////////////////////////////////////////////////
98 // Function: PhysxD6JointDesc::set_y_drive
99 // Access: Published
100 // Description:
101 ////////////////////////////////////////////////////////////////////
102 void PhysxD6JointDesc::
103 set_y_drive(const PhysxJointDriveDesc &drive) {
104 
105  _desc.yDrive = drive._desc;
106 }
107 
108 ////////////////////////////////////////////////////////////////////
109 // Function: PhysxD6JointDesc::set_z_drive
110 // Access: Published
111 // Description:
112 ////////////////////////////////////////////////////////////////////
113 void PhysxD6JointDesc::
114 set_z_drive(const PhysxJointDriveDesc &drive) {
115 
116  _desc.zDrive = drive._desc;
117 }
118 
119 ////////////////////////////////////////////////////////////////////
120 // Function: PhysxD6JointDesc::set_swing_drive
121 // Access: Published
122 // Description:
123 ////////////////////////////////////////////////////////////////////
124 void PhysxD6JointDesc::
125 set_swing_drive(const PhysxJointDriveDesc &drive) {
126 
127  _desc.swingDrive = drive._desc;
128 }
129 
130 ////////////////////////////////////////////////////////////////////
131 // Function: PhysxD6JointDesc::set_twist_drive
132 // Access: Published
133 // Description:
134 ////////////////////////////////////////////////////////////////////
135 void PhysxD6JointDesc::
136 set_twist_drive(const PhysxJointDriveDesc &drive) {
137 
138  _desc.twistDrive = drive._desc;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: PhysxD6JointDesc::set_slerp_drive
143 // Access: Published
144 // Description:
145 ////////////////////////////////////////////////////////////////////
146 void PhysxD6JointDesc::
147 set_slerp_drive(const PhysxJointDriveDesc &drive) {
148 
149  _desc.slerpDrive = drive._desc;
150 }
151 
152 ////////////////////////////////////////////////////////////////////
153 // Function: PhysxD6JointDesc::set_flag
154 // Access: Published
155 // Description: Sets or clears a single D6JointFlag flag.
156 ////////////////////////////////////////////////////////////////////
158 set_flag(PhysxD6JointFlag flag, bool value) {
159 
160  if (value == true) {
161  _desc.flags |= flag;
162  }
163  else {
164  _desc.flags &= ~(flag);
165  }
166 }
167 
168 ////////////////////////////////////////////////////////////////////
169 // Function: PhysxD6JointDesc::set_linear_limit
170 // Access: Published
171 // Description:
172 ////////////////////////////////////////////////////////////////////
173 void PhysxD6JointDesc::
174 set_linear_limit(const PhysxJointLimitSoftDesc &limit) {
175 
176  _desc.linearLimit = limit._desc;
177 }
178 
179 ////////////////////////////////////////////////////////////////////
180 // Function: PhysxD6JointDesc::set_swing1_limit
181 // Access: Published
182 // Description:
183 ////////////////////////////////////////////////////////////////////
184 void PhysxD6JointDesc::
185 set_swing1_limit(const PhysxJointLimitSoftDesc &limit) {
186 
187  _desc.swing1Limit = limit._desc;
188 }
189 
190 ////////////////////////////////////////////////////////////////////
191 // Function: PhysxD6JointDesc::set_swing2_limit
192 // Access: Published
193 // Description:
194 ////////////////////////////////////////////////////////////////////
195 void PhysxD6JointDesc::
196 set_swing2_limit(const PhysxJointLimitSoftDesc &limit) {
197 
198  _desc.swing2Limit = limit._desc;
199 }
200 
201 ////////////////////////////////////////////////////////////////////
202 // Function: PhysxD6JointDesc::set_twist_limit_low
203 // Access: Published
204 // Description:
205 ////////////////////////////////////////////////////////////////////
206 void PhysxD6JointDesc::
207 set_twist_limit_low(const PhysxJointLimitSoftDesc &limit) {
208 
209  _desc.twistLimit.low = limit._desc;
210 }
211 
212 ////////////////////////////////////////////////////////////////////
213 // Function: PhysxD6JointDesc::set_twist_limit_high
214 // Access: Published
215 // Description:
216 ////////////////////////////////////////////////////////////////////
217 void PhysxD6JointDesc::
218 set_twist_limit_high(const PhysxJointLimitSoftDesc &limit) {
219 
220  _desc.twistLimit.high = limit._desc;
221 }
222 
223 ////////////////////////////////////////////////////////////////////
224 // Function: PhysxD6JointDesc::set_projection_distance
225 // Access: Published
226 // Description:
227 ////////////////////////////////////////////////////////////////////
228 void PhysxD6JointDesc::
229 set_projection_distance(float distance) {
230 
231  _desc.projectionDistance = distance;
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: PhysxD6JointDesc::set_projection_angle
236 // Access: Published
237 // Description:
238 ////////////////////////////////////////////////////////////////////
239 void PhysxD6JointDesc::
240 set_projection_angle(float angle) {
241 
242  _desc.projectionAngle = angle;
243 }
244 
245 ////////////////////////////////////////////////////////////////////
246 // Function: PhysxD6JointDesc::set_gear_ratio
247 // Access: Published
248 // Description:
249 ////////////////////////////////////////////////////////////////////
250 void PhysxD6JointDesc::
251 set_gear_ratio(float ratio) {
252 
253  _desc.gearRatio = ratio;
254 }
255 
256 ////////////////////////////////////////////////////////////////////
257 // Function: PhysxD6JointDesc::set_drive_position
258 // Access: Published
259 // Description:
260 ////////////////////////////////////////////////////////////////////
261 void PhysxD6JointDesc::
262 set_drive_position(const LPoint3f &pos) {
263 
264  nassertv(!pos.is_nan());
265  _desc.drivePosition = PhysxManager::point3_to_nxVec3(pos);
266 }
267 
268 ////////////////////////////////////////////////////////////////////
269 // Function: PhysxD6JointDesc::set_drive_linear_velocity
270 // Access: Published
271 // Description:
272 ////////////////////////////////////////////////////////////////////
273 void PhysxD6JointDesc::
274 set_drive_linear_velocity(const LVector3f &v) {
275 
276  nassertv(!v.is_nan());
277  _desc.driveLinearVelocity = PhysxManager::vec3_to_nxVec3(v);
278 }
279 
280 ////////////////////////////////////////////////////////////////////
281 // Function: PhysxD6JointDesc::set_drive_angular_velocity
282 // Access: Published
283 // Description:
284 ////////////////////////////////////////////////////////////////////
285 void PhysxD6JointDesc::
286 set_drive_angular_velocity(const LVector3f &v) {
287 
288  nassertv(!v.is_nan());
289  _desc.driveAngularVelocity = PhysxManager::vec3_to_nxVec3(v);
290 }
291 
292 ////////////////////////////////////////////////////////////////////
293 // Function: PhysxD6JointDesc::set_drive_orientation
294 // Access: Published
295 // Description:
296 ////////////////////////////////////////////////////////////////////
297 void PhysxD6JointDesc::
298 set_drive_orientation(const LQuaternionf &quat) {
299 
300  _desc.driveOrientation = PhysxManager::quat_to_nxQuat(quat);
301 }
302 
303 ////////////////////////////////////////////////////////////////////
304 // Function: PhysxD6JointDesc::set_projection_mode
305 // Access: Published
306 // Description: Use this to enable joint projection.
307 // Default is PM_none.
308 ////////////////////////////////////////////////////////////////////
310 set_projection_mode(PhysxProjectionMode mode) {
311 
312  _desc.projectionMode = (NxJointProjectionMode)mode;
313 }
314 
315 ////////////////////////////////////////////////////////////////////
316 // Function: PhysxD6JointDesc::get_x_motion
317 // Access: Published
318 // Description:
319 ////////////////////////////////////////////////////////////////////
320 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
321 get_x_motion() const {
322 
323  return (PhysxD6JointMotion)_desc.xMotion;
324 }
325 
326 ////////////////////////////////////////////////////////////////////
327 // Function: PhysxD6JointDesc::get_y_motion
328 // Access: Published
329 // Description:
330 ////////////////////////////////////////////////////////////////////
331 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
332 get_y_motion() const {
333 
334  return (PhysxD6JointMotion)_desc.yMotion;
335 }
336 
337 ////////////////////////////////////////////////////////////////////
338 // Function: PhysxD6JointDesc::get_z_motion
339 // Access: Published
340 // Description:
341 ////////////////////////////////////////////////////////////////////
342 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
343 get_z_motion() const {
344 
345  return (PhysxD6JointMotion)_desc.zMotion;
346 }
347 
348 ////////////////////////////////////////////////////////////////////
349 // Function: PhysxD6JointDesc::get_swing1_motion
350 // Access: Published
351 // Description:
352 ////////////////////////////////////////////////////////////////////
353 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
354 get_swing1_motion() const {
355 
356  return (PhysxD6JointMotion)_desc.swing1Motion;
357 }
358 
359 ////////////////////////////////////////////////////////////////////
360 // Function: PhysxD6JointDesc::get_swing2_motion
361 // Access: Published
362 // Description:
363 ////////////////////////////////////////////////////////////////////
364 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
365 get_swing2_motion() const {
366 
367  return (PhysxD6JointMotion)_desc.swing2Motion;
368 }
369 
370 ////////////////////////////////////////////////////////////////////
371 // Function: PhysxD6JointDesc::get_twist_motion
372 // Access: Published
373 // Description:
374 ////////////////////////////////////////////////////////////////////
375 PhysxEnums::PhysxD6JointMotion PhysxD6JointDesc::
376 get_twist_motion() const {
377 
378  return (PhysxD6JointMotion)_desc.twistMotion;
379 }
380 
381 ////////////////////////////////////////////////////////////////////
382 // Function: PhysxD6JointDesc::get_x_drive
383 // Access: Published
384 // Description:
385 ////////////////////////////////////////////////////////////////////
386 PhysxJointDriveDesc PhysxD6JointDesc::
387 get_x_drive() const {
388 
389  PhysxJointDriveDesc value;
390  value._desc = _desc.xDrive;
391  return value;
392 }
393 
394 ////////////////////////////////////////////////////////////////////
395 // Function: PhysxD6JointDesc::get_y_drive
396 // Access: Published
397 // Description:
398 ////////////////////////////////////////////////////////////////////
399 PhysxJointDriveDesc PhysxD6JointDesc::
400 get_y_drive() const {
401 
402  PhysxJointDriveDesc value;
403  value._desc = _desc.yDrive;
404  return value;
405 }
406 
407 ////////////////////////////////////////////////////////////////////
408 // Function: PhysxD6JointDesc::get_z_drive
409 // Access: Published
410 // Description:
411 ////////////////////////////////////////////////////////////////////
412 PhysxJointDriveDesc PhysxD6JointDesc::
413 get_z_drive() const {
414 
415  PhysxJointDriveDesc value;
416  value._desc = _desc.zDrive;
417  return value;
418 }
419 
420 ////////////////////////////////////////////////////////////////////
421 // Function: PhysxD6JointDesc::get_swing_drive
422 // Access: Published
423 // Description:
424 ////////////////////////////////////////////////////////////////////
425 PhysxJointDriveDesc PhysxD6JointDesc::
426 get_swing_drive() const {
427 
428  PhysxJointDriveDesc value;
429  value._desc = _desc.swingDrive;
430  return value;
431 }
432 
433 ////////////////////////////////////////////////////////////////////
434 // Function: PhysxD6JointDesc::get_twist_drive
435 // Access: Published
436 // Description:
437 ////////////////////////////////////////////////////////////////////
438 PhysxJointDriveDesc PhysxD6JointDesc::
439 get_twist_drive() const {
440 
441  PhysxJointDriveDesc value;
442  value._desc = _desc.twistDrive;
443  return value;
444 }
445 
446 ////////////////////////////////////////////////////////////////////
447 // Function: PhysxD6JointDesc::get_slerp_drive
448 // Access: Published
449 // Description:
450 ////////////////////////////////////////////////////////////////////
451 PhysxJointDriveDesc PhysxD6JointDesc::
452 get_slerp_drive() const {
453 
454  PhysxJointDriveDesc value;
455  value._desc = _desc.slerpDrive;
456  return value;
457 }
458 
459 ////////////////////////////////////////////////////////////////////
460 // Function: PhysxD6JointDesc::get_flag
461 // Access: Published
462 // Description:
463 ////////////////////////////////////////////////////////////////////
464 bool PhysxD6JointDesc::
465 get_flag(PhysxD6JointFlag flag) const {
466 
467  return (_desc.flags & flag) ? true : false;
468 }
469 
470 ////////////////////////////////////////////////////////////////////
471 // Function: PhysxD6JointDesc::get_linear_limit
472 // Access: Published
473 // Description:
474 ////////////////////////////////////////////////////////////////////
475 PhysxJointLimitSoftDesc PhysxD6JointDesc::
476 get_linear_limit() const {
477 
479  value._desc = _desc.linearLimit;
480  return value;
481 }
482 
483 ////////////////////////////////////////////////////////////////////
484 // Function: PhysxD6JointDesc::get_swing1_limit
485 // Access: Published
486 // Description:
487 ////////////////////////////////////////////////////////////////////
488 PhysxJointLimitSoftDesc PhysxD6JointDesc::
489 get_swing1_limit() const {
490 
492  value._desc = _desc.swing1Limit;
493  return value;
494 }
495 
496 ////////////////////////////////////////////////////////////////////
497 // Function: PhysxD6JointDesc::get_swing2_limit
498 // Access: Published
499 // Description:
500 ////////////////////////////////////////////////////////////////////
501 PhysxJointLimitSoftDesc PhysxD6JointDesc::
502 get_swing2_limit() const {
503 
505  value._desc = _desc.swing2Limit;
506  return value;
507 }
508 
509 ////////////////////////////////////////////////////////////////////
510 // Function: PhysxD6JointDesc::get_twist_limit_low
511 // Access: Published
512 // Description:
513 ////////////////////////////////////////////////////////////////////
514 PhysxJointLimitSoftDesc PhysxD6JointDesc::
515 get_twist_limit_low() const {
516 
518  value._desc = _desc.twistLimit.low;
519  return value;
520 }
521 
522 ////////////////////////////////////////////////////////////////////
523 // Function: PhysxD6JointDesc::get_twist_limit_high
524 // Access: Published
525 // Description:
526 ////////////////////////////////////////////////////////////////////
527 PhysxJointLimitSoftDesc PhysxD6JointDesc::
528 get_twist_limit_high() const {
529 
531  value._desc = _desc.twistLimit.high;
532  return value;
533 }
534 
535 ////////////////////////////////////////////////////////////////////
536 // Function: PhysxD6JointDesc::get_projection_distance
537 // Access: Published
538 // Description:
539 ////////////////////////////////////////////////////////////////////
540 float PhysxD6JointDesc::
541 get_projection_distance() const {
542 
543  return _desc.projectionDistance;
544 }
545 
546 ////////////////////////////////////////////////////////////////////
547 // Function: PhysxD6JointDesc::get_projection_angle
548 // Access: Published
549 // Description:
550 ////////////////////////////////////////////////////////////////////
551 float PhysxD6JointDesc::
552 get_projection_angle() const {
553 
554  return _desc.projectionAngle;
555 }
556 
557 ////////////////////////////////////////////////////////////////////
558 // Function: PhysxD6JointDesc::get_gear_ratio
559 // Access: Published
560 // Description:
561 ////////////////////////////////////////////////////////////////////
562 float PhysxD6JointDesc::
563 get_gear_ratio() const {
564 
565  return _desc.gearRatio;
566 }
567 
568 ////////////////////////////////////////////////////////////////////
569 // Function: PhysxD6JointDesc::get_drive_position
570 // Access: Published
571 // Description:
572 ////////////////////////////////////////////////////////////////////
573 LPoint3f PhysxD6JointDesc::
574 get_drive_position() const {
575 
576  return PhysxManager::nxVec3_to_point3(_desc.drivePosition);
577 }
578 
579 ////////////////////////////////////////////////////////////////////
580 // Function: PhysxD6JointDesc::get_drive_linear_velocity
581 // Access: Published
582 // Description:
583 ////////////////////////////////////////////////////////////////////
584 LVector3f PhysxD6JointDesc::
585 get_drive_linear_velocity() const {
586 
587  return PhysxManager::nxVec3_to_vec3(_desc.driveLinearVelocity);
588 }
589 
590 ////////////////////////////////////////////////////////////////////
591 // Function: PhysxD6JointDesc::get_drive_angular_velocity
592 // Access: Published
593 // Description:
594 ////////////////////////////////////////////////////////////////////
595 LVector3f PhysxD6JointDesc::
596 get_drive_angular_velocity() const {
597 
598  return PhysxManager::nxVec3_to_vec3(_desc.driveAngularVelocity);
599 }
600 
601 ////////////////////////////////////////////////////////////////////
602 // Function: PhysxD6JointDesc::get_drive_orientation
603 // Access: Published
604 // Description:
605 ////////////////////////////////////////////////////////////////////
606 LQuaternionf PhysxD6JointDesc::
607 get_drive_orientation() const {
608 
609  return PhysxManager::nxQuat_to_quat(_desc.driveOrientation);
610 }
611 
612 ////////////////////////////////////////////////////////////////////
613 // Function: PhysxD6JointDesc::get_projection_mode
614 // Access: Published
615 // Description:
616 ////////////////////////////////////////////////////////////////////
617 PhysxEnums::PhysxProjectionMode PhysxD6JointDesc::
618 get_projection_mode() const {
619 
620  return (PhysxProjectionMode)_desc.projectionMode;
621 }
622 
Describes a joint limit.
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:121
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:77
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:464
Used to describe drive properties for a PhysxD6Joint.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
static LQuaternionf nxQuat_to_quat(const NxQuat &q)
Converts from NxQuat to LQuaternionf.
Definition: physxManager.I:134
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:44
This is the base quaternion class.
Definition: lquaternion.h:96
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:88