[Bf-python] How to export texture coordinates

Campbell Barton ideasman42 at gmail.com
Tue May 5 23:14:43 CEST 2009


It lookes like your doing it right, but UV coords are not assigned to
new models automatic.
In editmode press the U key and try "Sphere from View", then open the
image window to see the UVs

On Tue, May 5, 2009 at 1:02 PM, Tron Thomas <tron.thomas at verizon.net> wrote:
> 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?
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>



-- 
- Campbell



More information about the Bf-python mailing list