Chapter 4 · Recipes
4.18Reading results
- Look. Capture the frames where the behaviour shows: the drape settled, the fastest move, the frame a tear opens. Use the same view and frames before and after a change. In fast, chaotic motion such as a flag in a gale, a small change can produce different folds, so judge the behaviour, not one fold.
- Measure. Read positions from the simulated mesh at the current frame:
(
local m = snapshotAsMesh $Shirt -- world space, as simulated at the slider's frame
local lo = undefined, sum = [0, 0, 0]
for i = 1 to m.numverts do ( local p = getVert m i; sum += p; if lo == undefined or p.z < lo.z do lo = p )
local mid = if m.numverts > 0 then sum / (m.numverts as float) else sum
delete m
"lowest point " + (lo as string) + ", middle " + (mid as string)
)
- Is it staying on the body? This is the usual outfit question. A garment can stay close to the body while it slides along it, so its distance to the body does not answer it.
tpaSlipties points of the garment to the nearest body points at one frame, and measures how far each has drifted from its body point at a later frame. Each tied point is compared with every body point: for a jacket of 8,000 points on a body of 14,000,step200 takes about a second andstep20 about ten.
global tpaSlip
-- how far garment g drifted from where it sat on body b, from frame f0 to frame f1 (simulate up to f1 first, 4.15):
-- every step-th point of g within reach of b at f0 is tied to b's nearest point, and at f1 the distance between the two
-- is measured again. Returns the points tied, the mean and largest drift, and how many drifted further than reach.
fn tpaSlip g b f0 f1 reach step = (
local g0 = at time f0 (snapshotAsMesh g), b0 = at time f0 (snapshotAsMesh b)
local g1 = at time f1 (snapshotAsMesh g), b1 = at time f1 (snapshotAsMesh b)
local s = ""
if g0.numverts != g1.numverts or b0.numverts != b1.numverts then s = "A mesh changed its point count between the two frames."
else (
local tieG = #(), tieB = #(), tieD = #()
for i = 1 to g0.numverts by step do (
local p = getVert g0 i, best = 0, bd = reach
for j = 1 to b0.numverts do ( local d = distance p (getVert b0 j); if d < bd do ( bd = d; best = j ) )
if best > 0 do ( append tieG i; append tieB best; append tieD bd )
)
if tieG.count == 0 then s = "No point of " + g.name + " lies within " + (reach as string) + " of " + b.name + " at frame " + (f0 as string) + "."
else (
local sum = 0.0, mx = 0.0, far = 0
for k = 1 to tieG.count do (
local dr = abs ((distance (getVert g1 tieG[k]) (getVert b1 tieB[k])) - tieD[k])
sum += dr
if dr > mx do mx = dr
if dr > reach do far += 1
)
s = g.name + " on " + b.name + ", frames " + (f0 as string) + " to " + (f1 as string) + ": " + (tieG.count as string) + " points tied, drift mean " + (formattedPrint (sum / tieG.count) format:".3f") + ", largest " + (formattedPrint mx format:".3f") + ", " + (far as string) + " drifted further than " + (reach as string)
)
)
delete g0; delete b0; delete g1; delete b1
s
)
-- tpaSimTo $Jacket 48 (4.15), then: tpaSlip $Jacket $Body 0 48 1.0 50 (lengths in scene units)
A mean drift close to 0 with a large largest drift means one region slides: capture it, then look at that region's friction (3.7).
-
Read status. These calls return what the panels show:
Call Returns TnpixTool.cacheInfoFrames, file and whether it plays TnpixTool.rigidInfoPieces TnpixTool.selfColLayersLayers TnpixTool.wrapInfoProxy memory and the last message TnpixTool.threadsInfoThe Threads status lines TnpixTool.postInfoThe Post Process settings and rest pose TnpixTool.live node "info" 0Live's status line TnpixTool.mbInfoMotion Brush layers Other status lines are only on the panels: the Tear's strongest pull, the Stitch's count, a material's stretch. Ask the artist to read one when you need it.
-
The Listener. Each TenPix line in the MAXScript Listener starts with
TenPix: a note when a cache is saved, a warning when a demo limit holds the simulation or a collider is gone, an error when a cache cannot be saved or the graphics driver or card cannot run TenPix Cloth. A script relies on return values, not on these lines.