Script to give each vertex in a editable poly model a unique vertex color

Script to give each vertex in a editable poly model a unique vertex color

rpardridge
Participant Participant
329 Views
2 Replies
Message 1 of 3

Script to give each vertex in a editable poly model a unique vertex color

rpardridge
Participant
Participant

Hello,

 

I'd like to build a script that gives each vertex in an editable polygon object a unique vertex color, such that the distance between any 2 points (in color space) is above a threshold. A simple way I imagine doing this is creating a 3D RBG grid from (0,0,0) to (255, 255, 255), spaced out evenly based on the number of points in the mesh.

 

I am pretty sure I can figure out the math for assigning the vertex colors properly, but I am not sure where to get started on making the script. Any help getting started is greatly appreciated.

 

Thanks!

0 Likes
330 Views
2 Replies
Replies (2)
Message 2 of 3

denisT.MaxDoctor
Advisor
Advisor

every vertex index is already a unique color. 🙂

there is a common color type COLOREF which is an unsigned integer made as << B-byte << G-byte << R-byte

 

so if we want to convert the index to a color, it would be:

 

R = mod index 256

G = mod (index/256) 256

B = mod (index/256/256) 256

 

 

 

0 Likes
Message 3 of 3

denisT.MaxDoctor
Advisor
Advisor

I could be wrong in my assumptions, but it seems to me that the crux of your question is different...
"how do I mark vertexes so that after changing topology (numeration) and geometry (position) I can find correspondence between old and new ones?" 

it's a very common question

0 Likes