Panda3D
physxSoftBodyDesc.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 physxSoftBodyDesc.cxx
10  * @author enn0x
11  * @date 2010-09-12
12  */
13 
14 #include "physxSoftBodyDesc.h"
15 #include "physxSoftBodyMesh.h"
16 #include "physxManager.h"
17 
18 /**
19  *
20  */
21 void PhysxSoftBodyDesc::
22 set_name(const char *name) {
23 
24  _name = name ? name : "";
25  _desc.name = _name.c_str();
26 }
27 
28 /**
29  *
30  */
31 void PhysxSoftBodyDesc::
32 set_global_pos(const LPoint3f &pos) {
33 
34  _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
35 }
36 
37 /**
38  *
39  */
40 void PhysxSoftBodyDesc::
41 set_global_mat(const LMatrix4f &mat) {
42 
43  _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
44 }
45 
46 /**
47  *
48  */
49 void PhysxSoftBodyDesc::
50 set_global_hpr(float h, float p, float r) {
51 
52  LQuaternionf q;
53  LMatrix3f rot;
54  NxMat34 m;
55 
56  q.set_hpr(LVector3f(h, p, r));
57  q.extract_to_matrix(rot);
58 
59  _desc.globalPose.M = PhysxManager::mat3_to_nxMat33(rot);
60 }
61 
62 /**
63  *
64  */
65 void PhysxSoftBodyDesc::
66 set_particle_radius(float radius) {
67 
68  _desc.particleRadius = radius;
69 }
70 
71 /**
72  *
73  */
74 void PhysxSoftBodyDesc::
75 set_relative_grid_spacing(float spacing) {
76 
77  _desc.relativeGridSpacing = spacing;
78 }
79 
80 /**
81  *
82  */
83 void PhysxSoftBodyDesc::
84 set_collision_response_coefficient(float coef) {
85 
86  _desc.collisionResponseCoefficient = coef;
87 }
88 
89 /**
90  *
91  */
92 void PhysxSoftBodyDesc::
93 set_attachment_response_coefficient(float coef) {
94 
95  _desc.attachmentResponseCoefficient = coef;
96 }
97 
98 /**
99  *
100  */
101 void PhysxSoftBodyDesc::
102 set_density(float density) {
103 
104  _desc.density = density;
105 }
106 
107 /**
108  *
109  */
110 void PhysxSoftBodyDesc::
111 set_volume_stiffness(float stiffness) {
112 
113  _desc.volumeStiffness = stiffness;
114 }
115 
116 /**
117  *
118  */
119 void PhysxSoftBodyDesc::
120 set_stretching_stiffness(float stiffness) {
121 
122  _desc.stretchingStiffness = stiffness;
123 }
124 
125 /**
126  *
127  */
128 void PhysxSoftBodyDesc::
129 set_damping_coefficient(float damping) {
130 
131  _desc.dampingCoefficient = damping;
132 }
133 
134 /**
135  *
136  */
137 void PhysxSoftBodyDesc::
138 set_friction(float friction) {
139 
140  _desc.friction = friction;
141 }
142 
143 /**
144  *
145  */
146 void PhysxSoftBodyDesc::
147 set_tear_factor(float tearFactor) {
148 
149  _desc.tearFactor = tearFactor;
150 }
151 
152 /**
153  * Raise or lower individual SoftBodyFlag flags.
154  */
156 set_flag(PhysxSoftBodyFlag flag, bool value) {
157 
158  if (value == true) {
159  _desc.flags |= flag;
160  }
161  else {
162  _desc.flags &= ~(flag);
163  }
164 }
165 
166 /**
167  * Number of solver iterations. Small numbers make the simulation faster
168  * while the soft body gets less stiff.
169  */
171 set_solver_iterations(unsigned int iterations) {
172 
173  _desc.solverIterations = iterations;
174 }
175 
176 /**
177  *
178  */
179 void PhysxSoftBodyDesc::
180 set_soft_body_mesh(PhysxSoftBodyMesh *mesh) {
181 
182  _desc.softBodyMesh = mesh->ptr();
183 }
184 
185 /**
186  *
187  */
188 const char *PhysxSoftBodyDesc::
189 get_name() const {
190 
191  return _desc.name;
192 }
193 
194 /**
195  *
196  */
197 LPoint3f PhysxSoftBodyDesc::
198 get_global_pos() const {
199 
200  return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
201 }
202 
203 /**
204  *
205  */
206 LMatrix4f PhysxSoftBodyDesc::
207 get_global_mat() const {
208 
209  return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
210 }
211 
212 /**
213  *
214  */
215 float PhysxSoftBodyDesc::
216 get_particle_radius() const {
217 
218  return _desc.particleRadius;
219 }
220 
221 /**
222  *
223  */
224 float PhysxSoftBodyDesc::
225 get_relative_grid_spacing() const {
226 
227  return _desc.relativeGridSpacing;
228 }
229 
230 /**
231  *
232  */
233 float PhysxSoftBodyDesc::
234 get_collision_response_coefficient() const {
235 
236  return _desc.collisionResponseCoefficient;
237 }
238 
239 /**
240  *
241  */
242 float PhysxSoftBodyDesc::
243 get_attachment_response_coefficient() const {
244 
245  return _desc.attachmentResponseCoefficient;
246 }
247 
248 /**
249  *
250  */
251 float PhysxSoftBodyDesc::
252 get_density() const {
253 
254  return _desc.density;
255 }
256 
257 /**
258  *
259  */
260 float PhysxSoftBodyDesc::
261 get_volume_stiffness() const {
262 
263  return _desc.volumeStiffness;
264 }
265 
266 /**
267  *
268  */
269 float PhysxSoftBodyDesc::
270 get_stretching_stiffness() const {
271 
272  return _desc.stretchingStiffness;
273 }
274 
275 /**
276  *
277  */
278 float PhysxSoftBodyDesc::
279 get_damping_coefficient() const {
280 
281  return _desc.dampingCoefficient;
282 }
283 
284 /**
285  *
286  */
287 float PhysxSoftBodyDesc::
288 get_friction() const {
289 
290  return _desc.friction;
291 }
292 
293 /**
294  *
295  */
296 float PhysxSoftBodyDesc::
297 get_tear_factor() const {
298 
299  return _desc.tearFactor;
300 }
301 
302 /**
303  *
304  */
305 bool PhysxSoftBodyDesc::
306 get_flag(PhysxSoftBodyFlag flag) const {
307 
308  return (_desc.flags & flag) ? true : false;
309 }
310 
311 /**
312  *
313  */
314 unsigned int PhysxSoftBodyDesc::
315 get_solver_iterations() const {
316 
317  return _desc.solverIterations;
318 }
319 
320 /**
321  * Used by PhysScene to query the sizes of arrays to allocate for the user
322  * buffers in PhysxSoftBodyNode.
323  */
324 /*
325 void PhysxSoftBodyDesc::
326 get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) {
327 
328  NxSoftBodyMeshDesc meshDesc;
329  _desc.clothMesh->saveToDesc(meshDesc);
330 
331  numVertices = meshDesc.numVertices;
332  numTriangles = meshDesc.numTriangles;
333 }
334 */
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:63
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:119
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition: physxManager.I:139
void set_flag(PhysxSoftBodyFlag flag, bool value)
Raise or lower individual SoftBodyFlag flags.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:72
void set_solver_iterations(unsigned int interations)
Number of solver iterations.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition: physxManager.I:130