Guest User

Untitled

a guest
Nov 23rd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. public static Mesh newQube(float x[], float y[],float z[], Color colors[]) {
  2. final int length=8;
  3. Mesh mesh = new Mesh(true, length, 3*length, new VertexAttribute(
  4. Usage.Position, 3, "quad_positions"), new VertexAttribute(
  5. Usage.ColorPacked, 4, "quad_colors"));
  6.  
  7. float vertices[] = new float[length * 4];
  8. short indices[] = new short[length * 3];
  9. for (int a = 0; a < length; a++) {
  10. vertices[a * 4] = x[a];
  11. vertices[a * 4 + 1] = y[a];
  12. vertices[a * 4 + 2] = z[a];
  13. vertices[a * 4 + 3] = colors[a].toFloatBits();
  14. indices[a] = (short)a;
  15. indices[a+4] = (short)a;
  16. }
  17. indices[17] = 1;
  18. indices[18] = 2;
  19. indices[19] = 3;
  20. indices[20] = 4;
  21. indices[21] = 5;
  22. indices[22] = 6;
  23. indices[23] = 7;
  24.  
  25. mesh.setVertices(vertices);
  26. mesh.setIndices(indices);
  27.  
  28. return mesh;
  29. }
  30. }
Add Comment
Please, Sign In to add comment