[Bf-python] How to export texture coordinates
Tron Thomas
tron.thomas at verizon.net
Tue May 5 22:02:16 CEST 2009
I am trying to write an exporter for Blender and having difficulty
getting proper texture coordinates for mesh geometry.
I created a UV sphere with 8 segments and 8 rings.
I create a material that includes a JPEG texture image
In mesh editing mode for the sphere I created a new UV Texture.
When I render, the sphere shows up with the texture mapped onto it.
So, it appears that geometry is configure correctly for texturing.
When I try to use the Python API to get texture information, I get an
getting coordinate information that is incorrect.
When I try to the the uvco value of the vertices for the sphere, the
values are all zero.
I wrote this script to check the texture coordinates for the faces on
the sphere:
import Blender
sphere = Blender.Object.GetSelected()[0]
mesh = sphere.getData()
for face in mesh.faces:
if len(face.uv) == 0:
continue
for index in range(0, len(face.v)):
print "Vertex " + str(face.v[index].index) + " has texture
coordinates " + str(face.uv[index])
This produces output like:
Vertex 35 has texture coordinates (0.0, 0.0)
Vertex 7 has texture coordinates (1.0, 0.0)
Vertex 6 has texture coordinates (1.0, 1.0)
Vertex 6 has texture coordinates (0.0, 0.0)
Vertex 7 has texture coordinates (1.0, 0.0)
Vertex 8 has texture coordinates (1.0, 1.0)
Vertex 5 has texture coordinates (0.0, 1.0)
...
This does not seem right as not all these vertices should map to
either 0.0 or 1.0
What is the proper way for someone to get the correct texture
coordinates for mesh vertices?
More information about the Bf-python
mailing list