Panda3D
 All Classes Functions Variables Enumerations
physxSphericalJointDesc.cxx
1 // Filename: physxSphericalJointDesc.cxx
2 // Created by: enn0x (28Sep09)
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 "physxSphericalJointDesc.h"
16 #include "physxManager.h"
17 #include "physxSpringDesc.h"
18 #include "physxJointLimitDesc.h"
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: PhysxSphericalJointDesc::set_projection_distance
22 // Access: Published
23 // Description: Set the distance above which to project joint.
24 ////////////////////////////////////////////////////////////////////
26 set_projection_distance(float distance) {
27 
28  _desc.projectionDistance = distance;
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: PhysxSphericalJointDesc::set_flag
33 // Access: Published
34 // Description: Sets or clears a single SphericalJointFlag flag.
35 ////////////////////////////////////////////////////////////////////
37 set_flag(PhysxSphericalJointFlag flag, bool value) {
38 
39  if (value == true) {
40  _desc.flags |= flag;
41  }
42  else {
43  _desc.flags &= ~(flag);
44  }
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: PhysxSphericalJointDesc::set_twist_spring
49 // Access: Published
50 // Description: Sets a spring that works against twisting.
51 ////////////////////////////////////////////////////////////////////
54 
55  _desc.twistSpring = spring._desc;
56 }
57 
58 ////////////////////////////////////////////////////////////////////
59 // Function: PhysxSphericalJointDesc::set_swing_spring
60 // Access: Published
61 // Description: Sets a spring that works against swinging.
62 ////////////////////////////////////////////////////////////////////
65 
66  _desc.swingSpring = spring._desc;
67 }
68 
69 ////////////////////////////////////////////////////////////////////
70 // Function: PhysxSphericalJointDesc::set_joint_spring
71 // Access: Published
72 // Description: Sets a spring that lets the joint get pulled apart.
73 ////////////////////////////////////////////////////////////////////
76 
77  _desc.jointSpring = spring._desc;
78 }
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: PhysxSphericalJointDesc::set_swing_axis
82 // Access: Published
83 // Description: Set the swing limit axis defined in the joint
84 // space of actor 0.
85 ////////////////////////////////////////////////////////////////////
87 set_swing_axis(const LVector3f &axis) {
88 
89  nassertv( !axis.is_nan() );
90  _desc.swingAxis = PhysxManager::vec3_to_nxVec3(axis);
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: PhysxSphericalJointDesc::set_projection_mode
95 // Access: Published
96 // Description: Use this to enable joint projection.
97 // Default is PM_none.
98 ////////////////////////////////////////////////////////////////////
100 set_projection_mode(PhysxProjectionMode mode) {
101 
102  _desc.projectionMode = (NxJointProjectionMode)mode;
103 }
104 
105 ////////////////////////////////////////////////////////////////////
106 // Function: PhysxSphericalJointDesc::set_twist_limit_low
107 // Access: Published
108 // Description: Limits rotation around twist axis.
109 ////////////////////////////////////////////////////////////////////
112 
113  _desc.twistLimit.low = low._desc;
114 }
115 
116 ////////////////////////////////////////////////////////////////////
117 // Function: PhysxSphericalJointDesc::set_twist_limit_high
118 // Access: Published
119 // Description: Limits rotation around twist axis.
120 ////////////////////////////////////////////////////////////////////
123 
124  _desc.twistLimit.high = high._desc;
125 }
126 
127 ////////////////////////////////////////////////////////////////////
128 // Function: PhysxSphericalJointDesc::set_swing_limit
129 // Access: Published
130 // Description: Limits swing of twist axis.
131 ////////////////////////////////////////////////////////////////////
134 
135  _desc.swingLimit = limit._desc;
136 }
137 
138 ////////////////////////////////////////////////////////////////////
139 // Function: PhysxSphericalJointDesc::get_projection_distance
140 // Access: Published
141 // Description:
142 ////////////////////////////////////////////////////////////////////
143 float PhysxSphericalJointDesc::
144 get_projection_distance() const {
145 
146  return _desc.projectionDistance;
147 }
148 
149 ////////////////////////////////////////////////////////////////////
150 // Function: PhysxSphericalJointDesc::get_flag
151 // Access: Published
152 // Description:
153 ////////////////////////////////////////////////////////////////////
154 bool PhysxSphericalJointDesc::
155 get_flag(PhysxSphericalJointFlag flag) const {
156 
157  return (_desc.flags & flag) ? true : false;
158 }
159 
160 ////////////////////////////////////////////////////////////////////
161 // Function: PhysxSphericalJointDesc::get_twist_spring
162 // Access: Published
163 // Description:
164 ////////////////////////////////////////////////////////////////////
165 PhysxSpringDesc PhysxSphericalJointDesc::
166 get_twist_spring() const {
167 
168  PhysxSpringDesc value;
169  value._desc = _desc.twistSpring;
170  return value;
171 }
172 
173 ////////////////////////////////////////////////////////////////////
174 // Function: PhysxSphericalJointDesc::get_swing_spring
175 // Access: Published
176 // Description:
177 ////////////////////////////////////////////////////////////////////
178 PhysxSpringDesc PhysxSphericalJointDesc::
179 get_swing_spring() const {
180 
181  PhysxSpringDesc value;
182  value._desc = _desc.swingSpring;
183  return value;
184 }
185 
186 ////////////////////////////////////////////////////////////////////
187 // Function: PhysxSphericalJointDesc::get_joint_spring
188 // Access: Published
189 // Description:
190 ////////////////////////////////////////////////////////////////////
191 PhysxSpringDesc PhysxSphericalJointDesc::
192 get_joint_spring() const {
193 
194  PhysxSpringDesc value;
195  value._desc = _desc.jointSpring;
196  return value;
197 }
198 
199 ////////////////////////////////////////////////////////////////////
200 // Function: PhysxSphericalJointDesc::get_swing_axis
201 // Access: Published
202 // Description:
203 ////////////////////////////////////////////////////////////////////
204 LVector3f PhysxSphericalJointDesc::
205 get_swing_axis() const {
206 
207  return PhysxManager::nxVec3_to_vec3(_desc.swingAxis);
208 }
209 
210 ////////////////////////////////////////////////////////////////////
211 // Function: PhysxSphericalJointDesc::get_projection_mode
212 // Access: Published
213 // Description:
214 ////////////////////////////////////////////////////////////////////
215 PhysxEnums::PhysxProjectionMode PhysxSphericalJointDesc::
216 get_projection_mode() const {
217 
218  return (PhysxProjectionMode)_desc.projectionMode;
219 }
220 
221 ////////////////////////////////////////////////////////////////////
222 // Function: PhysxSphericalJointDesc::get_twist_limit_low
223 // Access: Published
224 // Description:
225 ////////////////////////////////////////////////////////////////////
226 PhysxJointLimitDesc PhysxSphericalJointDesc::
227 get_twist_limit_low() const {
228 
229  PhysxJointLimitDesc value;
230  value._desc = _desc.twistLimit.low;
231  return value;
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: PhysxSphericalJointDesc::get_twist_limit_high
236 // Access: Published
237 // Description:
238 ////////////////////////////////////////////////////////////////////
239 PhysxJointLimitDesc PhysxSphericalJointDesc::
240 get_twist_limit_high() const {
241 
242  PhysxJointLimitDesc value;
243  value._desc = _desc.twistLimit.high;
244  return value;
245 }
246 
247 ////////////////////////////////////////////////////////////////////
248 // Function: PhysxSphericalJointDesc::get_swing_limit
249 // Access: Published
250 // Description: Limits swing of twist axis.
251 ////////////////////////////////////////////////////////////////////
254 
255  PhysxJointLimitDesc value;
256  value._desc = _desc.swingLimit;
257  return value;
258 }
259 
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.
void set_twist_limit_low(const PhysxJointLimitDesc &low)
Limits rotation around twist axis.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
Describes a joint spring.
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:463
PhysxJointLimitDesc get_swing_limit() const
Limits swing of twist axis.
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.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
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:44
void set_swing_axis(const LVector3f &axis)
Set the swing limit axis defined in the joint space of actor 0.
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.