Hi to all!
I’m a newbie, so please excuse me for basic question.
I must convert the verts and norms from local to global coords.
So I use this code:
objects = Object.GetSelected()
mesh = objects[0].getData()
m = objects[0].getMatrix()
for v in mesh.verts:
vCoo = mulmatvec3x3(m, v.co)
vNor = mulmatvec3x3(m, v.no)
where the mulmatvec3x3 is:
def mulmatvec3x3(m, v):
r = [0.0, 0.0, 0.0]
r[0] = v[0]*m[0][0] + v[1]*m[1][0] + v[2]*m[2][0]
r[1] = v[0]*m[0][1] + v[1]*m[1][1] + v[2]*m[2][1]
r[2] = v[0]*m[0][2] + v[1]*m[1][2] + v[2]*m[2][2]
return r
The code above don’t work. The verts isn’t modified, as multiplied for a identity matrix…
I’ve added a print m, so I’ve understand the mistake (I hope): getMatrix return a 4x4 matrix. In istance, if I move the object along Y axe, the matrix is:
[1.0000, 0.0000, -0.0000, 0.0000]
[0.0000, 1.0000, 0.0000, 0.0000]
[0.0000, 0.0000, 1.0000, 0.0000]
[0.0000, 12.4396, 0.0000, 1.0000]
Anyone can help me ?
I’m right about the mistake?
Anyone have the 4x4 mult code?
Thanks to all!