Chapter 4 · The TnpixTool Interface

4.8Cache, Post Process, Rigid and Wrap

FunctionReturnsWhat it does
cacheSave nodeintegerSave cache: frames written, or −1 if refused (the reason is in cacheInfo, for example the demo on a farm, or an Alembic file in the demo). It records from the first frame of the Cache's range wherever the time slider is, and puts the slider back. Frames already simulated are saved as they are.
cacheLoad nodebooleanLoad: opens the file and plays from it.
cacheClear nodebooleanClear: stops playing and forgets the file; nothing is deleted.
cacheInfo nodestringThe file, whether it was found, the frames, whether it plays, the garments and the last status; stopped=1 when the file is from a recording that stopped early and holds the frames it kept.
postInfo nodestringWhat the Post Process is set to and what rest pose it has.
postCaptureRest nodebooleanCapture rest: takes the rest pose now, at the rest frame.
rigidInfo nodestringThe rigid pieces and points of the garment.
wrapFill nodeintegerFill now: evaluates the animation range into the proxy memory; frames filled, or −1 if refused (a proxy that is a live simulation).
wrapInfo nodestringThe proxy memory's frames and size, the tick and the last message.
addModifier $Shirt (Tnpix_Cache())
$Shirt.modifiers[#Tnpix_Cache].file = "D:/caches/shirt.tnc"
TnpixTool.cacheSave $Shirt
TnpixTool.cacheInfo $Shirt

Progress while a cache records

While a Save records, TenPix Cloth calls a global MAXScript function named tnpixCacheProgressHook, if one exists, with two integers: the frames recorded so far and the frames this Save records. It is called once with 0 before the first frame and then after every frame, for the panel's Save button and for cacheSave alike. Its return value is ignored, and so is an error inside it: the recording goes on. The Deadline job that comes with the plug-in uses it to show each recorded frame as the task's progress.

global tnpixCacheProgressHook
fn tnpixCacheProgressHook done total = (
    format "recorded % of % frames\n" done total
)
TnpixTool.cacheSave $Shirt
tnpixCacheProgressHook = undefined      -- stop listening

Declare the function global. A farm manager that runs a job file as one block, as Deadline does, makes a function defined at the top of the file local to that block, and the plug-in looks for a global.