Panda3D
physxD6Joint.cxx
1 // Filename: physxD6Joint.cxx
2 // Created by: enn0x (02Oct09)
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 "physxD6Joint.h"
16 #include "physxD6JointDesc.h"
17 
18 TypeHandle PhysxD6Joint::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: PhysxD6Joint::link
22 // Access: Public
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 void PhysxD6Joint::
26 link(NxJoint *jointPtr) {
27 
28  _ptr = jointPtr->isD6Joint();
29  _ptr->userData = this;
30  _error_type = ET_ok;
31 
32  set_name(jointPtr->getName());
33 
34  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
35  scene->_joints.add(this);
36 }
37 
38 ////////////////////////////////////////////////////////////////////
39 // Function: PhysxD6Joint::unlink
40 // Access: Public
41 // Description:
42 ////////////////////////////////////////////////////////////////////
43 void PhysxD6Joint::
44 unlink() {
45 
46  _ptr->userData = NULL;
47  _error_type = ET_released;
48 
49  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
50  scene->_joints.remove(this);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function : PhysxD6Joint::save_to_desc
55 // Access : Published
56 // Description : Saves the state of the joint object to a
57 // descriptor.
58 ////////////////////////////////////////////////////////////////////
59 void PhysxD6Joint::
60 save_to_desc(PhysxD6JointDesc &jointDesc) const {
61 
62  nassertv(_error_type == ET_ok);
63  _ptr->saveToDesc(jointDesc._desc);
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function : PhysxD6Joint::load_from_desc
68 // Access : Published
69 // Description : Loads the entire state of the joint from a
70 // descriptor with a single call.
71 ////////////////////////////////////////////////////////////////////
72 void PhysxD6Joint::
73 load_from_desc(const PhysxD6JointDesc &jointDesc) {
74 
75  nassertv(_error_type == ET_ok);
76  _ptr->loadFromDesc(jointDesc._desc);
77 }
78 
79 ////////////////////////////////////////////////////////////////////
80 // Function: PhysxD6Joint::set_drive_angular_velocity
81 // Access: Published
82 // Description:
83 ////////////////////////////////////////////////////////////////////
84 void PhysxD6Joint::
85 set_drive_angular_velocity(const LVector3f &v) {
86 
87  nassertv(_error_type == ET_ok);
88  _ptr->setDriveAngularVelocity(PhysxManager::vec3_to_nxVec3(v));
89 }
90 
91 ////////////////////////////////////////////////////////////////////
92 // Function: PhysxD6Joint::set_drive_linear_velocity
93 // Access: Published
94 // Description:
95 ////////////////////////////////////////////////////////////////////
96 void PhysxD6Joint::
97 set_drive_linear_velocity(const LVector3f &v) {
98 
99  nassertv(_error_type == ET_ok);
100  _ptr->setDriveLinearVelocity(PhysxManager::vec3_to_nxVec3(v));
101 }
102 
103 ////////////////////////////////////////////////////////////////////
104 // Function: PhysxD6Joint::set_drive_orientation
105 // Access: Published
106 // Description:
107 ////////////////////////////////////////////////////////////////////
108 void PhysxD6Joint::
109 set_drive_orientation(const LQuaternionf &quat) {
110 
111  nassertv(_error_type == ET_ok);
112  _ptr->setDriveOrientation(PhysxManager::quat_to_nxQuat(quat));
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: PhysxD6Joint::set_drive_position
117 // Access: Published
118 // Description:
119 ////////////////////////////////////////////////////////////////////
120 void PhysxD6Joint::
121 set_drive_position(const LPoint3f &pos) {
122 
123  nassertv(_error_type == ET_ok);
124  _ptr->setDrivePosition(PhysxManager::point3_to_nxVec3(pos));
125 }
126 
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
A scene is a collection of bodies, constraints, and effectors which can interact. ...
Definition: physxScene.h:73
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
This is the base quaternion class.
Definition: lquaternion.h:96
void set_name(const char *name)
Sets a name string for this object.
Definition: physxJoint.cxx:100
void save_to_desc(PhysxD6JointDesc &jointDesc) const
Saves the state of the joint object to a descriptor.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
void load_from_desc(const PhysxD6JointDesc &jointDesc)
Loads the entire state of the joint from a descriptor with a single call.