Assembly Spline Molecule
Handles mesh assembly kit parsing, attachment point extraction, and molecule building for the assembly spline tool. A "molecule" is a group of rigid meshes joined via attachment anchor points, with op
Handles mesh assembly kit parsing, attachment point extraction, and molecule building for the assembly spline tool. A "molecule" is a group of rigid meshes joined via attachment anchor points, with optional bridge meshes spanning between consecutive molecules.
Public Functions
| Function | Description |
|---|---|
M.getRigidEnabled(spline, meshId) | Check if a rigid mesh is enabled for the given spline |
M.setRigidEnabled(spline, meshId, enabled) | Set enabled state for a rigid mesh |
M.getBridgeEnabled(spline, meshId) | Check if a bridge mesh is enabled for the given spline |
M.setBridgeEnabled(spline, meshId, enabled) | Set enabled state for a bridge mesh |
M.getRigidRandom(spline, meshId) | Get random distribution flag for a rigid mesh |
M.setRigidRandom(spline, meshId, isRandom) | Set random distribution flag for a rigid mesh |
M.getRigidRandomWeight(spline, meshId) | Get random weight for a rigid mesh (default 1.0) |
M.setRigidRandomWeight(spline, meshId, weight) | Set random weight for a rigid mesh |
M.getBridgeRandom(spline, meshId) | Get random distribution flag for a bridge mesh |
M.setBridgeRandom(spline, meshId, isRandom) | Set random distribution flag for a bridge mesh |
M.getBridgeRandomWeight(spline, meshId) | Get random weight for a bridge mesh (default 1.0) |
M.setBridgeRandomWeight(spline, meshId, weight) | Set random weight for a bridge mesh |
M.getAssemblyKit(kitFolderPath) | Scan folder for .dae files and return an assembly kit table |
M.buildMolecule(assemblyKit, spline) | Build a molecule structure from an assembly kit |
M.applyEnabledStatesToMolecule(spline, molecule) | Apply enabled states after deserialization |
Key Concepts
Anchor Point Naming Convention
Anchor points in meshes follow the format: nail.<joinName>.<pointType>[.<aliasName>]
- point - Required base position for all join types
- head - Defines forward direction (used in nail and fixed joins)
- aux - Defines orientation lock (used in fixed joins)
Join Types
| Type | DOF | Points Required | Description |
|---|---|---|---|
ball | 3 | point only | Free rotation on all axes |
nail | 1 | point + head | Rotation around nail axis only |
fixed | 0 | point + head + aux | No rotation allowed |
Molecule Structure
local molecule = {
rigids = {}, -- Rigid mesh entries with attachments
placingOrder = {}, -- Ordered indices for building from root
rigidAttachmentSequence = {}, -- Placement instructions for non-root meshes
bridges = {}, -- Bridge meshes spanning molecule pairs
bridgeAttachments = {}, -- Bridge-to-rigid attachment mapping
isSagEnabled = false, -- Whether any bridge supports sag
}Usage Example
local mol = require('editor/assemblySpline/molecule')
-- Load an assembly kit from a folder of .dae meshes
local kit = mol.getAssemblyKit('/art/meshes/fence_kit/')
-- Build the molecule (determines attachment order, bridges, etc.)
local molecule = mol.buildMolecule(kit, spline)
-- Toggle a rigid mesh off
mol.setRigidEnabled(spline, kit[2].id, false)
-- Rebuild with updated state
molecule = mol.buildMolecule(kit, spline)Filename Conventions
| String | Purpose |
|---|---|
root | Identifies the root rigid mesh |
bridge | Identifies bridge meshes |
sag | Marks a bridge as supporting sag deformation |
var | Marks a file as a variation of its base mesh |
See Also
- assemblySpline/populate - Places molecules along the spline
- assemblySpline/splineMgr - Manages assembly spline state and UI
Assembly Spline – Import
Imports existing scene objects (TSStatic groups) into assembly splines by analyzing positions, fitting curves, and reconstructing spline data with undo support.
Assembly Spline Populate
Handles the placement of molecule instances (rigid + bridge meshes) along an assembly spline. Manages mesh pooling, spline sampling, rigid placement via attachment sequences, and bridge scaling/alignm