Proper UV Coords and Joint Rotation/position Export

Had my exporter working fine for UV Coords to export but since the update to 2.63. So ive been trying to try a few things for the past week and no luck has appeared. The closest i’ve been is exporting values but, they are incorrect.
Whats exporting from Blender

0.669797 1.300080
0.318956 1.496827
0.377478 1.571246

What should be exporting:

0.344562 1.453787
0.318956 1.503173
0.346527 1.510960

As for the code to get the UV Coords:

for obj in bpy.context.selectable_objects:
		if obj.type == 'MESH':
			temp =
			me =
			me.transform(EXPORT_GLOBAL_MATRIX * obj.matrix_world)
			uv_layer =
			for face in me.faces:
					uv1x =[face.verts[0].index].uv.x
					uv1y =[face.verts[0].index].uv.y
					uv1x = 0.0
					uv1y = 0.0
					uv2x =[face.verts[1].index].uv.x
					uv2y =[face.verts[1].index].uv.y
					uv2x = 0.0
					uv2y = 0.0	
					uv3x =[face.verts[2].index].uv.x
					uv3y = 2.0 + vec([face.verts[2].index].uv.y
					uv3x = 0.0
					uv3y = 0.0
					uv4x =[face.verts[3].index].uv.x
					uv4y = 2.0 + vec([face.verts[3].index].uv.y
					uv4x = 0.0
					uv4y = 0.0

I’ve added 2.0 to each y (don’t ask why it was more suggested for the last version and it worked fine so I thought id try it. Any Advice?

Also, been looking for how to get the world position for joints as well as the rotation for the joints. I have got values but they are incorrect. Here is my code:

for obj in bpy.context.selectable_objects:
		me =
		if obj.type == 'ARMATURE':
			obj.matrix_local *= obj.matrix_world
			for bone in me.bones:
				getBoneRot = bone.matrix_local.to_euler()
				fw( + '
					fw( + '
				fw('%.6f %.6f %.6f %.6f %.6f %.6f
' % (bone.head.x, bone.head.y, bone.head.z, getBoneRot.x, getBoneRot.y, getBoneRot.z))

first off, there’s no Mesh.faces in 2.63, Bmesh uses Mesh.polygons instead.

Your code tries to retrieve uv data like it was done before 2.63, using uv1-uv4. They corresponded to a face’s vertices_raw (every face was internally a quad).

This is no longer the case! uv_layers contains uv coordinates per face loop. And faces can be n-gons now.

A simple cube has 8 vertices, 8 edges, 6 faces and 24 loops:

vertex colors and uv coords are stored per loop, not as properties of faces/vertices.

>>> for p in
...     for v in p.vertices:
...[v].co # Vert coords of the polygon
...[v].uv # matching UV coords (poly vert indices equal uv layer loops here)

Bone matrices in world space: i used this for my CoD-IO script:

b_matrix = armature.matrix_world * bone.matrix_local
file.write("X %.6f %.6f %.6f
" % (b_matrix[0][0], b_matrix[1][0], b_matrix[2][0]))
file.write("Y %.6f %.6f %.6f
" % (b_matrix[0][1], b_matrix[1][1], b_matrix[2][1]))
file.write("Z %.6f %.6f %.6f
" % (b_matrix[0][2], b_matrix[1][2], b_matrix[2][2]))

Note that matrices are row-major since 2.62, before you had to use:

file.write("X %.6f %.6f %.6f
" % (b_matrix[0][0], b_matrix[0][1], b_matrix[0][2]))
file.write("Y %.6f %.6f %.6f
" % (b_matrix[1][0], b_matrix[1][1], b_matrix[1][2]))
file.write("Z %.6f %.6f %.6f
" % (b_matrix[2][0], b_matrix[2][1], b_matrix[2][2]))

–> [#1][#2] swapped to [#2][#1]

Thanks for the reply!

For the UV Coords:

Is that not essentially what I am doing?

me is a bmesh thats got its data from a mesh object. therefore

bmesh.faces[0].verts[0].index should return the first verts index on the first face correct? still such thing as faces i hope haha.

but then use:[me.faces[0].verts[0].index].uv

should that not do the same thing as what you have shown me?

For the Bone Position and rotation, ill take a look when i get home!

Once again thanks for the reply :slight_smile: