Page 1 of 1

Texture mapping

Posted: Sat Sep 25, 2004 3:21 pm
by FvEldijk
Can anyone help me with texture mapping?

Do I understand it correctly that:
- you need to define new UV-coords for every triangle?
(which does not sound entirely stange to me)
- you need to define 4 sets of coordinates per triangle?
(Why is that? Why not just three)

So if I have four triangles, for example, I would need to define 4x4=16 sets of UV coords?

Posted: Sat Sep 25, 2004 3:55 pm
by Moonshine
Well one texture image has 4 coordinates, in Direct3D its as follows:

topleft = (0.0, 0.0)
topright = (1.0, 0.0)
bottomleft = (0.0, 1.0)
bottomright = (1.0, 1.0)

The texture is then mapped over the model where each vertex on the model has UV coordinates within the image (which is why a model has one texture, not one per triangle), ranging from 0.0 to 1.0 on each axis. The exact center could be specified with (0.5, 0.5) for example. Heres a link that may explain things a little better:

http://www.thehavok.co.uk/scene/32bits/ ... apping.php

It may be worth noting that in OpenGL things are different, and the coordinates are different:

topleft = (0.0, 1.0)
topright = (1.0, 1.0)
bottomleft = (0.0, 0.0)
bottomright = (1.0, 0.0)

Posted: Sat Sep 25, 2004 4:14 pm
by FvEldijk
Ok,
but I 've red somewhere that you need to define 4 sets of coords per triangle - is this true? Or is your point that I only need to define one set per vertex?

Posted: Sat Sep 25, 2004 11:03 pm
by Moonshine
Im not sure why youd need 4 sets of coordinates per triangle - each vertex has a UV coordinate as far as I know. The texture can then be correctly mapped to the model.