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

Create a cloth entity with mesh and transform for soft body simulation.

Create a cloth entity with mesh and transform for soft body simulationCreates a 2D grid of vertices in the XY plane, suitable for soft body cloth simulation. After creation, add a SoftBody component to enable physics:

Parameters
coreEngine core reference
infoParameters for creating the cloth (width, height, spacing, position, rotation, scale)
Returns
Engine::Entity The created entity with mesh and transform
auto cloth = Object::Helper::CreateCloth(core, { .width = 10, .height = 10, .spacing = 0.1f, .position = glm::vec3(0,
5, 0) }); auto& soft = cloth.AddComponent<Physics::Component::SoftBody>(core, SoftBodySettings::Cloth(0.5f));
soft.PinVertex(0); // Pin top-left corner
soft.PinVertex(9); // Pin top-right corner
decltype(auto) AddComponent(TComponent &&component)
Add a component to an entity.
Definition Entity.hpp:55
Engine::Entity CreateCloth(Engine::Core &core, CreateClothInfo info)
Definition CreateShape.cpp:75
Soft body physics component.
Definition SoftBody.hpp:241
void PinVertex(uint32_t vertexIndex)
Pin a vertex (fix it in space).
Definition SoftBody.hpp:284

a cloth for soft body simulation: