15 #include "physxCloth.h" 16 #include "physxClothDesc.h" 17 #include "physxScene.h" 18 #include "physxGroupsMask.h" 19 #include "physxShape.h" 20 #include "physxManager.h" 22 #include "boundingBox.h" 32 link(NxCloth *clothPtr) {
37 _ptr->userData =
this;
42 scene->_cloths.add(
this);
54 _ptr->userData = NULL;
55 _error_type = ET_released;
58 scene->_cloths.remove(
this);
71 nassertv(_error_type == ET_ok);
74 _ptr->getScene().releaseCloth(*_ptr);
93 _ptr->getWorldBounds(bounds);
97 _node->set_bounds(&bb);
109 nassertr(_error_type == ET_ok, NULL);
110 return (
PhysxScene *)_ptr->getScene().userData;
119 get_cloth_node()
const {
121 nassertr(_error_type == ET_ok, NULL);
131 create_cloth_node(
const char *name) {
133 nassertr(_error_type == ET_ok, NULL);
136 _node->allocate(
this);
152 nassertv(_error_type == ET_ok);
154 _name = name ? name :
"";
155 _ptr->setName(_name.c_str());
166 nassertr(_error_type == ET_ok,
"");
167 return _ptr->getName();
179 nassertv(_error_type == ET_ok);
180 nassertv(group >= 0 && group < 32);
181 _ptr->setGroup(group);
193 nassertr(_error_type == ET_ok, 0);
194 return _ptr->getGroup();
205 nassertv(_error_type == ET_ok);
206 _ptr->setThickness(thickness);
217 nassertr(_error_type == ET_ok, 0.0f);
218 return _ptr->getThickness();
229 nassertr(_error_type == ET_ok, 0.0f);
230 return _ptr->getDensity();
246 nassertr(_error_type == ET_ok, 0.0f);
247 return _ptr->getRelativeGridSpacing();
258 nassertr(_error_type == ET_ok, 0);
259 return _ptr->getNumberOfParticles();
270 nassertv(_error_type == ET_ok);
272 NxU32 flags = _ptr->getFlags();
281 _ptr->setFlags(flags);
292 nassertr(_error_type == ET_ok,
false);
294 return (_ptr->getFlags() & flag) ?
true :
false;
305 nassertv(_error_type == ET_ok);
307 NxGroupsMask _mask = mask.get_mask();
308 _ptr->setGroupsMask(_mask);
322 nassertr(_error_type == ET_ok, mask);
324 NxGroupsMask _mask = _ptr->getGroupsMask();
325 mask.set_mask(_mask);
346 nassertr(_error_type == ET_ok,
false);
347 return _ptr->isSleeping();
363 nassertv(_error_type == ET_ok);
364 _ptr->wakeUp(wakeCounterValue);
381 nassertv(_error_type == ET_ok);
399 nassertv(_error_type == ET_ok);
400 _ptr->setSleepLinearVelocity(threshold);
413 nassertr(_error_type == ET_ok, 0.0f);
414 return _ptr->getSleepLinearVelocity();
426 nassertv(_error_type == ET_ok);
445 nassertv(_error_type == ET_ok);
448 NxU32 attachmentFlags = 0;
449 _ptr->attachToShape(shape->ptr(), attachmentFlags);
465 nassertv(_error_type == ET_ok);
467 NxU32 attachmentFlags = 0;
468 _ptr->attachToCollidingShapes(attachmentFlags);
483 nassertv(_error_type == ET_ok);
486 _ptr->detachFromShape(shape->ptr());
497 nassertv(_error_type == ET_ok);
498 _ptr->freeVertex(vertexId);
510 nassertv(_error_type == ET_ok);
511 nassertv(!localPos.
is_nan());
514 NxU32 attachmentFlags = 0;
515 _ptr->attachVertexToShape(vertexId, shape->ptr(),
528 nassertr(_error_type == ET_ok, VAS_none);
531 return (PhysxVertexAttachmentStatus) _ptr->getVertexAttachmentStatus(vertexId);
544 nassertr(_error_type == ET_ok, NULL);
547 NxShape *shapePtr = _ptr->getVertexAttachmentShape(vertexId);
580 nassertv(_error_type == ET_ok);
581 nassertv_always(!acceleration.
is_nan());
595 nassertv(_error_type == ET_ok);
596 nassertv_always(!acceleration.
is_nan());
637 nassertv(_error_type == ET_ok);
653 nassertv(_error_type == ET_ok);
670 nassertv(_error_type == ET_ok);
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
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 const LPoint3f & zero()
Returns a zero-length point.
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Abstract base class for shapes.
static const LVector3f & zero()
Returns a zero-length vector.
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.
float get_thickness() const
Gets the cloth thickness.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
void attach_to_colliding_shapes()
Attaches the cloth to all shapes, currently colliding.
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
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.
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
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.
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.
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.
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.
float get_sleep_linear_velocity() const
Returns the linear velocity below which an soft body may go to sleep.