Hi All,
I am trying to get coordinates of the center of a face in world space. I thought all you had to do was multiply by the object world_matrix, but I get the same return value no matter where my plane is located in the scene.
import bpy, random, bmesh
from mathutils import Vector
def returnPolygonCenter(ob,polygon_index):
mx = ob.matrix_world
tmp = [ob.data.vertices[el].co*mx for el in ob.data.polygons[polygon_index].vertices]
v0 = Vector()
for el in tmp:
v0 += el
nr_verts = len(tmp)
return v0/nr_verts
ob_source = bpy.data.objects.get("Plane")
for i,p in enumerate(ob_source.data.polygons):
face_center = returnPolygonCenter(ob_source,i)
print(face_center)
Whats the trick to getting the real world coordinates?