List of usage examples for javax.media.j3d IndexedQuadArray setColors
public void setColors(int index, float colors[])
From source file:AppearanceExplorer.java
Shape3D createColorCube() { // color cube int[] indices = { 0, 3, 4, 2, // left face x = -1 0, 1, 5, 3, // bottom face y = -1 0, 2, 6, 1, // back face z = -1 7, 5, 1, 6, // right face x = 1 7, 6, 2, 4, // top face y = 1 7, 4, 3, 5 // front face z = 1 };/*from ww w . ja va 2s. c o m*/ Point3f pts[] = new Point3f[8]; pts[0] = new Point3f(-1.0f, -1.0f, -1.0f); pts[1] = new Point3f(1.0f, -1.0f, -1.0f); pts[2] = new Point3f(-1.0f, 1.0f, -1.0f); pts[3] = new Point3f(-1.0f, -1.0f, 1.0f); pts[4] = new Point3f(-1.0f, 1.0f, 1.0f); pts[5] = new Point3f(1.0f, -1.0f, 1.0f); pts[6] = new Point3f(1.0f, 1.0f, -1.0f); pts[7] = new Point3f(1.0f, 1.0f, 1.0f); Color3f colr[] = new Color3f[8]; colr[0] = black; colr[1] = red; colr[2] = green; colr[3] = blue; colr[4] = cyan; colr[5] = magenta; colr[6] = yellow; colr[7] = white; // The normals point out from 0,0,0, through the verticies of the // cube. These can be calculated by copying the coordinates to // a Vector3f and normalizing. Vector3f norm[] = new Vector3f[8]; for (int i = 0; i < 8; i++) { norm[i] = new Vector3f(pts[i]); norm[i].normalize(); } IndexedQuadArray iqa = new IndexedQuadArray(8, GeometryArray.COORDINATES | GeometryArray.COLOR_3 | GeometryArray.NORMALS, 24); iqa.setCoordinates(0, pts); iqa.setColors(0, colr); iqa.setNormals(0, norm); iqa.setCoordinateIndices(0, indices); iqa.setColorIndices(0, indices); iqa.setNormalIndices(0, indices); return new Shape3D(iqa, appearance); }