Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Creating a cloth for soft body simulation:

Generate a cloth mesh (2D grid in XY plane).

Generate a cloth mesh (2D grid in XY plane)Creates a grid of vertices suitable for soft body cloth simulation. The mesh is generated in the XY plane, facing +Z direction.

Parameters
widthNumber of vertices along X axis (minimum 2)
heightNumber of vertices along Y axis (minimum 2)
spacingDistance between adjacent vertices (default: 0.1)
Returns
Component::Mesh The generated cloth mesh with vertices, normals, UVs, and indices
Note
For degenerate sizes (width < 2 or height < 2), returns vertices without faces.
auto mesh = Object::Utils::GenerateClothMesh(10, 10, 0.1f);
entity.AddComponent<Mesh>(core, mesh);
entity.AddComponent<SoftBody>(core, SoftBodySettings::Cloth(0.5f));
Component::Mesh GenerateClothMesh(uint32_t width, uint32_t height, float spacing)
Definition ClothGenerator.cpp:6

a cloth for soft body simulation: