11
$\begingroup$

Say I have a mesh and I have colored the vertices using vertex paint, how can I then get the average of the colors or rather the color in the middle of the face or the color under the normal (shown below) using blender python?

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ I'm sort of guessing here but I think that point can be obtained using some barycentric coordinates function. $\endgroup$ Commented Feb 25, 2015 at 0:26
  • $\begingroup$ The "middle" of the face might be vague. See wikipedia for the different definitions of midpoints. I think you refer to the median / centroid according to the site linked. $\endgroup$ Commented Feb 28, 2015 at 19:35
  • $\begingroup$ Btw there exists a function to deal with barycentric coordinates -> mathutils.geometry.barycentric_transform though this is not needed for the median $\endgroup$ Commented Feb 28, 2015 at 19:35

1 Answer 1

8
$\begingroup$

In the middle of a face is an average color of all the vertices. For triangle this means:

Col_RGB = ((R1+R2+R3)/3, (G1+G2+G3)/3, (B1+B2+B3)/3)

Where each vert has color in form of (Rn, Gn, Bn) for n in (1..3).

$\endgroup$
1
  • 7
    $\begingroup$ It's cheaper to add all vertex vectors and divide once by the number of vertices. $\endgroup$
    – CodeManX
    Commented Feb 24, 2015 at 22:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .