Chapter 4 · Recipes
4.1Make a cloth
Quick Cloth (toolbar). With meshes selected, the artist sets Triangle size (the Tnpix Garment's Edge length, default 2.0), Rebuild the mesh (adds Tnpix Garment), Quick Cloth's own Quality (Draft: Substeps 2, Iterations 2; Preview: 4, 3; Final: 9, 4), Smoothing iterations (default 5), Add gravity, Add Standard material with the ceiling held on the body, and an optional collider. Make Selected Cloth then builds Garment > Gravity > Collision > Material Standard > Solver on every selected mesh. To open the window for the artist, run tpaOpenTool "TenPix_01_QuickCloth.ms" (7.7).
By hand. addModifier puts each new modifier on top of the stack, so add the modifiers bottom first. Measure the mesh before you rebuild it:
global tpaEdge
-- the mean edge length of o's mesh as it is now, in the scene's unit
fn tpaEdge o = (
local m = snapshotAsMesh o
local tot = 0.0, n = 0
for f = 1 to m.numfaces do (
local fc = getFace m f
local a = getVert m fc.x, b = getVert m fc.y, c = getVert m fc.z
tot += (distance a b) + (distance b c) + (distance c a)
n += 3
)
delete m
if n > 0 then tot / n else 0.0
)
undo "TenPix: make cloth" on (
local g = $Sheet
local e = tpaEdge g -- the modelled density, measured before any rebuild
addModifier g (Tnpix_Garment()) -- only on a mesh nothing else follows (see below)
g.modifiers[#Tnpix_Garment].edgeLength = e -- scene units; smaller = more detail and a slower solve
addModifier g (Tnpix_Gravity()) -- Earth gravity in the scene's unit
addModifier g (Tnpix_Collision())
addModifier g (Tnpix_Material_Standard())
TnpixTool.goldPreset g 0 -- Cotton (approx); the stock fabrics are listed in 7.5
TnpixTool.goldSetAt g 0 "stretchBodyLimit" 1.0 -- "limit where it touches the body", as Quick Cloth sets it
addModifier g (Tnpix_Solver()) -- last, so on top
TnpixTool.colAdd g $Body -- an object collides only once it is in the list
)
Tnpix Garment rebuilds the mesh, and that changes its point count.
- Leave it out when the mesh is already clean, even triangles, as most modelled garments are.
- Never add it to a mesh that something else follows: a Tnpix Wrap that uses the garment as a proxy (3.4), a Skin Wrap, or a Morpher target. They stop following until they are bound again, and the Wrap's status line then reads "proxy ... changed since the bind". Render meshes often follow simulation meshes this way.
- Its Edge length is in the scene's unit, and it decides the density and with it the time each frame takes. Start from the mesh's own mean edge (
tpaEdge), never from a fixed number: 2.0 is 2 inches in an inch scene and 2 metres in a metre scene.