PDA

View Full Version : Stretch texture...

Darkpower
06-21-2012, 04:17 AM
Hey!

How can I stretch a texture over the whole terrain? (Using Triangle strips)

Code:

for (int z = 0; z < Z_DEPTH-1; z++)
{
for (int x = 0; x < X_WIDTH-1; x++)
{
buff.put((float)SCALE_X * x).put(height(x, z)).put(-(float)SCALE_Z * z); //Vertex1
index.put(indexCounter++);
buff.put(0.0f).put(0.0f); //Texture1

buff.put((float)(SCALE_X * x + SCALE_X)).put(height(x + 1, z)).put(-(float)SCALE_Z * z); //Vertex2
index.put(indexCounter++);
buff.put(1.0f).put(0.0f); //Texture2

buff.put((float)SCALE_X * x).put(height(x, z + 1)).put((float)(-SCALE_Z * z - SCALE_Z)); //Vertex3
index.put(indexCounter++);
buff.put(0.0f).put(1.0f); //Texture3

buff.put((float)(SCALE_X * x + SCALE_X)).put(height(x + 1, z + 1)).put((float)(-SCALE_Z * z - SCALE_Z)); //Vertex4
index.put(indexCounter++);
buff.put(1.0f).put(1.0f); //Texture4
}
index.put(restart);
}

How can I change all the coords? all help is appreciated.
buff.put(0.0f).put(0.0f); //Texture1
buff.put(1.0f).put(0.0f); //Texture2
buff.put(0.0f).put(1.0f); //Texture3
buff.put(1.0f).put(1.0f); //Texture4

And maybe z++, x++.