ClothBodyComponent
A component that simulates an entity as a deformable cloth body, when part of a cloth simulation.
Declaration
struct ClothBodyComponentOverview
A cloth body belongs to the simulation root defined by its closest ancestor entity with a ClothSimulationComponent, if any.
If the same entity has a ModelComponent, then the mesh of that component will follow the deformation of this cloth body. As an example, you can simulate and render a cloth body by setting up your entity hierarchy as follows.
- scene
- entity1 (ClothSimulationComponent)
- entity2 (ClothBodyComponent + ModelComponent)The simulated cloth body is effectively a deforming copy of the input mesh (ClothMeshResource) that it is initialized from. This mesh is known as the simulation mesh (also known as proxy mesh) of the body, and RealityKit does not render this mesh. In contrast, the mesh of the ModelComponent is rendered and is known as the visual mesh of the cloth body in this context. Unless the mesh stored in the ModelComponent is a LowLevelMesh, it will follow the deformation of the simulation mesh.
The simulation mesh can be the same as the visual mesh, but it is recommended to use a separate mesh. This is because there are quality and performance aspects to consider when picking a suitable simulation mesh. See mesh for details.
A cloth body is effectively simulated as a cluster of constrained particles with different physical properties. Consequently, the vertices of the simulation mesh are sometimes referred to as particles.
Topics
Creating a cloth body
Mapping the visual mesh
visualMeshvisualMeshWeightsmaterialNamesClothBodyComponent.PerVisualVertexDataClothBodyComponent.PerSimulationVertexData
Controlling cloth motion
Defining target shapes
Applying external forces
externalForcesClothBodyComponent.ExternalForceinflationConstraintClothBodyComponent.InflationConstraint