Get rot. / loc. from mesh influenced by bone

Hi all,

As some of you might know already I’m extending the VRML 2.0 exporter to support animation export. I made some progress in successfully exporting meshes which have simple animation (keyframed) through rotations and translations.

My target right now is to export a character consisting of meshes (lower leg, upper leg, etc) animated (keyframed) using an armature.

Unfortunately the mesh objects moved and rotated due to bone influence don’t report their positions through the object properties like they did when they were animated by “hand”

I was quite disapointed discovering this fact, since I have to finish this exporter with a week or so.

I hope there is an other way than going through the armatures bones, computing stuff, is there??

Regards,
Christoph

You’re talking about derfomed meshes or just meshes parented to bones?

In the case of a deformed mesh, the deformation doesn’t affect the global rot/loc of the mesh, unless the armature object itself is moved. In both cases, the matrix “should” have the correct location/rotation.

If you need a matrix to euler function, I have one gathering dust somewhere.

Martin

Just meshes parented to bones, no deformation.

In the case of a deformed mesh, the deformation doesn’t affect the global rot/loc of the mesh, unless the armature object itself is moved. In both cases, the matrix “should” have the correct location/rotation.

Ok, I’ll check the matrix

If you need a matrix to euler function, I have one gathering dust somewhere.

Martin

Well, I would be happy to see this function! I’m not a big friend of inventing the wheel twice :wink:

Regards,
Christoph

# only extract rotation component 
def mat2euler_rot(mat): 
	mtx = [list(mat[0][:3]), list(mat[1][:3]), list(mat[2][:3])] 
	angle_y = -asin(max(min(mtx[0][2], 1.0), -1.0)) 
	C = cos(angle_y) 
	if C!=0.0: C = 1.0/C 
	angle_x = atan2(mtx[1][2] * C, mtx[2][2] * C) 
	angle_z = atan2(mtx[0][1] * C, mtx[0][0] * C) 
	return [angle_x, angle_y, angle_z]

It expect a matrice of the form
mat = [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]
I believe it should work with a matrix from the mathutils module (not sure though).

Martin

Hi Martin!

Thanks for the code! Unfortunately the matrix of the animated object (mesh) doesn’t contain the location and rotation information. I printed the matrix of the object for each frame of the animation and they all were absolutly identical… Any suggestion about this?

Edit:
Well, I should have looked at the matrix in world not in local space…

Regards,
Christoph