How can I set UV coordinates for a mesh ?


I’m getting vertices, faces and uv coordinates from a 3rd party app and need to recreate the mesh in Blender 2.49.

mesh ='mesh')

Currently coords is a list containing lists of 3 items,
e.g coords = [[0.0,0.0,0.0],[0.1,0.1,0.1],[1.0,1.0,1.0]…etc.]

I’ve noticed the MVert( object has the uvco property.

How can I set UV coords to my Blender mesh ?


It seems I need to make sure I work with a Mesh instance, not an NMesh, and have an UVLayer there.

something like:

for f in range(0,len(fmesh.faces):
    fmesh.faces[f].uv = [myuvs[f],myuvs[f+1],myuvs[f+2],myuvs[f+3]]

where myuvs[f] would a 2d vector: Vector(0.0,0.0) from the Mathutils.

the snippet isn’t the best way to do it, but just a way to access and set uvs.