texture coordinates?

In one of the tutorials I found, it describes creating a cube that will end up being the background of a video game. The cube moves with the camera, so it never gets closer or further away. When setting the vertexes, it has commands for tu, and tv which "set the u and v components of the texture coordinate."

But WHAT IS A U AND V TEXTURE COORDINATE? I can't figure this out. I've been able to find out it has something to do with wrapping the background image, but nowhere I've found actually tells you what the coordinate is, what it does, why it's necessary in the program, nor what the difference is between them. Can someone PLEASE help me out with this? I'm completely stuck on this problem.

Here's a sample of some of the code they gave me if that helps (my problem spots are highlighted inblue) also, if you could explain thepinkhighlights a little too, I'd be most appreciative:

_topFaceVertex[0].X = -100.0f;

_topFaceVertex[0].Y = 100.0f;

_topFaceVertex[0].Z = -100.0f;

_topFaceVertex[0].Tu= 0.0f;

_topFaceVertex[0].Tv= 1.0f;

_topFaceVertex[0].Nx= 0.0f;

_topFaceVertex[0].Ny= -1.0f;

_topFaceVertex[0].Nz= 0.0f;

_topFaceVertex[1].X = 100.0f;

_topFaceVertex[1].Y = 100.0f;

_topFaceVertex[1].Z = -100.0f;

_topFaceVertex[1].Tu= 0.0f;

_topFaceVertex[1].Tv= 0.0f;

_topFaceVertex[1].Nx= 0.0f;

_topFaceVertex[1].Ny= -1.0f;

_topFaceVertex[1].Nz= 0.0f;

[2073 byte] By [Troy193] at [2007-12-26]
# 1

Hi

I find this article: http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=1044454

Maybe Textures paragraph explain those parameters?

Hope this help.

Markku

MarkkuBehm at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 2

That does help a little bit... so essentially, these tu and tv coordinates simply tell the program which point in the texture file will match with which vertex in an array?

So, in that lesson, it said "In the code we simply assign each texture coordinate to the matching mesh coordinate by dividing it by the number of quads. Doing this results in a single texel spanning a single quad of the terrain."

Could you explain then what it means by "quad" and also, how exactly what the difference is between the u and v coordinates?

Troy193 at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 3

Well, I'm not expert at this kind of programming but Part VI article (http://msdn.microsoft.com/coding4fun/gaming/arcade/article.aspx?articleid=1044115) explain more of that terminology.

Markku

MarkkuBehm at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...
# 4

I suggest checking out this article in the DirectX docs: http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_Summer_04/directx/graphics/ProgrammingGuide/GettingStarted/Direct3DTextures/coordinates/texturecoordinates.asp

That should tell you all you need to know about texture coordinates. Also, the .Nx/.Ny/.Nz members are vertex normals. (They basically indicate which direction is "out" from the mesh for each vertex.) I suggest checking wikipedia for more information on that. http://en.wikipedia.org/wiki/Vertex_normals

PinBender at 2007-9-4 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: General...