Chapter 4 · Recipes
4.12Gravity
-- a Solver group needs one Tnpix Gravity, one instance shared by its garments: add it only where the group has none
(
local sv = tpaFirst $Shirt Tnpix_Solver
local has = for o in (tpaUsers sv) where (tpaFirst o Tnpix_Gravity) != undefined collect o.name
if has.count > 0 then ("Gravity is already on: " + (has as string))
else (
undo "TenPix: gravity" on (
local g = tpaAddBelowSolver $Shirt (Tnpix_Gravity()) -- a new one pulls with Earth gravity in the scene's unit
for o in (tpaUsers sv) where o != $Shirt do tpaAddBelowSolver o g
)
"Gravity added to " + ((tpaUsers sv).count as string) + " garment(s)"
)
)
- Magnitude and direction. The pull is
magnitude, in scene units per second squared, alongdirection; only the direction of that vector counts, not its length. A new Gravity has direction [0,0,1] and a negative magnitude (−386.22 in an inch scene), so it pulls down. Do not change the direction to [0,0,−1] to correct it: with the negative magnitude, gravity would then pull up. - Lower magnitude gives a slow-motion look; a tilted
directiongives a steady sideways pull. - Off.
tnEnabled = falseswitches gravity off for a comparison without removing the modifier.