Global coordinates B2.54

Hi there,
i’m trying to calculate the global coordinates for vertices in 2.54, i thought it would be as easy as in 2.49, just use the object matrix and multiply it with the vertices, but looks like it’s the wrong way.

I’m using kind of this function:


def multMatrix (pV, pM):
    # copy coords for calculation
    coords = mathutils.Vector(pV.__copy__())
    x = coords[0]; y = coords[1]; z = coords[2];

    pV.co[0] = (pM[0][0] * x) + (pM[1][0] * y) + (pM[2][0] * z) + pM[3][0]
    pV.co[1] = (pM[0][1] * x) + (pM[1][1] * y) + (pM[2][1] * z) + pM[3][1]
    pV.co[2] = (pM[0][2] * x) + (pM[1][2] * y) + (pM[2][2] * z) + pM[3][2]

    return

################################

# get global coords from vertex with object
multMatrix(vertex, obj.matrix_world)

But as i am using this sometimes i get totally wrong coordinates, so looks like the objects matrix_world matrix isn’t the right one. The property matrix_local results in the same wrong coordinates…

Also i checked what is happening with the matrix when i am rotating the mesh in objectmode and in editmode. In objectmode the matrix is changing as i rotate the mesh. In editmode nothing happens with the matrix values as i rotate anything. Surly, this is because the local coordinates of the vertices are changing. But anyway, as i would multiply the whole mesh with the global matrix, the coordinates should be correct, but there are not.

You know, you can simply say

global_coords = obj.matrix_world * vertex

Regarding the function you’ve posted, keep an eye on column vs. row major matrix lay-outs, this may have changed between 2.49 and 2.5x

thanks, that is really more simple^^

i think that something changed with the matrices between 2.49 and 2.54, as many other details also ~