Panda3D
physxSphericalJointDesc.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 physxSphericalJointDesc.cxx
10  * @author enn0x
11  * @date 2009-09-28
12  */
13 
15 #include "physxManager.h"
16 #include "physxSpringDesc.h"
17 #include "physxJointLimitDesc.h"
18 
19 /**
20  * Set the distance above which to project joint.
21  */
23 set_projection_distance(float distance) {
24 
25  _desc.projectionDistance = distance;
26 }
27 
28 /**
29  * Sets or clears a single SphericalJointFlag flag.
30  */
32 set_flag(PhysxSphericalJointFlag flag, bool value) {
33 
34  if (value == true) {
35  _desc.flags |= flag;
36  }
37  else {
38  _desc.flags &= ~(flag);
39  }
40 }
41 
42 /**
43  * Sets a spring that works against twisting.
44  */
47 
48  _desc.twistSpring = spring._desc;
49 }
50 
51 /**
52  * Sets a spring that works against swinging.
53  */
56 
57  _desc.swingSpring = spring._desc;
58 }
59 
60 /**
61  * Sets a spring that lets the joint get pulled apart.
62  */
65 
66  _desc.jointSpring = spring._desc;
67 }
68 
69 /**
70  * Set the swing limit axis defined in the joint space of actor 0.
71  */
73 set_swing_axis(const LVector3f &axis) {
74 
75  nassertv( !axis.is_nan() );
76  _desc.swingAxis = PhysxManager::vec3_to_nxVec3(axis);
77 }
78 
79 /**
80  * Use this to enable joint projection. Default is PM_none.
81  */
83 set_projection_mode(PhysxProjectionMode mode) {
84 
85  _desc.projectionMode = (NxJointProjectionMode)mode;
86 }
87 
88 /**
89  * Limits rotation around twist axis.
90  */
93 
94  _desc.twistLimit.low = low._desc;
95 }
96 
97 /**
98  * Limits rotation around twist axis.
99  */
102 
103  _desc.twistLimit.high = high._desc;
104 }
105 
106 /**
107  * Limits swing of twist axis.
108  */
111 
112  _desc.swingLimit = limit._desc;
113 }
114 
115 /**
116  *
117  */
118 float PhysxSphericalJointDesc::
119 get_projection_distance() const {
120 
121  return _desc.projectionDistance;
122 }
123 
124 /**
125  *
126  */
127 bool PhysxSphericalJointDesc::
128 get_flag(PhysxSphericalJointFlag flag) const {
129 
130  return (_desc.flags & flag) ? true : false;
131 }
132 
133 /**
134  *
135  */
136 PhysxSpringDesc PhysxSphericalJointDesc::
137 get_twist_spring() const {
138 
139  PhysxSpringDesc value;
140  value._desc = _desc.twistSpring;
141  return value;
142 }
143 
144 /**
145  *
146  */
147 PhysxSpringDesc PhysxSphericalJointDesc::
148 get_swing_spring() const {
149 
150  PhysxSpringDesc value;
151  value._desc = _desc.swingSpring;
152  return value;
153 }
154 
155 /**
156  *
157  */
158 PhysxSpringDesc PhysxSphericalJointDesc::
159 get_joint_spring() const {
160 
161  PhysxSpringDesc value;
162  value._desc = _desc.jointSpring;
163  return value;
164 }
165 
166 /**
167  *
168  */
169 LVector3f PhysxSphericalJointDesc::
170 get_swing_axis() const {
171 
172  return PhysxManager::nxVec3_to_vec3(_desc.swingAxis);
173 }
174 
175 /**
176  *
177  */
178 PhysxEnums::PhysxProjectionMode PhysxSphericalJointDesc::
179 get_projection_mode() const {
180 
181  return (PhysxProjectionMode)_desc.projectionMode;
182 }
183 
184 /**
185  *
186  */
187 PhysxJointLimitDesc PhysxSphericalJointDesc::
188 get_twist_limit_low() const {
189 
190  PhysxJointLimitDesc value;
191  value._desc = _desc.twistLimit.low;
192  return value;
193 }
194 
195 /**
196  *
197  */
198 PhysxJointLimitDesc PhysxSphericalJointDesc::
199 get_twist_limit_high() const {
200 
201  PhysxJointLimitDesc value;
202  value._desc = _desc.twistLimit.high;
203  return value;
204 }
205 
206 /**
207  * Limits swing of twist axis.
208  */
211 
212  PhysxJointLimitDesc value;
213  value._desc = _desc.swingLimit;
214  return value;
215 }
void set_projection_distance(float distance)
Set the distance above which to project joint.
void set_joint_spring(const PhysxSpringDesc &spring)
Sets a spring that lets the joint get pulled apart.
void set_twist_limit_high(const PhysxJointLimitDesc &high)
Limits rotation around twist axis.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_twist_limit_low(const PhysxJointLimitDesc &low)
Limits rotation around twist axis.
Describes a joint spring.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_swing_spring(const PhysxSpringDesc &spring)
Sets a spring that works against swinging.
void set_swing_limit(const PhysxJointLimitDesc &limit)
Limits swing of twist axis.
PhysxJointLimitDesc get_swing_limit() const
Limits swing of twist axis.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
void set_projection_mode(PhysxProjectionMode mode)
Use this to enable joint projection.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_swing_axis(const LVector3f &axis)
Set the swing limit axis defined in the joint space of actor 0.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_twist_spring(const PhysxSpringDesc &spring)
Sets a spring that works against twisting.
void set_flag(PhysxSphericalJointFlag flag, bool value)
Sets or clears a single SphericalJointFlag flag.
Describes a joint limit.