29 link(NxCloth *clothPtr) {
34 _ptr->userData =
this;
39 scene->_cloths.add(
this);
49 _ptr->userData =
nullptr;
50 _error_type = ET_released;
53 scene->_cloths.remove(
this);
64 nassertv(_error_type == ET_ok);
67 _ptr->getScene().releaseCloth(*_ptr);
84 _ptr->getWorldBounds(bounds);
88 _node->set_bounds(&bb);
98 nassertr(_error_type == ET_ok,
nullptr);
99 return (
PhysxScene *)_ptr->getScene().userData;
106 get_cloth_node()
const {
108 nassertr(_error_type == ET_ok,
nullptr);
116 create_cloth_node(
const char *name) {
118 nassertr(_error_type == ET_ok,
nullptr);
121 _node->allocate(
this);
133 nassertv(_error_type == ET_ok);
135 _name = name ? name :
"";
136 _ptr->setName(_name.c_str());
145 nassertr(_error_type == ET_ok,
"");
146 return _ptr->getName();
156 nassertv(_error_type == ET_ok);
157 nassertv(group >= 0 && group < 32);
158 _ptr->setGroup(group);
167 nassertr(_error_type == ET_ok, 0);
168 return _ptr->getGroup();
177 nassertv(_error_type == ET_ok);
178 _ptr->setThickness(thickness);
187 nassertr(_error_type == ET_ok, 0.0f);
188 return _ptr->getThickness();
197 nassertr(_error_type == ET_ok, 0.0f);
198 return _ptr->getDensity();
210 nassertr(_error_type == ET_ok, 0.0f);
211 return _ptr->getRelativeGridSpacing();
220 nassertr(_error_type == ET_ok, 0);
221 return _ptr->getNumberOfParticles();
230 nassertv(_error_type == ET_ok);
232 NxU32 flags = _ptr->getFlags();
241 _ptr->setFlags(flags);
250 nassertr(_error_type == ET_ok,
false);
252 return (_ptr->getFlags() & flag) ?
true :
false;
261 nassertv(_error_type == ET_ok);
263 NxGroupsMask _mask = mask.get_mask();
264 _ptr->setGroupsMask(_mask);
275 nassertr(_error_type == ET_ok, mask);
277 NxGroupsMask _mask = _ptr->getGroupsMask();
278 mask.set_mask(_mask);
295 nassertr(_error_type == ET_ok,
false);
296 return _ptr->isSleeping();
309 nassertv(_error_type == ET_ok);
310 _ptr->wakeUp(wakeCounterValue);
323 nassertv(_error_type == ET_ok);
337 nassertv(_error_type == ET_ok);
338 _ptr->setSleepLinearVelocity(threshold);
349 nassertr(_error_type == ET_ok, 0.0f);
350 return _ptr->getSleepLinearVelocity();
359 nassertv(_error_type == ET_ok);
360 nassertv(!pos.is_nan());
375 nassertv(_error_type == ET_ok);
378 NxU32 attachmentFlags = 0;
379 _ptr->attachToShape(shape->ptr(), attachmentFlags);
391 nassertv(_error_type == ET_ok);
393 NxU32 attachmentFlags = 0;
394 _ptr->attachToCollidingShapes(attachmentFlags);
406 nassertv(_error_type == ET_ok);
409 _ptr->detachFromShape(shape->ptr());
418 nassertv(_error_type == ET_ok);
419 _ptr->freeVertex(vertexId);
428 nassertv(_error_type == ET_ok);
429 nassertv(!localPos.is_nan());
432 NxU32 attachmentFlags = 0;
433 _ptr->attachVertexToShape(vertexId, shape->ptr(),
444 nassertr(_error_type == ET_ok, VAS_none);
447 return (PhysxVertexAttachmentStatus) _ptr->getVertexAttachmentStatus(vertexId);
458 nassertr(_error_type == ET_ok,
nullptr);
461 NxShape *shapePtr = _ptr->getVertexAttachmentShape(vertexId);
475 nassertr(_error_type == ET_ok, LPoint3f::zero());
489 nassertv(_error_type == ET_ok);
490 nassertv_always(!acceleration.is_nan());
501 nassertv(_error_type == ET_ok);
502 nassertv_always(!acceleration.is_nan());
514 nassertr(_error_type == ET_ok, LVector3f::zero());
525 nassertr(_error_type == ET_ok, LVector3f::zero());
536 nassertv(_error_type == ET_ok);
547 add_force_at_pos(LPoint3f
const &pos,
float magnitude,
float radius, PhysxForceMode mode) {
549 nassertv(_error_type == ET_ok);
563 nassertv(_error_type == ET_ok);
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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...
unsigned int get_num_particles()
Gets the number of cloth particles.
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the cloth if it is sleeping.
PhysxScene * get_scene() const
Returns the scene which this cloth belongs to.
void attach_to_shape(PhysxShape *shape)
Attaches the cloth to a shape.
void detach_from_shape(PhysxShape *shape)
Detaches the cloth from a shape it has been attached to before.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Abstract base class for shapes.
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
void set_group(unsigned int group)
Sets which collision group this cloth is part of.
PhysxVertexAttachmentStatus get_vertex_attachment_status(unsigned int vertexId) const
Return the attachment status of the given vertex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
float get_thickness() const
Gets the cloth thickness.
void attach_to_colliding_shapes()
Attaches the cloth to all shapes, currently colliding.
A scene is a collection of bodies, constraints, and effectors which can interact.
float get_relative_grid_spacing() const
Gets the relative grid spacing for the broad phase.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
float get_density() const
Gets the cloth density.
void set_groups_mask(const PhysxGroupsMask &mask)
Sets 128-bit mask used for collision filtering.
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.
void put_to_sleep()
Forces the cloth to sleep.
PhysxShape * get_vertex_attachment_shape(unsigned int vertexId) const
Returns the pointer to an attached shape pointer of the given vertex.
void free_vertex(unsigned int vertexId)
Frees a previously attached cloth point.
void set_wind_acceleration(LVector3f const &acceleration)
Sets an acceleration acting normal to the cloth surface at each vertex.
LVector3f get_external_acceleration() const
Retrieves the external acceleration which affects all non attached particles of the cloth.
void attach_vertex_to_shape(unsigned int vertexId, PhysxShape *shape, LPoint3f const &localPos)
Attaches a cloth vertex to a local position within a shape.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
bool is_sleeping() const
Returns true if this cloth is sleeping.
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an cloth may go to sleep.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
void set_external_acceleration(LVector3f const &acceleration)
Sets an external acceleration which affects all non attached particles of the cloth.
void attach_vertex_to_global_pos(unsigned int vertexId, LPoint3f const &pos)
Attaches a cloth vertex to a position in world space.
LVector3f get_wind_acceleration() const
Retrieves the acceleration acting normal to the cloth surface at each vertex.
LPoint3f get_vertex_attachment_pos(unsigned int vertexId) const
Returns the attachment position of the given vertex.
PhysxGroupsMask get_groups_mask() const
Gets the 128-bit groups mask used for collision filtering.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_thickness(float thickness)
Sets the cloth thickness (must be positive).
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
unsigned int get_group() const
Retrieves the collision group this cloth is part of.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
const char * get_name() const
Retrieves the name string.
void set_flag(PhysxClothFlag flag, bool value)
Sets the value of a single flag.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
Renderable geometry which represents a cloth mesh.
bool get_flag(PhysxClothFlag flag) const
Retrieves the value of a single flag.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.