Notifications
Clear all

[Closed] Inverse Vertex Color

Hi,

I want to make a script that inverse the value of vertex color on an Editable_Poly object.
White vertex colors becomes black and black becomes white etc…

With Mesh Objects we have the “getVertColor” and “setVertColor” to manipulate the vertices but in Editable_Poly objects only the setVertColor is available… Why ?
I did’nt found anything to get the vertice color with editable_Poly…

So in my script i tried to convert the poly to a mesh and get the vertice color from there with the getVertColor function. But there is a difference between mesh and poly objects that i don’t understand very well.
in mesh you manipulate the CPV Color Per Vertices wich are way more thant he vertices itselfs. approximatively 3 CPV for 1 vertice… so when i try to apply my getVertColor result back on the poly objet with the polyop.setvertColor i have Strange results.

How could i achieve that, has anyone an idea ?

2 Replies

I’d just ignore all that poly->mesh-> poly craziness and work with the vertex color data correctly.

You’re right that it’s odd that there’s no polyOp.getVertColor… almost seems like somebody was working on that and then said “meh.” and went ahead and wrote polyOp.getMapVert instead. Or went “meh.” -because- polyOp.getMapVert already existed.

Regardless…


 vertColor = polyOp.getMapVert $ 0 1 -- channel 0 = vertex colors, 1 = vertex index
 [1,0,1][color=Green] -- looks like a magenta vertex color.
 newVertColor = [1,1,1] - vertColor -- let's invert it
 [color=Blue][0,1,0] -- mmm green
 [/color][/color]polyOp.setMapVert $ 0 1 newVertColor
 OK
 

You can use “(<point3> * 255) as color” if you want proper color values, but not required for the purpose you mentioned

Is there some sort of update needed to get polyop.setmapvert to work?
Sometimes it updates, sometimes not. Sometimes calling update() does the trick, sometimes not…

The only way I’ve found at the moment it’s to manually adjust a vert color, and suddenly the whole mesh updates to the values I fed it with polyop.setmapvert.

Thanks