Creating Cloth
Create a native Jolt cloth and render it through BBMOD.
Create a native Jolt cloth and render it through BBMOD.
jolt_soft_body_create_cloth(x, y, z, width, height, segments_x, segments_y, options=undefined)cloth = jolt_soft_body_create_cloth(0, 0, 3, 4, 2, 30, 15, {rotation_x: 90});
cloth.set_mass(2);
cloth.set_stretch(0.1);
cloth.set_bend(0);
cloth.pin_edge("top");
cloth.set_renderer(o_control_bbmod_renderer.renderer);Call jolt_start() first. Creation returns JoltBBMODCloth, or undefined on failure; inspect jolt_get_error(). Position is the center. The unrotated grid lies in XY with +Z up. Width and height are full dimensions in metres; segment counts must be integers in 1..100.
Optional construction options still accept rotation_x/y/z, layer and physical values. Runtime setters include mass, stretch, bend, damping, friction, gravity_factor and collision_thickness. Grid resolution and dimensions remain construction choices.
Register the cloth with set_renderer() once. Advance physics with the existing jolt_update() loop; BBMOD renders its deforming mesh. Do not add a second physics step for rendering.
New related workflows#
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| jolt_soft_body_create_cloth | jolt_soft_body_create_cloth(x,y,z,width,height,sx,sy,settings=undefined) | Returns JoltBBMODCloth or undefined; requires jolt_start. Center x/y/z and full dimensions in m, positive dimensions, finite absolute values ≤1e9, integer segments 1..100. Flat cloth lies in XY. Options: mass=1, stretch=.9, bend=.3, damping=.1, friction=.5, gravity_factor=1, collision_thickness=.01, rotation_x/y/z=0° and default layer. (sx+1)*(sy+1) particles; renderer is assigned separately. |