Panda3D
Loading...
Searching...
No Matches
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 */
21void PhysxSoftBodyDesc::
22set_name(const char *name) {
23
24 _name = name ? name : "";
25 _desc.name = _name.c_str();
26}
27
28/**
29 *
30 */
31void PhysxSoftBodyDesc::
32set_global_pos(const LPoint3f &pos) {
33
34 _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
35}
36
37/**
38 *
39 */
40void PhysxSoftBodyDesc::
41set_global_mat(const LMatrix4f &mat) {
42
43 _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
44}
45
46/**
47 *
48 */
49void PhysxSoftBodyDesc::
50set_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 */
65void PhysxSoftBodyDesc::
66set_particle_radius(float radius) {
67
68 _desc.particleRadius = radius;
69}
70
71/**
72 *
73 */
74void PhysxSoftBodyDesc::
75set_relative_grid_spacing(float spacing) {
76
77 _desc.relativeGridSpacing = spacing;
78}
79
80/**
81 *
82 */
83void PhysxSoftBodyDesc::
84set_collision_response_coefficient(float coef) {
85
86 _desc.collisionResponseCoefficient = coef;
87}
88
89/**
90 *
91 */
92void PhysxSoftBodyDesc::
93set_attachment_response_coefficient(float coef) {
94
95 _desc.attachmentResponseCoefficient = coef;
96}
97
98/**
99 *
100 */
101void PhysxSoftBodyDesc::
102set_density(float density) {
103
104 _desc.density = density;
105}
106
107/**
108 *
109 */
110void PhysxSoftBodyDesc::
111set_volume_stiffness(float stiffness) {
112
113 _desc.volumeStiffness = stiffness;
114}
115
116/**
117 *
118 */
119void PhysxSoftBodyDesc::
120set_stretching_stiffness(float stiffness) {
121
122 _desc.stretchingStiffness = stiffness;
123}
124
125/**
126 *
127 */
128void PhysxSoftBodyDesc::
129set_damping_coefficient(float damping) {
130
131 _desc.dampingCoefficient = damping;
132}
133
134/**
135 *
136 */
137void PhysxSoftBodyDesc::
138set_friction(float friction) {
139
140 _desc.friction = friction;
141}
142
143/**
144 *
145 */
146void PhysxSoftBodyDesc::
147set_tear_factor(float tearFactor) {
148
149 _desc.tearFactor = tearFactor;
150}
151
152/**
153 * Raise or lower individual SoftBodyFlag flags.
154 */
156set_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 */
171set_solver_iterations(unsigned int iterations) {
172
173 _desc.solverIterations = iterations;
174}
175
176/**
177 *
178 */
179void PhysxSoftBodyDesc::
180set_soft_body_mesh(PhysxSoftBodyMesh *mesh) {
181
182 _desc.softBodyMesh = mesh->ptr();
183}
184
185/**
186 *
187 */
188const char *PhysxSoftBodyDesc::
189get_name() const {
190
191 return _desc.name;
192}
193
194/**
195 *
196 */
197LPoint3f PhysxSoftBodyDesc::
198get_global_pos() const {
199
200 return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
201}
202
203/**
204 *
205 */
206LMatrix4f PhysxSoftBodyDesc::
207get_global_mat() const {
208
209 return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
210}
211
212/**
213 *
214 */
215float PhysxSoftBodyDesc::
216get_particle_radius() const {
217
218 return _desc.particleRadius;
219}
220
221/**
222 *
223 */
224float PhysxSoftBodyDesc::
225get_relative_grid_spacing() const {
226
227 return _desc.relativeGridSpacing;
228}
229
230/**
231 *
232 */
233float PhysxSoftBodyDesc::
234get_collision_response_coefficient() const {
235
236 return _desc.collisionResponseCoefficient;
237}
238
239/**
240 *
241 */
242float PhysxSoftBodyDesc::
243get_attachment_response_coefficient() const {
244
245 return _desc.attachmentResponseCoefficient;
246}
247
248/**
249 *
250 */
251float PhysxSoftBodyDesc::
252get_density() const {
253
254 return _desc.density;
255}
256
257/**
258 *
259 */
260float PhysxSoftBodyDesc::
261get_volume_stiffness() const {
262
263 return _desc.volumeStiffness;
264}
265
266/**
267 *
268 */
269float PhysxSoftBodyDesc::
270get_stretching_stiffness() const {
271
272 return _desc.stretchingStiffness;
273}
274
275/**
276 *
277 */
278float PhysxSoftBodyDesc::
279get_damping_coefficient() const {
280
281 return _desc.dampingCoefficient;
282}
283
284/**
285 *
286 */
287float PhysxSoftBodyDesc::
288get_friction() const {
289
290 return _desc.friction;
291}
292
293/**
294 *
295 */
296float PhysxSoftBodyDesc::
297get_tear_factor() const {
298
299 return _desc.tearFactor;
300}
301
302/**
303 *
304 */
305bool PhysxSoftBodyDesc::
306get_flag(PhysxSoftBodyFlag flag) const {
307
308 return (_desc.flags & flag) ? true : false;
309}
310
311/**
312 *
313 */
314unsigned int PhysxSoftBodyDesc::
315get_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/*
325void PhysxSoftBodyDesc::
326get_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*/
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
void set_solver_iterations(unsigned int interations)
Number of solver iterations.
void set_flag(PhysxSoftBodyFlag flag, bool value)
Raise or lower individual SoftBodyFlag flags.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.