   How do I determine the UV coordinates of a texture tile?   (newbie)
  Let's say I have textures that are each 128x128 and I have a 4x4 grid of them inside one file.What is the math for getting the UV coordinates of each tile?For example, the first tile should be:  (I think)float tileSizeX = 127 / 511;float tileSizeY = 127 / 511;topLeft = (0, 0)topRight = (tileSizeX, 0)bottomLeft = (0, tileSizeY)bottomRight = (tileSizeX, tileSizeY)I'm using 127 because it's 128 - 1 and I'm using 511 because it's (128 * 4) - 1.Let's say I want tile position (2, 2) now.  How do I get that?  ...and is my math even correct for tile (0, 0)?   
  topLeftX = (tileX * tileSize) / textureSizeXtopleftZ = (tileZ * tileSize) / textureSizeZbottomRightX = ((tileX * tileSize) + tileSize)/ textureSizeXbottomRightZ = ((tileZ * tileSize) + tileSize) / textureSizeZSomething like that.[Edited by - starvinmarvin on May 14, 2009 3:38:36 PM];  Thanks for the reply!I must be doing something wrong because it's not quite working for me.  I seem to getting a little too much of the texture (eg. it's grabbing part of the next texture)...Here are some examples:Here is my tilemap:EDIT: The examples above are several cubes placed right next to each other. The lines you see must be because each texture is grabbing part of the next texture (although, this does help to illustrate that they are infact several cubes and not just one).   ;  something like this, untestedvoid GetTileCoords(int row, int col, int texWidth, int texHeight,   float& left, float& top, float& right, float& bottom){const int kNumRows = 4;const int kNnumCols = 4;// assumes each texture in the texture is squarefloat singleTileWidth = ((float)texWidth) / ((float)kNumCols);float singleTileHeight = ((float)texHeight) / ((float)kNumRows);left = col * singleTileWidth;top = row * singleTileHeight;right = left + singleTileWidth;bottom = top + singleTileHeight;// assuming (0,0) is top left corner adding goes down and rightleft /= texWidth;right /= texWidth;top /= texHeight;bottom /= texHeight;}