[Closed] Select faces/verts in VertexPaint modifier
I’d like to take a face (or vertex) selection into the VertexPaint modifier and apply the effect to only the selection.
Using ShowProperties() I can see how to set the blending mode, opacity etc., and I can set set the selection mode to vertex/face using subOjectLevel but I can’t seem to apply my selection.
I want to use this to tint selected faces/verts that already have ambient occlusion baked into them.
Any ideas?
well… there is no method in max script to select faces or vertices in VertexPaint modifier and VertexPaint modifier doesn’t inherit sub selection from stack. But there is a workaround.
- Create copy of your node with same class as your node.
- Delete all faces of copied node which you want to protect
- Apply colors to copied node
- Copy faces colors from copier node to original one.
how to do last step? OK.
fn facecolorsXChange node_from node_to channel: =
(
-- channel is map channel used for vertex colors
-- both nodes are Editable_Poly... modify the code if you are using editable_meshes
faces_from = (node_from.faces as bitarray) as array
faces_to = (node_to.selectedfaces as bitarray) as array
-- same count arrays with right order!
-- speed up and save memory!
getmapface = polyop.getmapface
getmapvert = polyop.getmapvert
setmapvert = polyop.setmapvert
for k=1 to faces_from.count do
(
map_verts_from = getmapface node_from channel faces_from[k]
map_verts_to = getmapface node_to channel faces_to[k]
for i=1 to map_verts_from.count do
(
setmapvert node_to channel map_verts_to[i] (getmapvert node_from channel map_verts_from[i])
)
)
)
Shame on me! There is the easier way. Just store current face colors in the buffer first, apply new colors using AssignVertexColors (or using VertexPain), and restore faces which you want to keep. It’s much better then I wrote above. Because new method for sure keeps vertex normals and doesn’t screw up lighting calculating.