   Texture Coordinates ---
  Sup guys,Can anyone (please explain)/(point to a tutorial) how texture coordinates work? I keep looking for tutorials but I came up short :(Thanks.   
Quote:Original post by pcbrainbusterSup guys,Can anyone (please explain)/(point to a tutorial) how texture coordinates work? I keep looking for tutorials but I came up short :(Thanks.Easiest explanation is that they are a ratio.a texture of 512 by 512 has 4 corners.when you texture a quad, you tell the 4 vertex's where they connect to the texture.if you told it to go 0,0.5 --------- 0.5, 0.5|||||0,0 --------- 0.5,0.0you only using half the texture on the x, and half on the y, so your 512 is now 256x256and the quad will only show that much of the texture, like you cropped it.   ;  So you're saying that the center/origin is the bottom left and texture coordinates are like percentages? ;  0.5,0.5 is the center of your texture.in (directx) its0,0 is top left1,0 is top right0,1 is bottom left1,1 is bottom right1= 100%0= 0%0.5= 50%So say you wanted to take your 512x512 texuture, and crop it to 50% with a centered orgin.0.25, 0.250.75,0.250.25,0.750.75,0.75   ;  Yes, I finally get it! There's just one more question; can textures be applied to non-quads?Thanks.   ;Quote:Original post by pcbrainbusterYes, I finally get it! There's just one more question; can textures be applied to non-quads?Thanks.Yes. If you have a triangle which has vertices at (0, 0), (50, 50), (100, 0), then you probably want to apply the texture coordinates (0, 1), (0.5, 0), (1, 1) respectively.You can also use values greater than 1 to repeat the texture. For example using 2's instead of 1's across a quad would repeat the texture twice in each direction (So you'd see it 4 times).   ;  Yes, they can.Each vertex has a texture coordinate.If you make a triangle with 3 vertices, the triangle with be textured using the texture coords, like the triangle is a cookie-cutter and it cuts out the portion of the texture defined by the three sets of tex coords.+--------------+|o   ||    / \  ||   /   \ ||  o-----o||    |+--------------+Each of the three sets of texture coords ( the o's ) defines a point in the texture.;  So how would you actually specify the coordinates(for a triangle)? Could you please show me?Thanks.   ;  In this example, each vertex is comprised of a position (pos), a normal vector (norm) and a pair of texture coordinates (tc).Each vertex position, normal and texture coordinates are specified.  struct SIMPLEVERTEX {  D3DXVECTOR3 pos, norm;  D3DXVECTOR2 tc; }; #define NUMPADTILES 1 SIMPLEVERTEX*verts; padVB->Lock(0,6*sizeof(SIMPLEVERTEX),(VOID**)&verts,0); verts[0].pos = D3DXVECTOR3(-PADSIZE,PADY,PADSIZE); verts[0].norm = D3DXVECTOR3(0,1,0); verts[0].tc = D3DXVECTOR2(0,0); verts[1].pos = D3DXVECTOR3(PADSIZE,PADY,PADSIZE); verts[1].norm = D3DXVECTOR3(0,1,0); verts[1].tc = D3DXVECTOR2(NUMPADTILES,0); verts[2].pos = D3DXVECTOR3(-PADSIZE,PADY,-PADSIZE); verts[2].norm = D3DXVECTOR3(0,1,0); verts[2].tc = D3DXVECTOR2(0,NUMPADTILES); verts[3] = verts[1]; verts[4].pos = D3DXVECTOR3(PADSIZE,PADY,-PADSIZE); verts[4].norm = D3DXVECTOR3(0,1,0); verts[4].tc = D3DXVECTOR2(NUMPADTILES,NUMPADTILES); verts[5] = verts[2]; padVB->Unlock();If you're more familiar with specifying u and v as texture coordinate, the "u" value is tc.x and the "v" value is tc.y.For the line: verts[2].tc = D3DXVECTOR2(0,NUMPADTILES)For the third vertex (verts[2]), the texture coordinate "u" is set to 0 and the tex coord "v" is set to NUMPADTILES.EDIT - added Unlock for completeness.   ;  Thanks. RESOLVED.   