Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float[] vertices = new float[TILES_WIDE * 3 * TILES_HIGH];
- int[] indices = new int[(TILES_WIDE * 6 * TILES_HIGH) - ((TILES_WIDE + 1) * 6)];
- float[] textureCoordinates = new float[TILES_WIDE * 2 * TILES_HIGH];
- float[] normals = new float[TILES_WIDE * 3 * TILES_HIGH];
- int counter = 0;
- for (int i = 0; i < TILES_HIGH; i++)
- {
- for (int j = 0; j < TILES_WIDE; j++)
- {
- vertices[counter * 3] = i * TILE_SIZE;
- vertices[counter * 3 + 1] = this.position.y;
- vertices[counter * 3 + 2] = j * TILE_SIZE;
- normals[counter * 3] = 0;
- normals[counter * 3 + 1] = 1;
- normals[counter * 3 + 2] = 0;
- textureCoordinates[counter * 2] = (float) j / vertices.length;
- textureCoordinates[counter * 2 + 1] = (float) i / vertices.length;
- counter++;
- }
- }
- counter = 0;
- for (int i = 0; i < TILES_WIDE * TILES_HIGH; i++)
- {
- if (counter + TILES_WIDE + 1 < TILES_WIDE * TILES_HIGH)
- {
- indices[counter * 6 + 0] = counter + TILES_WIDE + 1;
- indices[counter * 6 + 1] = counter;
- indices[counter * 6 + 2] = counter + 1;
- indices[counter * 6 + 3] = counter + 1;
- indices[counter * 6 + 4] = counter + TILES_WIDE + 2;
- indices[counter * 6 + 5] = counter + TILES_WIDE + 1;
- counter++;
- }
- indices[indices.length - 1] += 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement