Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. float[] vertices = new float[TILES_WIDE * 3 * TILES_HIGH];
  2. int[] indices = new int[(TILES_WIDE * 6 * TILES_HIGH) - ((TILES_WIDE + 1) * 6)];
  3. float[] textureCoordinates = new float[TILES_WIDE * 2 * TILES_HIGH];
  4. float[] normals = new float[TILES_WIDE * 3 * TILES_HIGH];
  5.  
  6. int counter = 0;
  7.  
  8. for (int i = 0; i < TILES_HIGH; i++)
  9. {
  10.  
  11. for (int j = 0; j < TILES_WIDE; j++)
  12. {
  13.  
  14.  
  15. vertices[counter * 3] = i * TILE_SIZE;
  16. vertices[counter * 3 + 1] = this.position.y;
  17. vertices[counter * 3 + 2] = j * TILE_SIZE;
  18.  
  19. normals[counter * 3] = 0;
  20. normals[counter * 3 + 1] = 1;
  21. normals[counter * 3 + 2] = 0;
  22.  
  23. textureCoordinates[counter * 2] = (float) j / vertices.length;
  24. textureCoordinates[counter * 2 + 1] = (float) i / vertices.length;
  25.  
  26. counter++;
  27.  
  28. }
  29.  
  30. }
  31.  
  32. counter = 0;
  33.  
  34. for (int i = 0; i < TILES_WIDE * TILES_HIGH; i++)
  35. {
  36.  
  37. if (counter + TILES_WIDE + 1 < TILES_WIDE * TILES_HIGH)
  38. {
  39.  
  40. indices[counter * 6 + 0] = counter + TILES_WIDE + 1;
  41. indices[counter * 6 + 1] = counter;
  42. indices[counter * 6 + 2] = counter + 1;
  43. indices[counter * 6 + 3] = counter + 1;
  44. indices[counter * 6 + 4] = counter + TILES_WIDE + 2;
  45. indices[counter * 6 + 5] = counter + TILES_WIDE + 1;
  46.  
  47. counter++;
  48.  
  49. }
  50.  
  51. indices[indices.length - 1] += 1;
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement