Chapter 4 · Recipes

4.17Batch Sim

Batch Sim (toolbar button Batch Sim, script TenPix_12_BatchSim.ms) runs the shots of a scene one after another and saves every garment's cache, shot by shot.

  • Garments. Pick one garment, and every garment on its Tnpix Solver is simulated together.
  • Shots. Each shot has a name, its first and last frame, and the Tnpix Collision and Tnpix Forces modifiers that are on in it. The modifiers another shot names are off; any other modifier is left as it is.
  • Output. Files go to <Folder>\<Shot>\<Garment>_<Shot>.tnc or .abc, with optional velocities for Alembic, and a log of the run beside them. Test frames N runs only the first N frames of each shot, into <Folder>\_TEST.
  • Per shot. For each shot, the run sets the timeline to the shot, switches on that shot's Collision and Forces, resets the simulation, simulates every garment frame by frame, and saves each garment's cache from memory.
  • The caches. Every garment keeps its own Tnpix Cache: one is added where there is none, and a shared one becomes one per garment. After the run, each garment plays the last shot saved.
  • Afterwards. The timeline, the slider and the shots' modifiers are put back as they were, and nothing is saved to the scene file. Esc stops the shot running, and that shot is not saved.

The same run is one script command, TenPixBatchCore:

TenPixBatch_NoDialog = true                          -- load the core without opening the window
fileIn (TenPixCloth_Dir + "TenPix_12_BatchSim.ms")   -- TenPixCloth_Dir undefined: the toolbar scripts are not loaded (7.7)

-- a shot: #(name, first frame, last frame, #(names of the Tnpix Collision / Tnpix Forces modifiers ON in it))
shots = #(#("Walk", 0, 120, #("Tnpix Collision_Floor")), #("Sit", 150, 300, #("Tnpix Collision_Chair")))

-- check changes nothing and returns #(problems, plan lines); an empty problem list means ready
chk = TenPixBatchCore.check $Robe shots folder:"D:\\Project\\PointCaches\\Cloth" ext:".tnc" testFrames:0 velocities:true

-- run, after the artist's yes; returns #(ok, message, log file)
res = TenPixBatchCore.run $Robe shots folder:"D:\\Project\\PointCaches\\Cloth" ext:".tnc"
  • The signatures:

    • check garment shots folder:"" ext:".tnc" testFrames:0 velocities:true
    • run garment shots folder:"" ext:".tnc" velocities:true preview:false testFrames:0 switched:undefined status:undefined

    ext: is ".tnc" or ".abc". preview:true makes a preview per shot. status: is a function given each progress line.

  • Modifier names. A shot names modifiers exactly as their stack names (m.name), for example "Tnpix Collision_Floor". Give each Collision and Forces that changes between shots its own name first; renaming is a change, so tell the artist.

  • switched: lists the modifiers switched per shot; by default, every name the given shots use. When you run some of the artist's shots, pass switched: with every name the whole shot list uses, as the window does.

  • Run Check first and show its plan to the artist. A run replaces same-named cache files in its shot folders and resets the simulation. Its changes (caches added, shared caches split) are not one undo step, so save the scene under a new name first. A long run holds 3ds Max until it ends: prefer letting the artist start it from the window, and try Test frames first.

  • Opening the window for the artist. If you loaded the core, set TenPixBatch_NoDialog = false, then run the fileIn line again.

  • Loading a shot back. In the Cache Manager: highlight the garments, Load, and pick the shot's folder.