addTexCoords not working?


(RipSting) #1

I’m working on modifying Jan’s OBJ import script so that I can import the UV coordinates that are saved. I’m running into a problem where it’s not setting the UV coordinates when I use the addTexCoords. It’s not even assigning the mesh a TexFace.

Another thing that I hope won’t be a problem (but probably will) is that… In the OBJ file the texture coordinates are assigned on a per-vertex basis, but in Blender I can only assign the texture coordinates on a per-face basis?

Hopefully someone can help me with this…

import Blender210 as Blender

scene  = Blender.getCurrentScene()
mesh   = Blender.Mesh("OBJ")
object = Blender.Object("OBJ")

mesh.enterEditMode()

indices = []

index = mesh.addVertex(2, 1, 0, 0, 0, 0)
indices.append(index)
index = mesh.addVertex(5, 2, 0, 0, 0, 0)
indices.append(index)
index = mesh.addVertex(1, 10, 0, 0, 0, 0)
indices.append(index)

mesh.addTexCoords(0,0.5,0.3,7,3,23,0,0)
mesh.addFace(indices[0], indices[1], indices[2], 0, 0, 0)

Blender.connect(object, mesh)
Blender.connect(scene, object)
mesh.leaveEditMode()