Panda3D
 All Classes Functions Variables Enumerations
physxCloth.cxx
1 // Filename: physxCloth.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 "physxCloth.h"
16 #include "physxClothDesc.h"
17 #include "physxScene.h"
18 #include "physxGroupsMask.h"
19 #include "physxShape.h"
20 #include "physxManager.h"
21 
22 #include "boundingBox.h"
23 
24 TypeHandle PhysxCloth::_type_handle;
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: PhysxCloth::link
28 // Access: Public
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 void PhysxCloth::
32 link(NxCloth *clothPtr) {
33 
34  // Link self
35  _ptr = clothPtr;
36  _error_type = ET_ok;
37  _ptr->userData = this;
38 
39  set_name(clothPtr->getName());
40 
41  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
42  scene->_cloths.add(this);
43 }
44 
45 ////////////////////////////////////////////////////////////////////
46 // Function: PhysxCloth::unlink
47 // Access: Public
48 // Description:
49 ////////////////////////////////////////////////////////////////////
50 void PhysxCloth::
51 unlink() {
52 
53  // Unlink self
54  _ptr->userData = NULL;
55  _error_type = ET_released;
56 
57  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
58  scene->_cloths.remove(this);
59 
60  _node = NULL;
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: PhysxCloth::release
65 // Access: Published
66 // Description:
67 ////////////////////////////////////////////////////////////////////
68 void PhysxCloth::
69 release() {
70 
71  nassertv(_error_type == ET_ok);
72 
73  unlink();
74  _ptr->getScene().releaseCloth(*_ptr);
75  _ptr = NULL;
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: PhysxCloth::update
80 // Access: Public
81 // Description:
82 ////////////////////////////////////////////////////////////////////
83 void PhysxCloth::
84 update() {
85 
86  if (_node) {
87 
88  // Update node mesh data
89  _node->update();
90 
91  // Update node bounding volume
92  NxBounds3 bounds;
93  _ptr->getWorldBounds(bounds);
94 
96  PhysxManager::nxVec3_to_point3(bounds.max));
97  _node->set_bounds(&bb);
98  }
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: PhysxCloth::get_scene
103 // Access: Published
104 // Description: Returns the scene which this cloth belongs to.
105 ////////////////////////////////////////////////////////////////////
107 get_scene() const {
108 
109  nassertr(_error_type == ET_ok, NULL);
110  return (PhysxScene *)_ptr->getScene().userData;
111 }
112 
113 ////////////////////////////////////////////////////////////////////
114 // Function: PhysxCloth::get_cloth_node
115 // Access: Published
116 // Description:
117 ////////////////////////////////////////////////////////////////////
118 PhysxClothNode *PhysxCloth::
119 get_cloth_node() const {
120 
121  nassertr(_error_type == ET_ok, NULL);
122  return _node;
123 }
124 
125 ////////////////////////////////////////////////////////////////////
126 // Function: PhysxCloth::create_cloth_node
127 // Access: Published
128 // Description:
129 ////////////////////////////////////////////////////////////////////
130 PhysxClothNode *PhysxCloth::
131 create_cloth_node(const char *name) {
132 
133  nassertr(_error_type == ET_ok, NULL);
134 
135  _node = new PhysxClothNode(name);
136  _node->allocate(this);
137 
138  return _node;
139 }
140 
141 ////////////////////////////////////////////////////////////////////
142 // Function: PhysxCloth::set_name
143 // Access: Published
144 // Description: Sets a name string for the object that can be
145 // retrieved with get_name().
146 // This is for debugging and is not used by the
147 // engine.
148 ////////////////////////////////////////////////////////////////////
149 void PhysxCloth::
150 set_name(const char *name) {
151 
152  nassertv(_error_type == ET_ok);
153 
154  _name = name ? name : "";
155  _ptr->setName(_name.c_str());
156 }
157 
158 ////////////////////////////////////////////////////////////////////
159 // Function: PhysxCloth::get_name
160 // Access: Published
161 // Description: Retrieves the name string.
162 ////////////////////////////////////////////////////////////////////
163 const char *PhysxCloth::
164 get_name() const {
165 
166  nassertr(_error_type == ET_ok, "");
167  return _ptr->getName();
168 }
169 
170 ////////////////////////////////////////////////////////////////////
171 // Function: PhysxCloth::set_group
172 // Access: Published
173 // Description: Sets which collision group this cloth is part of.
174 // Collision group must be between 0 and 31.
175 ////////////////////////////////////////////////////////////////////
176 void PhysxCloth::
177 set_group(unsigned int group) {
178 
179  nassertv(_error_type == ET_ok);
180  nassertv(group >= 0 && group < 32);
181  _ptr->setGroup(group);
182 }
183 
184 ////////////////////////////////////////////////////////////////////
185 // Function: PhysxCloth::get_group
186 // Access: Published
187 // Description: Retrieves the collision group this cloth is part
188 // of.
189 ////////////////////////////////////////////////////////////////////
190 unsigned int PhysxCloth::
191 get_group() const {
192 
193  nassertr(_error_type == ET_ok, 0);
194  return _ptr->getGroup();
195 }
196 
197 ////////////////////////////////////////////////////////////////////
198 // Function: PhysxCloth::set_thickness
199 // Access: Published
200 // Description: Sets the cloth thickness (must be positive).
201 ////////////////////////////////////////////////////////////////////
202 void PhysxCloth::
203 set_thickness(float thickness) {
204 
205  nassertv(_error_type == ET_ok);
206  _ptr->setThickness(thickness);
207 }
208 
209 ////////////////////////////////////////////////////////////////////
210 // Function: PhysxCloth::get_thickness
211 // Access: Published
212 // Description: Gets the cloth thickness.
213 ////////////////////////////////////////////////////////////////////
214 float PhysxCloth::
215 get_thickness() const {
216 
217  nassertr(_error_type == ET_ok, 0.0f);
218  return _ptr->getThickness();
219 }
220 
221 ////////////////////////////////////////////////////////////////////
222 // Function: PhysxCloth::get_density
223 // Access: Published
224 // Description: Gets the cloth density.
225 ////////////////////////////////////////////////////////////////////
226 float PhysxCloth::
227 get_density() const {
228 
229  nassertr(_error_type == ET_ok, 0.0f);
230  return _ptr->getDensity();
231 }
232 
233 ////////////////////////////////////////////////////////////////////
234 // Function: PhysxCloth::get_relative_grid_spacing
235 // Access: Published
236 // Description: Gets the relative grid spacing for the broad
237 // phase. The cloth is represented by a set of
238 // world aligned cubical cells in broad phase. The
239 // size of these cells is determined by multiplying
240 // the length of the diagonal of the AABB of the
241 // initial soft body size with this constant.
242 ////////////////////////////////////////////////////////////////////
243 float PhysxCloth::
245 
246  nassertr(_error_type == ET_ok, 0.0f);
247  return _ptr->getRelativeGridSpacing();
248 }
249 
250 ////////////////////////////////////////////////////////////////////
251 // Function: PhysxCloth::get_num_particles
252 // Access: Published
253 // Description: Gets the number of cloth particles.
254 ////////////////////////////////////////////////////////////////////
255 unsigned int PhysxCloth::
257 
258  nassertr(_error_type == ET_ok, 0);
259  return _ptr->getNumberOfParticles();
260 }
261 
262 ////////////////////////////////////////////////////////////////////
263 // Function: PhysxCloth::set_flag
264 // Access: Published
265 // Description: Sets the value of a single flag.
266 ////////////////////////////////////////////////////////////////////
267 void PhysxCloth::
268 set_flag(PhysxClothFlag flag, bool value) {
269 
270  nassertv(_error_type == ET_ok);
271 
272  NxU32 flags = _ptr->getFlags();
273 
274  if (value == true) {
275  flags |= flag;
276  }
277  else {
278  flags &= ~(flag);
279  }
280 
281  _ptr->setFlags(flags);
282 }
283 
284 ////////////////////////////////////////////////////////////////////
285 // Function: PhysxCloth::get_flag
286 // Access: Published
287 // Description: Retrieves the value of a single flag.
288 ////////////////////////////////////////////////////////////////////
289 bool PhysxCloth::
290 get_flag(PhysxClothFlag flag) const {
291 
292  nassertr(_error_type == ET_ok, false);
293 
294  return (_ptr->getFlags() & flag) ? true : false;
295 }
296 
297 ////////////////////////////////////////////////////////////////////
298 // Function: PhysxCloth::set_groups_mask
299 // Access: Published
300 // Description: Sets 128-bit mask used for collision filtering.
301 ////////////////////////////////////////////////////////////////////
302 void PhysxCloth::
304 
305  nassertv(_error_type == ET_ok);
306 
307  NxGroupsMask _mask = mask.get_mask();
308  _ptr->setGroupsMask(_mask);
309 }
310 
311 ////////////////////////////////////////////////////////////////////
312 // Function: PhysxCloth::get_groups_mask
313 // Access: Published
314 // Description: Gets the 128-bit groups mask used for collision
315 // filtering.
316 ////////////////////////////////////////////////////////////////////
319 
320  PhysxGroupsMask mask;
321 
322  nassertr(_error_type == ET_ok, mask);
323 
324  NxGroupsMask _mask = _ptr->getGroupsMask();
325  mask.set_mask(_mask);
326 
327  return mask;
328 }
329 
330 ////////////////////////////////////////////////////////////////////
331 // Function: PhysxCloth::is_sleeping
332 // Access: Published
333 // Description: Returns true if this cloth is sleeping.
334 //
335 // When a cloth does not move for a period of time,
336 // it is no longer simulated in order to save time.
337 // This state is called sleeping. However, because the
338 // object automatically wakes up when it is either
339 // touched by an awake object, or one of its
340 // properties is changed by the user, the entire sleep
341 // mechanism should be transparent to the user.
342 ////////////////////////////////////////////////////////////////////
343 bool PhysxCloth::
344 is_sleeping() const {
345 
346  nassertr(_error_type == ET_ok, false);
347  return _ptr->isSleeping();
348 }
349 
350 ////////////////////////////////////////////////////////////////////
351 // Function: PhysxCloth::wake_up
352 // Access: Published
353 // Description: Wakes up the cloth if it is sleeping.
354 //
355 // The wakeCounterValue determines how long until the
356 // body is put to sleep, a value of zero means that
357 // the body is sleeping. wake_up(0) is equivalent to
358 // PhysxCloth::put_to_sleep().
359 ////////////////////////////////////////////////////////////////////
360 void PhysxCloth::
361 wake_up(float wakeCounterValue) {
362 
363  nassertv(_error_type == ET_ok);
364  _ptr->wakeUp(wakeCounterValue);
365 }
366 
367 ////////////////////////////////////////////////////////////////////
368 // Function: PhysxCloth::put_to_sleep
369 // Access: Published
370 // Description: Forces the cloth to sleep.
371 //
372 // The cloth will stay asleep until the next
373 // call to simulate, and will not wake up until then
374 // even when otherwise it would (for example a force
375 // is applied to it). It can however wake up during
376 // the next do_physics call.
377 ////////////////////////////////////////////////////////////////////
378 void PhysxCloth::
380 
381  nassertv(_error_type == ET_ok);
382  _ptr->putToSleep();
383 }
384 
385 ////////////////////////////////////////////////////////////////////
386 // Function: PhysxCloth::set_sleep_linear_velocity
387 // Access: Published
388 // Description: Sets the linear velocity below which an cloth
389 // may go to sleep. Cloths whose linear velocity is
390 // above this threshold will not be put to sleep.
391 //
392 // Setting the sleep angular/linear velocity only
393 // makes sense when the BF_energy_sleep_test is not
394 // set.
395 ////////////////////////////////////////////////////////////////////
396 void PhysxCloth::
397 set_sleep_linear_velocity(float threshold) {
398 
399  nassertv(_error_type == ET_ok);
400  _ptr->setSleepLinearVelocity(threshold);
401 }
402 
403 ////////////////////////////////////////////////////////////////////
404 // Function: PhysxCloth::get_sleep_linear_velocity
405 // Access: Published
406 // Description: Returns the linear velocity below which an soft
407 // body may go to sleep. cloths whose linear velocity
408 // is above this threshold will not be put to sleep.
409 ////////////////////////////////////////////////////////////////////
410 float PhysxCloth::
412 
413  nassertr(_error_type == ET_ok, 0.0f);
414  return _ptr->getSleepLinearVelocity();
415 }
416 
417 ////////////////////////////////////////////////////////////////////
418 // Function: PhysxCloth::attach_vertex_to_global_pos
419 // Access: Published
420 // Description: Attaches a cloth vertex to a position in world
421 // space.
422 ////////////////////////////////////////////////////////////////////
423 void PhysxCloth::
424 attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos) {
425 
426  nassertv(_error_type == ET_ok);
427  nassertv(!pos.is_nan());
428 
429  _ptr->attachVertexToGlobalPosition(vertexId, PhysxManager::point3_to_nxVec3(pos));
430 }
431 
432 ////////////////////////////////////////////////////////////////////
433 // Function: PhysxCloth::attach_to_shape
434 // Access: Published
435 // Description: Attaches the cloth to a shape. All cloth points
436 // currently inside the shape are attached.
437 //
438 // This method only works with primitive and convex
439 // shapes. Since the inside of a general triangle mesh
440 // is not clearly defined.
441 ////////////////////////////////////////////////////////////////////
442 void PhysxCloth::
444 
445  nassertv(_error_type == ET_ok);
446  nassertv(shape);
447 
448  NxU32 attachmentFlags = 0; // --TODO--
449  _ptr->attachToShape(shape->ptr(), attachmentFlags);
450 }
451 
452 ////////////////////////////////////////////////////////////////////
453 // Function: PhysxCloth::attach_to_colliding_shapes
454 // Access: Published
455 // Description: Attaches the cloth to all shapes, currently
456 // colliding.
457 //
458 // This method only works with primitive and convex
459 // shapes. Since the inside of a general triangle mesh
460 // is not clearly defined.
461 ////////////////////////////////////////////////////////////////////
462 void PhysxCloth::
464 
465  nassertv(_error_type == ET_ok);
466 
467  NxU32 attachmentFlags = 0; // --TODO--
468  _ptr->attachToCollidingShapes(attachmentFlags);
469 }
470 
471 ////////////////////////////////////////////////////////////////////
472 // Function: PhysxCloth::detach_from_shape
473 // Access: Published
474 // Description: Detaches the cloth from a shape it has been
475 // attached to before.
476 //
477 // If the cloth has not been attached to the shape
478 // before, the call has no effect.
479 ////////////////////////////////////////////////////////////////////
480 void PhysxCloth::
482 
483  nassertv(_error_type == ET_ok);
484  nassertv(shape);
485 
486  _ptr->detachFromShape(shape->ptr());
487 }
488 
489 ////////////////////////////////////////////////////////////////////
490 // Function: PhysxCloth::free_vertex
491 // Access: Published
492 // Description: Frees a previously attached cloth point.
493 ////////////////////////////////////////////////////////////////////
494 void PhysxCloth::
495 free_vertex(unsigned int vertexId) {
496 
497  nassertv(_error_type == ET_ok);
498  _ptr->freeVertex(vertexId);
499 }
500 
501 ////////////////////////////////////////////////////////////////////
502 // Function: PhysxCloth::attach_vertex_to_shape
503 // Access: Published
504 // Description: Attaches a cloth vertex to a local position within
505 // a shape.
506 ////////////////////////////////////////////////////////////////////
507 void PhysxCloth::
508 attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos) {
509 
510  nassertv(_error_type == ET_ok);
511  nassertv(!localPos.is_nan());
512  nassertv(shape);
513 
514  NxU32 attachmentFlags = 0; // --TODO--
515  _ptr->attachVertexToShape(vertexId, shape->ptr(),
517  attachmentFlags);
518 }
519 
520 ////////////////////////////////////////////////////////////////////
521 // Function: PhysxCloth::get_vertex_attachment_status
522 // Access: Published
523 // Description: Return the attachment status of the given vertex.
524 ////////////////////////////////////////////////////////////////////
525 PhysxEnums::PhysxVertexAttachmentStatus PhysxCloth::
526 get_vertex_attachment_status(unsigned int vertexId) const {
527 
528  nassertr(_error_type == ET_ok, VAS_none);
529  // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), VAS_none);
530 
531  return (PhysxVertexAttachmentStatus) _ptr->getVertexAttachmentStatus(vertexId);
532 }
533 
534 ////////////////////////////////////////////////////////////////////
535 // Function: PhysxCloth::get_vertex_attachment_shape
536 // Access: Published
537 // Description: Returns the pointer to an attached shape pointer
538 // of the given vertex. If the vertex is not attached
539 // or attached to a global position, NULL is returned.
540 ////////////////////////////////////////////////////////////////////
542 get_vertex_attachment_shape(unsigned int vertexId) const {
543 
544  nassertr(_error_type == ET_ok, NULL);
545  // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), NULL);
546 
547  NxShape *shapePtr = _ptr->getVertexAttachmentShape(vertexId);
548  PhysxShape *shape = shapePtr ? (PhysxShape *)(shapePtr->userData) : NULL;
549 
550  return shape;
551 }
552 
553 ////////////////////////////////////////////////////////////////////
554 // Function: PhysxCloth::get_vertex_attachment_pos
555 // Access: Published
556 // Description: Returns the attachment position of the given
557 // vertex. If the vertex is attached to shape, the
558 // position local to the shape's pose is returned. If
559 // the vertex is not attached, the return value is
560 // undefined.
561 ////////////////////////////////////////////////////////////////////
563 get_vertex_attachment_pos(unsigned int vertexId) const {
564 
565  nassertr(_error_type == ET_ok, LPoint3f::zero());
566  // --TODO-- nassertr(vertexId < _ptr->getNumberOfParticles(), LPoint3f::zero());
567 
568  return PhysxManager::nxVec3_to_point3(_ptr->getVertexAttachmentPosition(vertexId));
569 }
570 
571 ////////////////////////////////////////////////////////////////////
572 // Function: PhysxCloth::set_external_acceleration
573 // Access: Published
574 // Description: Sets an external acceleration which affects all non
575 // attached particles of the cloth.
576 ////////////////////////////////////////////////////////////////////
577 void PhysxCloth::
578 set_external_acceleration(LVector3f const &acceleration) {
579 
580  nassertv(_error_type == ET_ok);
581  nassertv_always(!acceleration.is_nan());
582 
583  _ptr->setExternalAcceleration(PhysxManager::vec3_to_nxVec3(acceleration));
584 }
585 
586 ////////////////////////////////////////////////////////////////////
587 // Function: PhysxCloth::set_wind_acceleration
588 // Access: Published
589 // Description: Sets an acceleration acting normal to the cloth
590 // surface at each vertex.
591 ////////////////////////////////////////////////////////////////////
592 void PhysxCloth::
593 set_wind_acceleration(LVector3f const &acceleration) {
594 
595  nassertv(_error_type == ET_ok);
596  nassertv_always(!acceleration.is_nan());
597 
598  _ptr->setWindAcceleration(PhysxManager::vec3_to_nxVec3(acceleration));
599 }
600 
601 ////////////////////////////////////////////////////////////////////
602 // Function: PhysxCloth::get_external_acceleration
603 // Access: Published
604 // Description: Retrieves the external acceleration which affects
605 // all non attached particles of the cloth.
606 ////////////////////////////////////////////////////////////////////
609 
610  nassertr(_error_type == ET_ok, LVector3f::zero());
611  return PhysxManager::nxVec3_to_vec3(_ptr->getExternalAcceleration());
612 }
613 
614 ////////////////////////////////////////////////////////////////////
615 // Function: PhysxCloth::get_wind_acceleration
616 // Access: Published
617 // Description: Retrieves the acceleration acting normal to the
618 // cloth surface at each vertex
619 ////////////////////////////////////////////////////////////////////
622 
623  nassertr(_error_type == ET_ok, LVector3f::zero());
624  return PhysxManager::nxVec3_to_vec3(_ptr->getWindAcceleration());
625 }
626 
627 ////////////////////////////////////////////////////////////////////
628 // Function: PhysxCloth::add_force_at_vertex
629 // Access: Published
630 // Description: Applies a force (or impulse) defined in the
631 // global coordinate frame, to a particular vertex
632 // of the cloth.
633 ////////////////////////////////////////////////////////////////////
634 void PhysxCloth::
635 add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode) {
636 
637  nassertv(_error_type == ET_ok);
638  _ptr->addForceAtVertex(PhysxManager::vec3_to_nxVec3(force),
639  vertexId,
640  (NxForceMode) mode);
641 }
642 
643 ////////////////////////////////////////////////////////////////////
644 // Function: PhysxCloth::add_force_at_pos
645 // Access: Published
646 // Description: Applies a radial force (or impulse) at a
647 // particular position. All vertices within radius
648 // will be affected with a quadratic drop-off.
649 ////////////////////////////////////////////////////////////////////
650 void PhysxCloth::
651 add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceMode mode) {
652 
653  nassertv(_error_type == ET_ok);
654  _ptr->addForceAtPos(PhysxManager::point3_to_nxVec3(pos),
655  magnitude,
656  radius,
657  (NxForceMode) mode);
658 }
659 
660 ////////////////////////////////////////////////////////////////////
661 // Function: PhysxCloth::add_directed_force_at_pos
662 // Access: Published
663 // Description: Applies a directed force (or impulse) at a
664 // particular position. All vertices within radius
665 // will be affected with a quadratic drop-off.
666 ////////////////////////////////////////////////////////////////////
667 void PhysxCloth::
668 add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, PhysxForceMode mode) {
669 
670  nassertv(_error_type == ET_ok);
671  _ptr->addDirectedForceAtPos(PhysxManager::point3_to_nxVec3(pos),
673  radius,
674  (NxForceMode) mode);
675 }
676 
bool is_sleeping() const
Returns true if this cloth is sleeping.
Definition: physxCloth.cxx:344
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
Definition: boundingBox.h:31
void add_force_at_vertex(LVector3f const &force, int vertexId, PhysxForceMode mode=FM_force)
Applies a force (or impulse) defined in the global coordinate frame, to a particular vertex of the cl...
Definition: physxCloth.cxx:635
unsigned int get_num_particles()
Gets the number of cloth particles.
Definition: physxCloth.cxx:256
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the cloth if it is sleeping.
Definition: physxCloth.cxx:361
void attach_to_shape(PhysxShape *shape)
Attaches the cloth to a shape.
Definition: physxCloth.cxx:443
void detach_from_shape(PhysxShape *shape)
Detaches the cloth from a shape it has been attached to before.
Definition: physxCloth.cxx:481
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.
Definition: physxCloth.cxx:411
static const LPoint3f & zero()
Returns a zero-length point.
Definition: lpoint3.h:258
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:77
unsigned int get_group() const
Retrieves the collision group this cloth is part of.
Definition: physxCloth.cxx:191
Abstract base class for shapes.
Definition: physxShape.h:41
static const LVector3f & zero()
Returns a zero-length vector.
Definition: lvector3.h:269
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
Definition: physxCloth.cxx:150
void set_group(unsigned int group)
Sets which collision group this cloth is part of.
Definition: physxCloth.cxx:177
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
Definition: lvector3.h:100
void attach_to_colliding_shapes()
Attaches the cloth to all shapes, currently colliding.
Definition: physxCloth.cxx:463
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
A scene is a collection of bodies, constraints, and effectors which can interact. ...
Definition: physxScene.h:73
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:463
float get_thickness() const
Gets the cloth thickness.
Definition: physxCloth.cxx:215
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
Definition: physxCloth.cxx:303
PhysxGroupsMask get_groups_mask() const
Gets the 128-bit groups mask used for collision filtering.
Definition: physxCloth.cxx:318
void add_force_at_pos(LPoint3f const &pos, float magnitude, float radius, PhysxForceMode mode=FM_force)
Applies a radial force (or impulse) at a particular position.
Definition: physxCloth.cxx:651
void put_to_sleep()
Forces the cloth to sleep.
Definition: physxCloth.cxx:379
void free_vertex(unsigned int vertexId)
Frees a previously attached cloth point.
Definition: physxCloth.cxx:495
void set_wind_acceleration(LVector3f const &acceleration)
Sets an acceleration acting normal to the cloth surface at each vertex.
Definition: physxCloth.cxx:593
PhysxShape * get_vertex_attachment_shape(unsigned int vertexId) const
Returns the pointer to an attached shape pointer of the given vertex.
Definition: physxCloth.cxx:542
const char * get_name() const
Retrieves the name string.
Definition: physxCloth.cxx:164
void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos)
Attaches a cloth vertex to a local position within a shape.
Definition: physxCloth.cxx:508
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:33
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an cloth may go to sleep.
Definition: physxCloth.cxx:397
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:44
void set_external_acceleration(LVector3f const &acceleration)
Sets an external acceleration which affects all non attached particles of the cloth.
Definition: physxCloth.cxx:578
void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos)
Attaches a cloth vertex to a position in world space.
Definition: physxCloth.cxx:424
PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const
Return the attachment status of the given vertex.
Definition: physxCloth.cxx:526
void set_thickness(float thickness)
Sets the cloth thickness (must be positive).
Definition: physxCloth.cxx:203
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:88
LVector3f get_wind_acceleration() const
Retrieves the acceleration acting normal to the cloth surface at each vertex.
Definition: physxCloth.cxx:621
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
bool get_flag(PhysxClothFlag flag) const
Retrieves the value of a single flag.
Definition: physxCloth.cxx:290
void set_flag(PhysxClothFlag flag, bool value)
Sets the value of a single flag.
Definition: physxCloth.cxx:268
LVector3f get_external_acceleration() const
Retrieves the external acceleration which affects all non attached particles of the cloth...
Definition: physxCloth.cxx:608
float get_relative_grid_spacing() const
Gets the relative grid spacing for the broad phase.
Definition: physxCloth.cxx:244
void add_directed_force_at_pos(LPoint3f const &pos, LVector3f const &force, float radius, PhysxForceMode mode=FM_force)
Applies a directed force (or impulse) at a particular position.
Definition: physxCloth.cxx:668
LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const
Returns the attachment position of the given vertex.
Definition: physxCloth.cxx:563
Renderable geometry which represents a cloth mesh.
float get_density() const
Gets the cloth density.
Definition: physxCloth.cxx:227
PhysxScene * get_scene() const
Returns the scene which this cloth belongs to.
Definition: physxCloth.cxx:107
128-bit bitmask class.