0
$\begingroup$
mesh = obj.meshes[0]

for index in range(mesh.numPolygons):  # iterate over faces
    polygon = mesh.getPolygon(index)
    polyMesh = polygon.getMesh()
    mat_index = polygon.getMaterialIndex()
    for poly_vert_index in range(polygon.getNumVertex()):
        mesh_vert_index = polygon.getVertexIndex(poly_vert_index)
        vertex = mesh.getVertex(mat_index, mesh_vert_index)
        print("Index ",index," polyIndex ",poly_vert_index," vertex ",mesh_vert_index," coord ",vertex.x)

As i move the object (by applying force) the coordinates of each vertex remain the same, how do i get the updated coordinates as the object moves and rotates. Also how do i get the updated face normals of the moving object?

$\endgroup$
1
  • $\begingroup$ Visit this link and look at the part on geting global position of a vertex q-tutsblog.rf.gd/… $\endgroup$ Commented Jun 25, 2019 at 2:38

1 Answer 1

2
$\begingroup$

Reading the mesh provides you with vertex data relative to the object the mesh belongs to = coordinates in Object Space.

As long as you do not deform the mesh this data will remain unchanged.

According to your question you want to get the data in Scene Space. This means it will change when you move or turn the object or one of it's parents.

Positional vectors

You can convert positional vectors from object space to scene space by multiplying them with the object transformation matrix:

positionInSceneSpace = owner.worldTransform * vertex.XYZ

Normal vector

The normal Vector is not a positional vector. It's purpose is to represent a direction rather than a position. Therefore you consider rotation transformation only:

normalInSceneSpace = owner.worldOrientation * vertex.normal
$\endgroup$
1
  • $\begingroup$ UV.. probably me.. but I've not come across the term 'Scene Space' used in Blender before, as opposed to 'World Space' (..isn't that shared by all scenes?) I could be wrong.. or just pedantic ... ;) $\endgroup$
    – Robin Betts
    Commented Jun 25, 2019 at 5:48

You must log in to answer this question.

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