Chapter 2 · Examples

2.1Cloth from Nothing

p = Plane length:100 width:100 lengthsegs:1 widthsegs:1 pos:[0,0,50]
addModifier p (Tnpix_Garment())
p.modifiers[#Tnpix_Garment].edgeLength = 2.0
addModifier p (Tnpix_Gravity())
addModifier p (Tnpix_Collision())
addModifier p (Tnpix_Solver())
t = Teapot radius:25 pos:[0,0,0]
TnpixTool.colAdd p t            -- the same path as the Pick Object button

What you should see: the plane's wireframe rebuilds into small, even triangles (Tnpix Garment at work). Play from the first frame: the sheet falls and drapes over the teapot. Leave out the last line and it falls through: an object only collides once it is in a Tnpix Collision list. Leave out the Gravity line and it floats: a Solver group with no Gravity modifier has no gravity.