Open 3D Engine NvCloth Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
NvCloth::Cloth Class Reference

Implementation of the ICloth and IClothConfigurator interfaces. More...

#include <Cloth.h>

Inherits NvCloth::ICloth, and NvCloth::IClothConfigurator.

Public Member Functions

 AZ_RTTI (Cloth, "{D9DEED18-FEF2-440B-8639-A080F8C1F6DB}", ICloth)
 
 Cloth (ClothId id, const AZStd::vector< SimParticleFormat > &initialParticles, Fabric *fabric, NvClothUniquePtr nvCloth)
 
FabricGetFabric ()
 Returns the fabric used to create this cloth.
 
SolverGetSolver ()
 Returns the solver this cloth is added to or nullptr if it's not part of any solver.
 
void Update ()
 Retrieves the latest simulation data from NvCloth and updates the particles.
 
ClothId GetId () const override
 Returns the cloth identifier.
 
const AZStd::vector< SimParticleFormat > & GetInitialParticles () const override
 Returns the list of particles (positions and inverse mass) used when the cloth was created.
 
const AZStd::vector< SimIndexType > & GetInitialIndices () const override
 Returns the list of triangles' indices used when the cloth's fabric was created.
 
const AZStd::vector< SimParticleFormat > & GetParticles () const override
 Returns the current list of particles (positions and inverse mass) of cloth.
 
void SetParticles (const AZStd::vector< SimParticleFormat > &particles) override
 
void SetParticles (AZStd::vector< SimParticleFormat > &&particles) override
 
void DiscardParticleDelta () override
 
const FabricCookedDataGetFabricCookedData () const override
 Returns the FabricCookedData used when the cloth was created.
 
IClothConfiguratorGetClothConfigurator () override
 
void SetTransform (const AZ::Transform &transformWorld) override
 Sets world transform to cloth.
 
void ClearInertia () override
 Clears inertia derived from SetTransform to zero.
 
void SetMass (float mass) override
 
void SetGravity (const AZ::Vector3 &gravity) override
 Gravity applied to cloth during simulation.
 
void SetStiffnessFrequency (float frequency) override
 
void SetDamping (const AZ::Vector3 &damping) override
 
void SetDampingLinearDrag (const AZ::Vector3 &linearDrag) override
 
void SetDampingAngularDrag (const AZ::Vector3 &angularDrag) override
 
void SetLinearInertia (const AZ::Vector3 &linearInertia) override
 
void SetAngularInertia (const AZ::Vector3 &angularInertia) override
 
void SetCentrifugalInertia (const AZ::Vector3 &centrifugalInertia) override
 
void SetWindVelocity (const AZ::Vector3 &velocity) override
 
void SetWindDragCoefficient (float drag) override
 
void SetWindLiftCoefficient (float lift) override
 
void SetWindFluidDensity (float density) override
 
void SetCollisionFriction (float friction) override
 
void SetCollisionMassScale (float scale) override
 
void EnableContinuousCollision (bool value) override
 
void SetCollisionAffectsStaticParticles (bool value) override
 Enables/Disables colliders affecting static particles (inverse mass 0.0).
 
void SetSelfCollisionDistance (float distance) override
 
void SetSelfCollisionStiffness (float stiffness) override
 
void SetVerticalPhaseConfig (float stiffness, float stiffnessMultiplier, float compressionLimit, float stretchLimit) override
 
void SetHorizontalPhaseConfig (float stiffness, float stiffnessMultiplier, float compressionLimit, float stretchLimit) override
 
void SetBendingPhaseConfig (float stiffness, float stiffnessMultiplier, float compressionLimit, float stretchLimit) override
 
void SetShearingPhaseConfig (float stiffness, float stiffnessMultiplier, float compressionLimit, float stretchLimit) override
 
void SetTetherConstraintStiffness (float stiffness) override
 
void SetTetherConstraintScale (float scale) override
 
void SetSolverFrequency (float frequency) override
 
void SetAcceleationFilterWidth (AZ::u32 width) override
 
void SetSphereColliders (const AZStd::vector< AZ::Vector4 > &spheres) override
 
void SetSphereColliders (AZStd::vector< AZ::Vector4 > &&spheres) override
 
void SetCapsuleColliders (const AZStd::vector< AZ::u32 > &capsuleIndices) override
 
void SetCapsuleColliders (AZStd::vector< AZ::u32 > &&capsuleIndices) override
 
void SetMotionConstraints (const AZStd::vector< AZ::Vector4 > &constraints) override
 
void SetMotionConstraints (AZStd::vector< AZ::Vector4 > &&constraints) override
 
void ClearMotionConstraints () override
 Clear the list of motion constraints.
 
void SetMotionConstraintsScale (float scale) override
 
void SetMotionConstraintsBias (float bias) override
 
void SetMotionConstraintsStiffness (float stiffness) override
 
void SetSeparationConstraints (const AZStd::vector< AZ::Vector4 > &constraints) override
 
void SetSeparationConstraints (AZStd::vector< AZ::Vector4 > &&constraints) override
 
void ClearSeparationConstraints () override
 Clear the list of separation constraints.
 
- Public Member Functions inherited from NvCloth::ICloth
 AZ_RTTI (ICloth, "{78817F38-E4A5-4B94-BCD8-3E3B73F66B5A}")
 
void ConnectPreSimulationEventHandler (PreSimulationEvent::Handler &handler)
 
void ConnectPostSimulationEventHandler (PostSimulationEvent::Handler &handler)
 

Friends

class Solver
 

Additional Inherited Members

- Public Types inherited from NvCloth::ICloth
using PreSimulationEvent = AZ::Event< ClothId, float >
 
using PostSimulationEvent = AZ::Event< ClothId, float, const AZStd::vector< SimParticleFormat > & >
 
- Protected Attributes inherited from NvCloth::ICloth
PreSimulationEvent m_preSimulationEvent
 
PostSimulationEvent m_postSimulationEvent
 

Detailed Description

Implementation of the ICloth and IClothConfigurator interfaces.

Member Function Documentation

◆ DiscardParticleDelta()

void NvCloth::Cloth::DiscardParticleDelta ( )
overridevirtual

Makes current and previous particles the same, the next simulation will not have any effect since delta positions will be zero.

Implements NvCloth::ICloth.

◆ EnableContinuousCollision()

void NvCloth::Cloth::EnableContinuousCollision ( bool  value)
overridevirtual

Enables/Disables continuous collision detection. Enabling it improves collision by computing time of impact between cloth particles and colliders.

Note
The increase in quality comes with a cost in performance, it's recommended to use only when required.

Implements NvCloth::IClothConfigurator.

◆ GetClothConfigurator()

IClothConfigurator* NvCloth::Cloth::GetClothConfigurator ( )
overridevirtual

Returns the interface to IClothConfigurator to set all cloth parameters that define its behavior during simulation.

Implements NvCloth::ICloth.

◆ SetAcceleationFilterWidth()

void NvCloth::Cloth::SetAcceleationFilterWidth ( AZ::u32  width)
overridevirtual

Number of iterations to average delta time factor used for gravity and external acceleration. Width valid values are > 0.

Implements NvCloth::IClothConfigurator.

◆ SetAngularInertia()

void NvCloth::Cloth::SetAngularInertia ( const AZ::Vector3 &  angularInertia)
overridevirtual

Portion of angular acceleration applied to turning particles. 0.0: Particles are unaffected. 1.0: Physically correct.

Implements NvCloth::IClothConfigurator.

◆ SetBendingPhaseConfig()

void NvCloth::Cloth::SetBendingPhaseConfig ( float  stiffness,
float  stiffnessMultiplier,
float  compressionLimit,
float  stretchLimit 
)
overridevirtual

Configures bending constraints parameters.

Note
Applicable only if cloth has bending constraints, which is decided by the internal cooking process of the fabric.
Parameters
stiffnessStiffness value of bending constraints. 0.0: no bending constraints.
stiffnessMultiplierScale value for compression and stretch limits. 0.0: No horizontal compression and stretch limits applied. 1.0: Fully apply compression and stretch limits.
compressionLimitCompression limit for bending constraints. 0.0: No compression.
stretchLimitStretch limit for bending constraints. Reduce stiffness of tether constraints (or increase its scale beyond 1.0) to allow cloth to stretch. 0.0: No stretching.

Implements NvCloth::IClothConfigurator.

◆ SetCapsuleColliders() [1/2]

void NvCloth::Cloth::SetCapsuleColliders ( AZStd::vector< AZ::u32 > &&  capsuleIndices)
overridevirtual

Set a list of capsules to collide with cloth's particles (rvalue overload). Each capsule is formed by 2 indices to sphere colliders.

Note
Each cloth can have a maximum of 32 capsule colliders. In the case that all capsules use unique spheres that maximum number would go down to 16, limited by the maximum number of spheres (32).

Implements NvCloth::IClothConfigurator.

◆ SetCapsuleColliders() [2/2]

void NvCloth::Cloth::SetCapsuleColliders ( const AZStd::vector< AZ::u32 > &  capsuleIndices)
overridevirtual

Set a list of capsules to collide with cloth's particles. Each capsule is formed by 2 indices to sphere colliders.

Note
Each cloth can have a maximum of 32 capsule colliders. In the case that all capsules use unique spheres that maximum number would go down to 16, limited by the maximum number of spheres (32).

Implements NvCloth::IClothConfigurator.

◆ SetCentrifugalInertia()

void NvCloth::Cloth::SetCentrifugalInertia ( const AZ::Vector3 &  centrifugalInertia)
overridevirtual

Portion of angular velocity applied to turning particles. 0.0: Particles are unaffected. 1.0: Physically correct.

Implements NvCloth::IClothConfigurator.

◆ SetCollisionFriction()

void NvCloth::Cloth::SetCollisionFriction ( float  friction)
overridevirtual

Amount of friction with colliders. 0.0: No friction. Friction valid values are >= 0.0.

Implements NvCloth::IClothConfigurator.

◆ SetCollisionMassScale()

void NvCloth::Cloth::SetCollisionMassScale ( float  scale)
overridevirtual

Controls how quickly mass is increased during collisions. 0.0: No mass scaling. Scale valid values are >= 0.0.

Implements NvCloth::IClothConfigurator.

◆ SetDamping()

void NvCloth::Cloth::SetDamping ( const AZ::Vector3 &  damping)
overridevirtual

Damping of particles' velocity. 0.0: Velocity is unaffected. 1.0: Velocity is zeroed.

Implements NvCloth::IClothConfigurator.

◆ SetDampingAngularDrag()

void NvCloth::Cloth::SetDampingAngularDrag ( const AZ::Vector3 &  angularDrag)
overridevirtual

Portion of angular velocity applied to turning particles. 0.0: Particles is unaffected. 1.0: Damped global particle angular velocity.

Implements NvCloth::IClothConfigurator.

◆ SetDampingLinearDrag()

void NvCloth::Cloth::SetDampingLinearDrag ( const AZ::Vector3 &  linearDrag)
overridevirtual

Portion of velocity applied to particles. 0.0: Particles is unaffected. 1.0: Damped global particle velocity.

Implements NvCloth::IClothConfigurator.

◆ SetHorizontalPhaseConfig()

void NvCloth::Cloth::SetHorizontalPhaseConfig ( float  stiffness,
float  stiffnessMultiplier,
float  compressionLimit,
float  stretchLimit 
)
overridevirtual

Configures horizontal constraints parameters.

Note
Applicable only if cloth has horizontal constraints, which is decided by the internal cooking process of the fabric.
Parameters
stiffnessStiffness value of horizontal constraints. 0.0: no horizontal constraints.
stiffnessMultiplierScale value for compression and stretch limits. 0.0: No horizontal compression and stretch limits applied. 1.0: Fully apply compression and stretch limits.
compressionLimitCompression limit for horizontal constraints. 0.0: No compression.
stretchLimitStretch limit for horizontal constraints. Reduce stiffness of tether constraints (or increase its scale beyond 1.0) to allow cloth to stretch. 0.0: No stretching.

Implements NvCloth::IClothConfigurator.

◆ SetLinearInertia()

void NvCloth::Cloth::SetLinearInertia ( const AZ::Vector3 &  linearInertia)
overridevirtual

Portion of acceleration applied to particles. 0.0: Particles are unaffected. 1.0: Physically correct.

Implements NvCloth::IClothConfigurator.

◆ SetMass()

void NvCloth::Cloth::SetMass ( float  mass)
overridevirtual

Mass scale applied to all particles, zero makes all particles static.

Note
This function results in a copy of all particle data to NvCloth and therefore it's not a fast operation.

Implements NvCloth::IClothConfigurator.

◆ SetMotionConstraints() [1/2]

void NvCloth::Cloth::SetMotionConstraints ( AZStd::vector< AZ::Vector4 > &&  constraints)
overridevirtual

Sets the motion constraints (positions and radius) for cloth. Each particle's movement during simulation will be limited to the volume of a sphere.

Parameters
constraintsList of constraints (positions and radius) to set (rvalue overload).
Note
Partial set is not allowed, the list must include one constraint per particle.

Implements NvCloth::IClothConfigurator.

◆ SetMotionConstraints() [2/2]

void NvCloth::Cloth::SetMotionConstraints ( const AZStd::vector< AZ::Vector4 > &  constraints)
overridevirtual

Sets the motion constraints (positions and radius) for cloth. Each particle's movement during simulation will be limited to the volume of a sphere.

Parameters
constraintsList of constraints (positions and radius) to set.
Note
Partial set is not allowed, the list must include one constraint per particle.

Implements NvCloth::IClothConfigurator.

◆ SetMotionConstraintsBias()

void NvCloth::Cloth::SetMotionConstraintsBias ( float  bias)
overridevirtual

Sets the bias to be applied to all motion constraints. The bias value will be added to the radius of all motion constraints.

Note
Internally clamped to avoid negative radius.

Implements NvCloth::IClothConfigurator.

◆ SetMotionConstraintsScale()

void NvCloth::Cloth::SetMotionConstraintsScale ( float  scale)
overridevirtual

Sets the scale to be applied to all motion constraints. The radius of all motion constraints will be multiplied by the scale.

Note
Internally clamped to avoid negative radius.

Implements NvCloth::IClothConfigurator.

◆ SetMotionConstraintsStiffness()

void NvCloth::Cloth::SetMotionConstraintsStiffness ( float  stiffness)
overridevirtual

Stiffness for motion constraints. Stiffness range is [0.0, 1.0].

Implements NvCloth::IClothConfigurator.

◆ SetParticles() [1/2]

void NvCloth::Cloth::SetParticles ( AZStd::vector< SimParticleFormat > &&  particles)
overridevirtual

Sets the current particles (positions and inverse mass) for cloth.

Parameters
particlesList of particles to set (rvalue overload).
Note
This function results in a copy of all particle data to NvCloth and therefore it's not a fast operation.

Implements NvCloth::ICloth.

◆ SetParticles() [2/2]

void NvCloth::Cloth::SetParticles ( const AZStd::vector< SimParticleFormat > &  particles)
overridevirtual

Sets the current particles (positions and inverse mass) for cloth.

Parameters
particlesList of particles to set.
Note
This function results in a copy of all particle data to NvCloth and therefore it's not a fast operation.

Implements NvCloth::ICloth.

◆ SetSelfCollisionDistance()

void NvCloth::Cloth::SetSelfCollisionDistance ( float  distance)
overridevirtual

Meters that particles need to be separated from each other. 0.0: No self collision. Distance valid values are > 0.0.

Implements NvCloth::IClothConfigurator.

◆ SetSelfCollisionStiffness()

void NvCloth::Cloth::SetSelfCollisionStiffness ( float  stiffness)
overridevirtual

Stiffness for the self collision constraints. 0.0: No self collision. Stiffness range is [0.0, 1.0].

Implements NvCloth::IClothConfigurator.

◆ SetSeparationConstraints() [1/2]

void NvCloth::Cloth::SetSeparationConstraints ( AZStd::vector< AZ::Vector4 > &&  constraints)
overridevirtual

Sets the separation constraints (positions and radius) for cloth. Each particle's movement during simulation will be kept outside the volume of a sphere.

Parameters
constraintsList of constraints (positions and radius) to set (rvalue overload).
Note
Partial set is not allowed, the list must include one constraint per particle.

Implements NvCloth::IClothConfigurator.

◆ SetSeparationConstraints() [2/2]

void NvCloth::Cloth::SetSeparationConstraints ( const AZStd::vector< AZ::Vector4 > &  constraints)
overridevirtual

Sets the separation constraints (positions and radius) for cloth. Each particle's movement during simulation will be kept outside the volume of a sphere.

Parameters
constraintsList of constraints (positions and radius) to set.
Note
Partial set is not allowed, the list must include one constraint per particle.

Implements NvCloth::IClothConfigurator.

◆ SetShearingPhaseConfig()

void NvCloth::Cloth::SetShearingPhaseConfig ( float  stiffness,
float  stiffnessMultiplier,
float  compressionLimit,
float  stretchLimit 
)
overridevirtual

Configures shearing constraints parameters.

Note
Applicable only if cloth has shearing constraints, which is decided by the internal cooking process of the fabric.
Parameters
stiffnessStiffness value of shearing constraints. 0.0: no shearing constraints.
stiffnessMultiplierScale value for compression and stretch limits. 0.0: No horizontal compression and stretch limits applied. 1.0: Fully apply compression and stretch limits.
compressionLimitCompression limit for shearing constraints. 0.0: No compression.
stretchLimitStretch limit for shearing constraints. Reduce stiffness of tether constraints (or increase its scale beyond 1.0) to allow cloth to stretch. 0.0: No stretching.

Implements NvCloth::IClothConfigurator.

◆ SetSolverFrequency()

void NvCloth::Cloth::SetSolverFrequency ( float  frequency)
overridevirtual

Target solver iterations per second. At least 1 iteration per frame will be solved regardless of the value set. Frequency valid values are >= 0.0.

Implements NvCloth::IClothConfigurator.

◆ SetSphereColliders() [1/2]

void NvCloth::Cloth::SetSphereColliders ( AZStd::vector< AZ::Vector4 > &&  spheres)
overridevirtual

Set a list of spheres to collide with cloth's particles (rvalue overload). x,y,z represents the position and w the radius of the sphere.

Note
Each cloth can have a maximum of 32 sphere colliders.

Implements NvCloth::IClothConfigurator.

◆ SetSphereColliders() [2/2]

void NvCloth::Cloth::SetSphereColliders ( const AZStd::vector< AZ::Vector4 > &  spheres)
overridevirtual

Set a list of spheres to collide with cloth's particles. x,y,z represents the position and w the radius of the sphere.

Note
Each cloth can have a maximum of 32 sphere colliders.

Implements NvCloth::IClothConfigurator.

◆ SetStiffnessFrequency()

void NvCloth::Cloth::SetStiffnessFrequency ( float  frequency)
overridevirtual

Stiffness exponent per second applied to damping, damping dragging, wind dragging, wind lifting, self collision stiffness, fabric stiffness, fabric compression, fabric stretch, tether constraint stiffness and motion constraints stiffness. Stiffness frequency valid values are > 0.0.

Implements NvCloth::IClothConfigurator.

◆ SetTetherConstraintScale()

void NvCloth::Cloth::SetTetherConstraintScale ( float  scale)
overridevirtual

Tether constraints scale. Scale valid values are >= 0.0.

Note
Applicable when cloth has tether constraints, that's when fabric data had static particles (inverse mass 0.0) when cooking.

Implements NvCloth::IClothConfigurator.

◆ SetTetherConstraintStiffness()

void NvCloth::Cloth::SetTetherConstraintStiffness ( float  stiffness)
overridevirtual

Stiffness for tether constraints. 0.0: No tether constraints applied. 1.0: Makes the constraints behave springy. Stiffness range is [0.0, 1.0].

Note
Applicable when cloth has tether constraints, that's when fabric data had static particles (inverse mass 0.0) when cooking.

Implements NvCloth::IClothConfigurator.

◆ SetVerticalPhaseConfig()

void NvCloth::Cloth::SetVerticalPhaseConfig ( float  stiffness,
float  stiffnessMultiplier,
float  compressionLimit,
float  stretchLimit 
)
overridevirtual

Configures vertical constraints parameters.

Note
Applicable only if cloth has vertical constraints, which is decided by the internal cooking process of the fabric.
Parameters
stiffnessStiffness value of vertical constraints. 0.0: no vertical constraints.
stiffnessMultiplierScale value for compression and stretch limits. 0.0: No horizontal compression and stretch limits applied. 1.0: Fully apply compression and stretch limits.
compressionLimitCompression limit for vertical constraints. 0.0: No compression.
stretchLimitStretch limit for vertical constraints. Reduce stiffness of tether constraints (or increase its scale beyond 1.0) to allow cloth to stretch. 0.0: No stretching.

Implements NvCloth::IClothConfigurator.

◆ SetWindDragCoefficient()

void NvCloth::Cloth::SetWindDragCoefficient ( float  drag)
overridevirtual

Amount of air drag. Wind drag range is [0.0, 1.0].

Note
A combination of high values in wind properties can cause unstable results.

Implements NvCloth::IClothConfigurator.

◆ SetWindFluidDensity()

void NvCloth::Cloth::SetWindFluidDensity ( float  density)
overridevirtual

Density of air used for air drag and lift calculations. Fluid density valid values are > 0.0.

Note
A combination of high values in wind properties can cause unstable results.

Implements NvCloth::IClothConfigurator.

◆ SetWindLiftCoefficient()

void NvCloth::Cloth::SetWindLiftCoefficient ( float  lift)
overridevirtual

Amount of air lift. Wind lift range is [0.0, 1.0].

Note
A combination of high values in wind properties can cause unstable results.

Implements NvCloth::IClothConfigurator.

◆ SetWindVelocity()

void NvCloth::Cloth::SetWindVelocity ( const AZ::Vector3 &  velocity)
overridevirtual

Wind in global coordinates acting on cloth's triangles. Disabled when both wind air coefficients are zero. Wind velocity range is [-50.0, 50.0].

Note
A combination of high values in wind properties can cause unstable results.

Implements NvCloth::IClothConfigurator.


The documentation for this class was generated from the following file: