Chapter 4 · Recipes
4.11Rigid pieces and the Rigidity mix
Tnpix Rigid makes painted regions, or separate mesh elements, solid pieces inside the cloth: buttons, buckles, a stiffened collar, an armour plate. Rigidity is a mix:
| Rigidity | The piece |
|---|---|
| 1 | Rigid: keeps its modelled shape and moves as one body. |
| 0.75 | A stiff leather patch. |
| 0.5 | Draped over a body, it bends about half as much as the cloth around it. |
| 0.25 | A soft patch. |
| 0 | Off: moves as the cloth around it. |
Below 1, a piece meets a collider partly as one body (Bounce, Friction) and partly as the cloth around it. Rigidity can be keyed.
undo "TenPix: rigid collar" on (
local r = tpaAddBelowSolver $Shirt (Tnpix_Rigid())
r.piecesFrom = 0 -- 0 painted channel, 1 mesh elements
r.channel = "shirt_collar"
r.threshold = 0.5 -- paint at or above this is rigid
r.eachRegion = true -- every connected painted region is its own piece
r.rigidity = 0.75 -- the mix the artist chose
r.massMode = 0 -- By density; an open patch has no inside and weighs its cloth
r.density = 0.5 -- g/cm3 for closed pieces: wood 0.5, plastic 1.0 to 1.4, steel 7.8
)
TnpixTool.rigidInfo $Shirt -- after a simulation starts: the pieces and their points
The Rigid's own switch is named enabled, so from MAXScript the 3ds Max light bulb shadows it. Use the light bulb.
Scenes from earlier versions. A Tnpix Rigid from a scene of an earlier version keeps that version's Rigidity: any value above 0 holds its pieces fully rigid. Only a newly added Tnpix Rigid mixes. So if the artist wants a mix in such a scene, or a Rigidity between 0 and 1 still looks fully rigid, offer to replace that Rigid with a new one that has the same channel and settings. Replacing removes a modifier, so get their yes first.
global tpaRenewRigid
fn tpaRenewRigid o old = (
local idx = 0
for i = 1 to o.modifiers.count where idx == 0 and o.modifiers[i] == old do idx = i
local r = undefined
if idx > 0 do undo "TenPix: renew Tnpix Rigid" on (
r = Tnpix_Rigid()
addModifier o r before:idx -- right below the old one ...
r.piecesFrom = old.piecesFrom
r.channel = old.channel
r.threshold = old.threshold
r.eachRegion = old.eachRegion
r.rigidity = old.rigidity
r.massMode = old.massMode
r.density = old.density
r.massKg = old.massKg
r.massMul = old.massMul
r.bounce = old.bounce
r.friction = old.friction
r.airResistance = old.airResistance
r.spinResistance = old.spinResistance
r.name = old.name
deleteModifier o idx -- ... then the old one goes and the new one takes its place
)
r
)
-- tpaRenewRigid $Shirt (tpaFirst $Shirt Tnpix_Rigid)
The function copies a keyed Rigidity as its value at the current frame, so key the new Rigid again. A Rigid shared by several garments is replaced per garment, one call each.