[Bf-python] Bf-python Digest, Vol 56, Issue 1

Tron Thomas tron.thomas at verizon.net
Wed May 6 21:02:50 CEST 2009


Thanks Campbell.  I did what you suggested, and now I'm getting 
reasonable values for the texture coordinates.
> Date: Tue, 5 May 2009 14:14:43 -0700
> From: Campbell Barton <ideasman42 at gmail.com>
> Subject: Re: [Bf-python] How to export texture coordinates
> To: Blender Foundation Python list <bf-python at blender.org>
> Message-ID:
> 	<7c1ab96d0905051414n5b9a3820ra43cb8c35a9fff9b at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> 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
>>     



More information about the Bf-python mailing list