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?
$\begingroup$
$\endgroup$
3
-
1$\begingroup$ I'm sort of guessing here but I think that point can be obtained using some barycentric coordinates function. $\endgroup$– MarcClintDionCommented 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$– pink vertexCommented 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$– pink vertexCommented Feb 28, 2015 at 19:35
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
1
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).
-
7$\begingroup$ It's cheaper to add all vertex vectors and divide once by the number of vertices. $\endgroup$– CodeManXCommented Feb 24, 2015 at 22:48