Panda3D
physxD6Joint.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 physxD6Joint.cxx
10  * @author enn0x
11  * @date 2009-10-02
12  */
13 
14 #include "physxD6Joint.h"
15 #include "physxD6JointDesc.h"
16 
17 TypeHandle PhysxD6Joint::_type_handle;
18 
19 /**
20  *
21  */
22 void PhysxD6Joint::
23 link(NxJoint *jointPtr) {
24 
25  _ptr = jointPtr->isD6Joint();
26  _ptr->userData = this;
27  _error_type = ET_ok;
28 
29  set_name(jointPtr->getName());
30 
31  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
32  scene->_joints.add(this);
33 }
34 
35 /**
36  *
37  */
38 void PhysxD6Joint::
39 unlink() {
40 
41  _ptr->userData = nullptr;
42  _error_type = ET_released;
43 
44  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
45  scene->_joints.remove(this);
46 }
47 
48 /**
49  * Saves the state of the joint object to a descriptor.
50  */
51 void PhysxD6Joint::
52 save_to_desc(PhysxD6JointDesc &jointDesc) const {
53 
54  nassertv(_error_type == ET_ok);
55  _ptr->saveToDesc(jointDesc._desc);
56 }
57 
58 /**
59  * Loads the entire state of the joint from a descriptor with a single call.
60  */
61 void PhysxD6Joint::
62 load_from_desc(const PhysxD6JointDesc &jointDesc) {
63 
64  nassertv(_error_type == ET_ok);
65  _ptr->loadFromDesc(jointDesc._desc);
66 }
67 
68 /**
69  *
70  */
71 void PhysxD6Joint::
72 set_drive_angular_velocity(const LVector3f &v) {
73 
74  nassertv(_error_type == ET_ok);
75  _ptr->setDriveAngularVelocity(PhysxManager::vec3_to_nxVec3(v));
76 }
77 
78 /**
79  *
80  */
81 void PhysxD6Joint::
82 set_drive_linear_velocity(const LVector3f &v) {
83 
84  nassertv(_error_type == ET_ok);
85  _ptr->setDriveLinearVelocity(PhysxManager::vec3_to_nxVec3(v));
86 }
87 
88 /**
89  *
90  */
91 void PhysxD6Joint::
92 set_drive_orientation(const LQuaternionf &quat) {
93 
94  nassertv(_error_type == ET_ok);
95  _ptr->setDriveOrientation(PhysxManager::quat_to_nxQuat(quat));
96 }
97 
98 /**
99  *
100  */
101 void PhysxD6Joint::
102 set_drive_position(const LPoint3f &pos) {
103 
104  nassertv(_error_type == ET_ok);
105  _ptr->setDrivePosition(PhysxManager::point3_to_nxVec3(pos));
106 }
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
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition: physxScene.h:69
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
void set_name(const char *name)
Sets a name string for this object.
Definition: physxJoint.cxx:91
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:81
void load_from_desc(const PhysxD6JointDesc &jointDesc)
Loads the entire state of the joint from a descriptor with a single call.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.