Chapter 4 · The TnpixTool Interface
4.4Channels and the Tear Brush
Painting from script needs the Tnpix Channel modifier to be the current object in the Modify panel, on exactly one
object (an instanced Channel modifier is refused). A dab lands on the channel selected on the panel, which after
chanAdd is the new one. The brush centre is in the object's own space, the coordinates the mesh vertices
have before the node is moved.
| Function | Returns | What it does |
|---|---|---|
chanAdd node name fill | boolean | Creates a channel with every vertex at fill (clamped to 0–1) and selects it. Names are unique and case-sensitive. If a selection arrives from below the Channel at a sub-object level (vertex, edge or face), those vertices are born at the panel's Value; a selection left inside an object at its top level is not used. |
chanPaint node center radius mode strength | boolean | One brush dab. Modes: 0 Add, 1 Subtract, 2 Replace, 3 Smooth. |
chanStroke node on | boolean | true opens a stroke and false
closes it: the dabs between count as one stroke, as a mouse drag does. |
chanApplySel node | boolean | Writes the panel's Value into the selected vertices (Apply to Selection). |
chanRemSel node | boolean | Sets the selected vertices back to 0 (Remove Selection). |
chanClear node | boolean | Sets the whole selected channel back to 0 (Clear Channel). |
chans node | string | The channel table, as text. |
chanCount node name atOrAbove | integer | How many vertices carry paint at or above the value; −1 = no such channel. |
chanRemove node name | boolean | Deletes a channel by name, with the tear-brush lines drawn into it (the Delete button). |
chanMirror node side tolerance | string | Mirror, the panel button's own function: copies the selected channel's weights from one side of the object to the other. side: 0 +X to −X, 1 −X to +X, 2 +Y to −Y, 3 −Y to +Y, 4 +Z to −Z, 5 −Z to +Z. tolerance, in the object's units, is how far a mirrored vertex may land from a vertex and still count as its twin. One undo step. Returns <channel>: mirrored +X to -X: N vertices took their twin's weight, M found no twin, or a line beginning refused: with the reason (no Tnpix Channel on the node, no channel selected, a side outside 0 – 5, the modifier not the current object or on more than one object). |
chanSelCount node edges | integer | How many components the Channel Vertices
selection holds (edges false), or the Channel Edges selection (true), on the object
the modifier is edited on; −1 when the Channel is not the current object. |
tearCut node channel points projDir spacing | string | The Tear brush: cuts a line into the mesh inside the Channel modifier and marks it. See below. |
tearRemove node mode | string | 0 removes the last cut, 1 removes every cut; the weights are put back. Undoable. Returns removed N cut(s), M remain. |
tearCut. Every point of the array (object space, like chanPaint) is projected onto the mesh that
reaches the Channel modifier along projDir (the panel uses the view direction). Points closer than
spacing to the previous one are dropped. The line is cut into the mesh, every channel grows to the new vertex
count, and the vertices on the line are marked in the named channel at 1.0 (an empty name means the channel selected
on the panel). A first or last point that misses the cloth runs the cut out to the border on that side. It needs no
Modify panel. It returns cut N of M points, +A verts, marked K in 'name', or a line beginning *** REFUSED:
with the reason (no channel, no mesh yet, no point on the cloth, fewer than two points after spacing).
select $Flag
max modify mode
modPanel.setCurrentObject $Flag.modifiers[#Tnpix_Channel]
TnpixTool.chanAdd $Flag "hem" 0.0
TnpixTool.chanPaint $Flag [-55, 0, 0] 3.0 0 1.0
TnpixTool.chanCount $Flag "hem" 0.5
TnpixTool.chanMirror $Flag 1 0.1 -- the hem painted on the -X side, given to the +X side too
TnpixTool.tearCut $Flag "hem" #([-40,0,0], [-20,4,0], [0,0,0]) [0,0,-1] 2.0
TnpixTool.tearRemove $Flag 0
chanGrab and chanAddSel are registered but not part of this version: they
refuse with a message. Use chanApplySel.