[gameprogrammer] Re: Texture Coordinates

  • From: Richard Sabbarton <richard.sabbarton@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Thu, 6 Aug 2009 23:46:07 +0100

Hi All,

I thought I would share the solution came up with on working out the
texture coordinates.

What I am doing is cycling through the vertices and calculating the
distance between them to get a total width/height for the mesh.  I
guess this is the virtual equivalent of stretching the mesh out flat
on a table...  I then cycle through the vertices again adjusting the
texture coordinates according to the dimensions of the flattened mesh
and the distance between the vertices.  In the tank example from my
previous mail the texture appeared stretched along the top surface and
then condenced at the front and rear where there is a higher density
of vertices (for the curved shape.)  After running the
TextureCoordinate recalculation the texture is smoothed out so that it
wraps evenly around the body of the tank without the previous
distortion.

Regards

Richard

2009/7/23 Richard Sabbarton <richard.sabbarton@xxxxxxxxx>:
> Hi Esam,
>
> The application is a model creator.  I am putting it together to
> create simple 3D models for use in games.  I have attached an example
> model of a tank that I have created using my app and a copy of the
> output file it generates.   I have also attached a screenshot of the
> app (still using hand drawn GUI atm...)  This should give you an idea
> of what the program is doing.  The reason for doing it is that I am
> not really a designer.  I don't have 3DSMax and if I did I wouldn't
> know how to use it.  If you look at the attached model you can see
> there is quite a number of vertices.  I am already able to switch on
> textures in the application but by the time I have manipulated the
> vertices into position the texture coordinates are normally pretty
> useless.  If there is a mechanism for automatically calculating a
> "best fit" then this is what I think I need to do.  Maybe with some
> manual fine tuning once this is done.  It would be interesting to know
> how applications like 3DSMax handle this sort of thing.
>
> I appreciate your feedback.
>
> Rich
>
> 2009/7/22 Esam Bustaty <e.bustaty@xxxxxxxxxx>:
>> Can you give us more idea about what does the application do??
>> If you use 3DSMax there is many ways to assign texture coordinates (auto or
>> manual), I think I can help making most of them, but I just need to
>> understand what you need to help you with...
>>
>> ________________________________
>> From: Richard Sabbarton <richard.sabbarton@xxxxxxxxx>
>> To: gameprogrammer@xxxxxxxxxxxxx
>> Sent: Thursday, 23 July, 2009 12:42:21 AM
>> Subject: [gameprogrammer] Texture Coordinates
>>
>> Hi Guys,
>>
>> I am looking for some advice on how best to determine texture
>> coordinates for vertices.  I have been developing a 3D model utility
>> that can be used to create models for use in games and I am looking
>> for the best way of setting up texture coordinates.  The model format
>> is a simple array of vertices that are arranged into stacks of
>> TRIANGLE_STRIPS.  Each vertex has an assigned set of Texture
>> Coordinates.  I can create a new mesh, say a 4 vertex quad with
>> texture coordinates assigned correctly.  I can then subdivide the mesh
>> into 9 vertices and again into 25 vertices.  I don't have a problem
>> preserving the texture coordinates during subdivision but when I start
>> maniplulating the vertex coordinates it will stretch and skew the
>> texture.  I have no issues with why this is occuring, I am just
>> looking for advice on how best to manage texture coordinates.
>>
>> At the moment, the application allows you to select vertices and
>> adjust the texture coordinates manually but I am sure there must be a
>> better way of doing it that that...
>>
>> Any thoughts?
>>
>> Richard
>>
>>
>> P.S. If anyone is interesting in assisting with some testing of this
>> app then let me know.  I am thinking of making it freely available
>> when completed if there is some interest.
>>
>> ---------------------
>> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>>
>>
>>
>>
>

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: