Archived

This topic is now archived and is closed to further replies.

Pure Krome

Re: Lesson 10

Recommended Posts

I''m trying to get my head around lesson 10. this is regarding the STRUCTURE of the data we read in. I understand that essentially to read in the data, we must first know how many TRIANGLES we have in the picture. I''m assuming all model making programs always declare how many polygons, trigangles, whatever form the MODEL. Now each POINT contains 5 pieces of info: x, y, z, u, v x, y, z are easy to understand, they are the 3D position for that point. but u and v? i don''t understand how that comes into play. I know it''s used for textures, but HOW is it devised and what part does it play in the setting up of a world? I hope this makes sence. -PK- -PK-

Share this post


Link to post
Share on other sites
u and v define the 2D texture coordinate of that 3D vertex on your 2D texture. Does that make sense? It sounds slightly confusing I guess. These don''t make a whit of a difference if you''re not doing texture mapping.

Morgan

Share this post


Link to post
Share on other sites
Um. Yes. That i knew. But that is my question!

I know they represent the Co-Ordinates for a texture map, but what i don''t understand is how it can be 2D on a 3D point, and why it''s needed.

Can this please be explained? My closest guess is so that it is texture mapped correctly (ie. not upside, for example).

But i need a proper explanation please =)



-PK-

Share this post


Link to post
Share on other sites
Imagine that you have to apply a texture on a triangle.

the code to render the triangle is

glBegin(GLTRIANGLES;
glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);
glVertex3f( 1.0f, -1.0f, 0.0f);
glEnd();

This is an untextured triangle like this

/\
/ \
/ \
/ \
/ \
/ \
/______\

Now a textured triangle

glBegin(GLTRIANGLES;
glTexCoord2f(0.0f, 1.0f); //top left of the texture
glVertex3f(-1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); //bottom left of the texture
glVertex3f(-1.0f,-1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); //bottom right of the texture
glVertex3f( 1.0f, -1.0f, 0.0f);
glEnd();

The triangles is geometrically the same but now it is texture mapped with a texture image that you have to load previously in your code.

Does it make sense to you ?

Share this post


Link to post
Share on other sites
Sorry, forget my poor try to represent the trianle with ascii character, all the rest is right.

Does anyone know how to include links, and spaces in this shitty message board posts ?

Share this post


Link to post
Share on other sites