Panda3D
 All Classes Functions Variables Enumerations
physxClothDesc.cxx
1 // Filename: physxClothDesc.cxx
2 // Created by: enn0x (30Mar10)
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 "physxClothDesc.h"
16 #include "physxClothMesh.h"
17 #include "physxManager.h"
18 
19 ////////////////////////////////////////////////////////////////////
20 // Function: PhysxClothDesc::set_name
21 // Access: Published
22 // Description:
23 ////////////////////////////////////////////////////////////////////
24 void PhysxClothDesc::
25 set_name(const char *name) {
26 
27  _name = name ? name : "";
28  _desc.name = _name.c_str();
29 }
30 
31 ////////////////////////////////////////////////////////////////////
32 // Function: PhysxClothDesc::set_global_pos
33 // Access: Published
34 // Description:
35 ////////////////////////////////////////////////////////////////////
36 void PhysxClothDesc::
37 set_global_pos(const LPoint3f &pos) {
38 
39  _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: PhysxClothDesc::set_global_mat
44 // Access: Published
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 void PhysxClothDesc::
48 set_global_mat(const LMatrix4f &mat) {
49 
50  _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
51 }
52 
53 ////////////////////////////////////////////////////////////////////
54 // Function: PhysxClothDesc::set_global_hpr
55 // Access: Published
56 // Description:
57 ////////////////////////////////////////////////////////////////////
58 void PhysxClothDesc::
59 set_global_hpr(float h, float p, float r) {
60 
61  LQuaternionf q;
62  LMatrix3f rot;
63  NxMat34 m;
64 
65  q.set_hpr(LVector3f(h, p, r));
66  q.extract_to_matrix(rot);
67 
68  _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot);
69 }
70 
71 ////////////////////////////////////////////////////////////////////
72 // Function: PhysxClothDesc::set_thickness
73 // Access: Published
74 // Description:
75 ////////////////////////////////////////////////////////////////////
76 void PhysxClothDesc::
77 set_thickness(float thickness) {
78 
79  _desc.thickness = thickness;
80 }
81 
82 ////////////////////////////////////////////////////////////////////
83 // Function: PhysxClothDesc::set_density
84 // Access: Published
85 // Description:
86 ////////////////////////////////////////////////////////////////////
87 void PhysxClothDesc::
88 set_density(float density) {
89 
90  _desc.density = density;
91 }
92 
93 ////////////////////////////////////////////////////////////////////
94 // Function: PhysxClothDesc::set_bending_stiffness
95 // Access: Published
96 // Description:
97 ////////////////////////////////////////////////////////////////////
98 void PhysxClothDesc::
99 set_bending_stiffness(float stiffness) {
100 
101  _desc.bendingStiffness = stiffness;
102 }
103 
104 ////////////////////////////////////////////////////////////////////
105 // Function: PhysxClothDesc::set_stretching_stiffness
106 // Access: Published
107 // Description:
108 ////////////////////////////////////////////////////////////////////
109 void PhysxClothDesc::
110 set_stretching_stiffness(float stiffness) {
111 
112  _desc.stretchingStiffness = stiffness;
113 }
114 
115 ////////////////////////////////////////////////////////////////////
116 // Function: PhysxClothDesc::set_damping_coefficient
117 // Access: Published
118 // Description:
119 ////////////////////////////////////////////////////////////////////
120 void PhysxClothDesc::
121 set_damping_coefficient(float damping) {
122 
123  _desc.dampingCoefficient = damping;
124 }
125 
126 ////////////////////////////////////////////////////////////////////
127 // Function: PhysxClothDesc::set_friction
128 // Access: Published
129 // Description:
130 ////////////////////////////////////////////////////////////////////
131 void PhysxClothDesc::
132 set_friction(float friction) {
133 
134  _desc.friction = friction;
135 }
136 
137 ////////////////////////////////////////////////////////////////////
138 // Function: PhysxClothDesc::set_pressure
139 // Access: Published
140 // Description:
141 ////////////////////////////////////////////////////////////////////
142 void PhysxClothDesc::
143 set_pressure(float pressure) {
144 
145  _desc.pressure = pressure;
146 }
147 
148 ////////////////////////////////////////////////////////////////////
149 // Function: PhysxClothDesc::set_tear_factor
150 // Access: Published
151 // Description:
152 ////////////////////////////////////////////////////////////////////
153 void PhysxClothDesc::
154 set_tear_factor(float tearFactor) {
155 
156  _desc.tearFactor = tearFactor;
157 }
158 
159 ////////////////////////////////////////////////////////////////////
160 // Function: PhysxClothDesc::set_flag
161 // Access: Published
162 // Description: Raise or lower individual ClothFlag flags.
163 ////////////////////////////////////////////////////////////////////
164 void PhysxClothDesc::
165 set_flag(PhysxClothFlag flag, bool value) {
166 
167  if (value == true) {
168  _desc.flags |= flag;
169  }
170  else {
171  _desc.flags &= ~(flag);
172  }
173 }
174 
175 ////////////////////////////////////////////////////////////////////
176 // Function: PhysxClothDesc::set_solver_iterations
177 // Access: Published
178 // Description: Number of solver iterations.
179 // Small numbers make the simulation faster while
180 // the cloth gets less stiff.
181 ////////////////////////////////////////////////////////////////////
182 void PhysxClothDesc::
183 set_solver_iterations(unsigned int iterations) {
184 
185  _desc.solverIterations = iterations;
186 }
187 
188 ////////////////////////////////////////////////////////////////////
189 // Function: PhysxClothDesc::set_cloth_mesh
190 // Access: Published
191 // Description:
192 ////////////////////////////////////////////////////////////////////
193 void PhysxClothDesc::
194 set_cloth_mesh(PhysxClothMesh *mesh) {
195 
196  _desc.clothMesh = mesh->ptr();
197 }
198 
199 ////////////////////////////////////////////////////////////////////
200 // Function: PhysxClothDesc::get_name
201 // Access: Published
202 // Description:
203 ////////////////////////////////////////////////////////////////////
204 const char *PhysxClothDesc::
205 get_name() const {
206 
207  return _desc.name;
208 }
209 
210 ////////////////////////////////////////////////////////////////////
211 // Function: PhysxClothDesc::get_global_pos
212 // Access: Published
213 // Description:
214 ////////////////////////////////////////////////////////////////////
215 LPoint3f PhysxClothDesc::
216 get_global_pos() const {
217 
218  return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
219 }
220 
221 ////////////////////////////////////////////////////////////////////
222 // Function: PhysxClothDesc::get_global_mat
223 // Access: Published
224 // Description:
225 ////////////////////////////////////////////////////////////////////
226 LMatrix4f PhysxClothDesc::
227 get_global_mat() const {
228 
229  return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
230 }
231 
232 ////////////////////////////////////////////////////////////////////
233 // Function: PhysxClothDesc::get_thickness
234 // Access: Published
235 // Description:
236 ////////////////////////////////////////////////////////////////////
237 float PhysxClothDesc::
238 get_thickness() const {
239 
240  return _desc.thickness;
241 }
242 
243 ////////////////////////////////////////////////////////////////////
244 // Function: PhysxClothDesc::get_density
245 // Access: Published
246 // Description:
247 ////////////////////////////////////////////////////////////////////
248 float PhysxClothDesc::
249 get_density() const {
250 
251  return _desc.density;
252 }
253 
254 ////////////////////////////////////////////////////////////////////
255 // Function: PhysxClothDesc::get_bending_stiffness
256 // Access: Published
257 // Description:
258 ////////////////////////////////////////////////////////////////////
259 float PhysxClothDesc::
260 get_bending_stiffness() const {
261 
262  return _desc.bendingStiffness;
263 }
264 
265 ////////////////////////////////////////////////////////////////////
266 // Function: PhysxClothDesc::get_stretching_stiffness
267 // Access: Published
268 // Description:
269 ////////////////////////////////////////////////////////////////////
270 float PhysxClothDesc::
271 get_stretching_stiffness() const {
272 
273  return _desc.stretchingStiffness;
274 }
275 
276 ////////////////////////////////////////////////////////////////////
277 // Function: PhysxClothDesc::get_damping_coefficient
278 // Access: Published
279 // Description:
280 ////////////////////////////////////////////////////////////////////
281 float PhysxClothDesc::
282 get_damping_coefficient() const {
283 
284  return _desc.dampingCoefficient;
285 }
286 
287 ////////////////////////////////////////////////////////////////////
288 // Function: PhysxClothDesc::get_friction
289 // Access: Published
290 // Description:
291 ////////////////////////////////////////////////////////////////////
292 float PhysxClothDesc::
293 get_friction() const {
294 
295  return _desc.friction;
296 }
297 
298 ////////////////////////////////////////////////////////////////////
299 // Function: PhysxClothDesc::get_pressure
300 // Access: Published
301 // Description:
302 ////////////////////////////////////////////////////////////////////
303 float PhysxClothDesc::
304 get_pressure() const {
305 
306  return _desc.pressure;
307 }
308 
309 ////////////////////////////////////////////////////////////////////
310 // Function: PhysxClothDesc::get_tear_factor
311 // Access: Published
312 // Description:
313 ////////////////////////////////////////////////////////////////////
314 float PhysxClothDesc::
315 get_tear_factor() const {
316 
317  return _desc.tearFactor;
318 }
319 
320 ////////////////////////////////////////////////////////////////////
321 // Function: PhysxClothDesc::get_flag
322 // Access: Published
323 // Description:
324 ////////////////////////////////////////////////////////////////////
325 bool PhysxClothDesc::
326 get_flag(PhysxClothFlag flag) const {
327 
328  return (_desc.flags & flag) ? true : false;
329 }
330 
331 ////////////////////////////////////////////////////////////////////
332 // Function: PhysxClothDesc::get_solver_iterations
333 // Access: Published
334 // Description:
335 ////////////////////////////////////////////////////////////////////
336 unsigned int PhysxClothDesc::
337 get_solver_iterations() const {
338 
339  return _desc.solverIterations;
340 }
341 
342 /*
343 ////////////////////////////////////////////////////////////////////
344 // Function: PhysxClothDesc::get_mesh_numbers
345 // Access: Public
346 // Description: Used by PhysScene to query the sizes of arrays
347 // to allocate for the user buffers in PhysxClothNode.
348 ////////////////////////////////////////////////////////////////////
349 void PhysxClothDesc::
350 get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) {
351 
352  NxClothMeshDesc meshDesc;
353  _desc.clothMesh->saveToDesc(meshDesc);
354 
355  numVertices = meshDesc.numVertices;
356  numTriangles = meshDesc.numTriangles;
357 }
358 */
359 
void set_solver_iterations(unsigned int interations)
Number of solver iterations.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:77
void extract_to_matrix(LMatrix3f &m) const
Based on the quat lib from VRPN.
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
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:145
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:451
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition: physxManager.I:169
void set_flag(PhysxClothFlag flag, bool value)
Raise or lower individual ClothFlag flags.
void set_hpr(const LVecBase3f &hpr, CoordinateSystem cs=CS_default)
Sets the quaternion as the unit quaternion that is equivalent to these Euler angles.
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
This is a 3-by-3 transform matrix.
Definition: lmatrix.h:110
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition: physxManager.I:158