Notifications
Clear all
[Closed] Finding broken vertex colors
Aug 27, 2011 2:43 am
Hey guys, what would be the best way to find out broken vertex colors per vertex on a given object and then assign it a color of my choice…
7 Replies
1 Reply
Aug 27, 2011 2:43 am
sorry for being so vague, I want to pick out verts with colors that don’t blend (similar to applying a color to a selected face)
1 Reply
Aug 27, 2011 2:43 am
Hi denis, yes if thats the term for that…working with editable poly but i can work with editable mesh too if easier that way…
Aug 27, 2011 2:43 am
poly =
(
delete objects
max create mode
-- Make a sample poly node:
with redraw off
(
b = box lengthsegs:5 widthsegs:5 heightsegs:5 length:10 width:10 height:10 mapcoords:on
setCVertMode b on
setShadeCVerts b on
converttopoly b
vc = #(red, green, blue)
seed 1
for f=1 to b.numfaces do polyop.setfacecolor b 0 f vc[random 1 vc.count]
update b
)
struct vpoly (node, verts)
struct vdata (index, tverts = #(), vcolors = #(), unique = on)
verts = #()
verts.count = b.numverts
for f=1 to b.numfaces do
(
vv = polyop.getfaceverts b f
tv = polyop.getmapface b 0 f
for k=1 to vv.count do
(
if verts[vv[k]] == undefined do verts[vv[k]] = vdata index:vv[k]
d = verts[vv[k]]
append d.tverts tv[k]
c = polyop.getmapvert b 0 tv[k]
if d.vcolors.count > 0 and d.unique and (finditem d.vcolors c) == 0 do d.unique = off
append d.vcolors c
)
)
vpoly node:b verts:verts
)
fn getUniqueVerts data =
(
vv = #{}
for v in data where v.unique do append vv v.index
vv
)
fn getBrokenVerts data =
(
vv = #{}
for v in data where not v.unique do append vv v.index
vv
)
-- Find [b][i]Broken [/i][/b]verts
vv = getBrokenVerts poly.verts
poly.node.selectedverts = vv
format "unique:%
" vv
max modify mode
select poly.node
setselectionlevel poly.node #vertex
fn getAverageVertexColor vert =
(
vc = [0,0,0]
for c in vert.vcolors do vc += c
((vc/vert.vcolors.count) as point4) as color
)
/* -- [b][i]Average [/i][/b]Vertex colors:
for v in poly.verts do polyop.setvertcolor poly.node 0 v.index (getAverageVertexColor v)
update poly.node
*/
any questions are welcome.
Aug 27, 2011 2:43 am
Sweet… Thanks denis i can work with this. Will shout out if i get stuck.