Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Mesh newQube(float x[], float y[],float z[], Color colors[]) {
- final int length=8;
- Mesh mesh = new Mesh(true, length, 3*length, new VertexAttribute(
- Usage.Position, 3, "quad_positions"), new VertexAttribute(
- Usage.ColorPacked, 4, "quad_colors"));
- float vertices[] = new float[length * 4];
- short indices[] = new short[length * 3];
- for (int a = 0; a < length; a++) {
- vertices[a * 4] = x[a];
- vertices[a * 4 + 1] = y[a];
- vertices[a * 4 + 2] = z[a];
- vertices[a * 4 + 3] = colors[a].toFloatBits();
- indices[a] = (short)a;
- indices[a+4] = (short)a;
- }
- indices[17] = 1;
- indices[18] = 2;
- indices[19] = 3;
- indices[20] = 4;
- indices[21] = 5;
- indices[22] = 6;
- indices[23] = 7;
- mesh.setVertices(vertices);
- mesh.setIndices(indices);
- return mesh;
- }
- }
Add Comment
Please, Sign In to add comment