Panda3D

Loading...
Searching...
No Matches
physxClothDesc.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 physxClothDesc.cxx
10 * @author enn0x
11 * @date 2010-03-30
12 */
13
14#include "physxClothDesc.h"
15#include "physxClothMesh.h"
16#include "physxManager.h"
17
18/**
19 *
20 */
21 void PhysxClothDesc::
22set_name(const char *name) {
23
24 _name = name ? name : "";
25 _desc.name = _name.c_str();
26}
27
28/**
29 *
30 */
31 void PhysxClothDesc::
32set_global_pos(const LPoint3f &pos) {
33
34 _desc.globalPose.t = PhysxManager::point3_to_nxVec3(pos);
35}
36
37/**
38 *
39 */
40 void PhysxClothDesc::
41set_global_mat(const LMatrix4f &mat) {
42
43 _desc.globalPose = PhysxManager::mat4_to_nxMat34(mat);
44}
45
46/**
47 *
48 */
49 void PhysxClothDesc::
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 */
65 void PhysxClothDesc::
66set_thickness(float thickness) {
67
68 _desc.thickness = thickness;
69}
70
71/**
72 *
73 */
74 void PhysxClothDesc::
75set_density(float density) {
76
77 _desc.density = density;
78}
79
80/**
81 *
82 */
83 void PhysxClothDesc::
84set_bending_stiffness(float stiffness) {
85
86 _desc.bendingStiffness = stiffness;
87}
88
89/**
90 *
91 */
92 void PhysxClothDesc::
93set_stretching_stiffness(float stiffness) {
94
95 _desc.stretchingStiffness = stiffness;
96}
97
98/**
99 *
100 */
101 void PhysxClothDesc::
102set_damping_coefficient(float damping) {
103
104 _desc.dampingCoefficient = damping;
105}
106
107/**
108 *
109 */
110 void PhysxClothDesc::
111set_friction(float friction) {
112
113 _desc.friction = friction;
114}
115
116/**
117 *
118 */
119 void PhysxClothDesc::
120set_pressure(float pressure) {
121
122 _desc.pressure = pressure;
123}
124
125/**
126 *
127 */
128 void PhysxClothDesc::
129set_tear_factor(float tearFactor) {
130
131 _desc.tearFactor = tearFactor;
132}
133
134/**
135 * Raise or lower individual ClothFlag flags.
136 */
137 void PhysxClothDesc::
138 set_flag(PhysxClothFlag flag, bool value) {
139
140 if (value == true) {
141 _desc.flags |= flag;
142 }
143 else {
144 _desc.flags &= ~(flag);
145 }
146}
147
148/**
149 * Number of solver iterations. Small numbers make the simulation faster
150 * while the cloth gets less stiff.
151 */
152 void PhysxClothDesc::
153 set_solver_iterations(unsigned int iterations) {
154
155 _desc.solverIterations = iterations;
156}
157
158/**
159 *
160 */
161 void PhysxClothDesc::
162set_cloth_mesh(PhysxClothMesh *mesh) {
163
164 _desc.clothMesh = mesh->ptr();
165}
166
167/**
168 *
169 */
170 const char *PhysxClothDesc::
171get_name() const {
172
173 return _desc.name;
174}
175
176/**
177 *
178 */
179LPoint3f PhysxClothDesc::
180get_global_pos() const {
181
182 return PhysxManager::nxVec3_to_point3(_desc.globalPose.t);
183}
184
185/**
186 *
187 */
188LMatrix4f PhysxClothDesc::
189get_global_mat() const {
190
191 return PhysxManager::nxMat34_to_mat4(_desc.globalPose);
192}
193
194/**
195 *
196 */
197 float PhysxClothDesc::
198get_thickness() const {
199
200 return _desc.thickness;
201}
202
203/**
204 *
205 */
206 float PhysxClothDesc::
207get_density() const {
208
209 return _desc.density;
210}
211
212/**
213 *
214 */
215 float PhysxClothDesc::
216get_bending_stiffness() const {
217
218 return _desc.bendingStiffness;
219}
220
221/**
222 *
223 */
224 float PhysxClothDesc::
225get_stretching_stiffness() const {
226
227 return _desc.stretchingStiffness;
228}
229
230/**
231 *
232 */
233 float PhysxClothDesc::
234get_damping_coefficient() const {
235
236 return _desc.dampingCoefficient;
237}
238
239/**
240 *
241 */
242 float PhysxClothDesc::
243get_friction() const {
244
245 return _desc.friction;
246}
247
248/**
249 *
250 */
251 float PhysxClothDesc::
252get_pressure() const {
253
254 return _desc.pressure;
255}
256
257/**
258 *
259 */
260 float PhysxClothDesc::
261get_tear_factor() const {
262
263 return _desc.tearFactor;
264}
265
266/**
267 *
268 */
269 bool PhysxClothDesc::
270get_flag(PhysxClothFlag flag) const {
271
272 return (_desc.flags & flag) ? true : false;
273}
274
275/**
276 *
277 */
278 unsigned int PhysxClothDesc::
279get_solver_iterations() const {
280
281 return _desc.solverIterations;
282}
283
284/**
285 * Used by PhysScene to query the sizes of arrays to allocate for the user
286 * buffers in PhysxClothNode.
287 */
288/*
289 void PhysxClothDesc::
290 get_mesh_numbers(NxU32 &numVertices, NxU32 &numTriangles) {
291
292 NxClothMeshDesc meshDesc;
293 _desc.clothMesh->saveToDesc(meshDesc);
294
295 numVertices = meshDesc.numVertices;
296 numTriangles = meshDesc.numTriangles;
297}
298*/
PhysxClothDesc::set_solver_iterations
void set_solver_iterations(unsigned int interations)
Number of solver iterations.
Definition physxClothDesc.cxx:153
PhysxClothDesc::set_flag
void set_flag(PhysxClothFlag flag, bool value)
Raise or lower individual ClothFlag flags.
Definition physxClothDesc.cxx:138
PhysxClothMesh
Definition physxClothMesh.h:25
PhysxManager::point3_to_nxVec3
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition physxManager.I:63
PhysxManager::mat4_to_nxMat34
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition physxManager.I:119
PhysxManager::nxVec3_to_point3
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition physxManager.I:72
PhysxManager::mat3_to_nxMat33
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition physxManager.I:139
PhysxManager::nxMat34_to_mat4
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition physxManager.I:130
physxClothDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxClothMesh.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.