Texture mapping

Advanced game related topics
FvEldijk
New User
New User
Posts: 8
Joined: Sun Sep 05, 2004 9:03 am

Texture mapping

Post 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?
Moonshine
Enthusiast
Enthusiast
Posts: 263
Joined: Tue May 25, 2004 12:13 am
Location: UK

Post 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)
Mark my words, when you least expect it, your uppance will come...
FvEldijk
New User
New User
Posts: 8
Joined: Sun Sep 05, 2004 9:03 am

Post 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?
Moonshine
Enthusiast
Enthusiast
Posts: 263
Joined: Tue May 25, 2004 12:13 am
Location: UK

Post 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.
Mark my words, when you least expect it, your uppance will come...
Post Reply