API ReferenceGE Extensionseditorgen
Gen Experimental SolidFlex
Experimental solid/flex body simulation editor for exploring deformation and physics properties.
Experimental solid/flex body simulation editor for exploring deformation and physics properties.
Overview
The exp_solidflex module provides an experimental environment for simulating solid and flexible body dynamics. It supports viscosity and plasticity parameters, vertex selection and neighbor detection, history tracking, and edge-based body definitions with gradient descent optimization.
Module Table: W
| Field | Type | Description |
|---|---|---|
W.out | table | Output data |
W.ui.visc_in | number | Viscosity input value |
W.ui.plast_in | number | Plasticity input value |
W.isactive | boolean | Whether the editor is active |
Key Functions
| Function | Description |
|---|---|
W.up(k, lbl) | Initializes the editor, creates materials and edit group |
W.init() | Sets up body definition and initial state |
W.test() | Runs test scenarios in development mode |
Simulation State
| Variable | Description |
|---|---|
segpick | Picked segment indices |
cvover | Hovered vertex |
cpick | Picked vertex |
cvneigh | Neighbor vertices of current selection |
vpin | Pinned vertex position |
ahist | History of simulation states |
nvisc | Viscosity step count |
cplast | Current plasticity level |
aloss | Loss history for optimization |
Body Definition
The body is defined by arrays:
aind- Index multipliersaa- Angle arrayae- Edge anglesdedge- Edge dictionary
Dependencies
| Module | Path |
|---|---|
| Utils | /lua/ge/extensions/editor/gen/utils |
| AI Lib | /lua/ge/extensions/editor/gen/lib/ai |
| Mesh | /lua/ge/extensions/editor/gen/mesh |
| UI Lib | /lua/ge/extensions/editor/gen/lib/ui |
Usage Example
-- The solidflex editor is activated through the gen editor:
W.up('exp_solidflex', 'SolidFlex Simulation')
-- Adjusting simulation parameters via UI:
-- W.ui.visc_in → viscosity slider
-- W.ui.plast_in → plasticity sliderAll Exported Functions
| Function | Signature | Description |
|---|---|---|
W.up(k, lbl) | (string, string) | Initializes editor: hides player, registers window, creates materials and edit group |
W.init() | () | Builds initial mesh from angle arrays, creates body object, computes edge dictionary |
W.build(ac) | (table) → table | Builds mesh from angle coefficients. Returns mesh table {verts, normals, uvs, faces, material} |
W.onVal(k, val, mute) | (string, any?, boolean?) | Event handler for: reset, visc_in, plast_in, crumple, edge_pick |
W.gui() | () | Renders ImGui window with crumple button, reset, viscosity/plasticity sliders, and hint overlay |
W.update() | () | Per-frame update: mouse vertex picking/dragging with IK solving, camera orbit on Alt+click, animations |
W.test() | () | Runs test scenarios with multi-segment body and gradient descent optimization |
See Also
- Gen AI Library - Gradient descent optimization
- Gen Frame Editor - Skeletal body simulation
- Gen Mesh - Mesh utilities