Example usage for javax.media.j3d GeometryArray COLOR_3

List of usage examples for javax.media.j3d GeometryArray COLOR_3

Introduction

In this page you can find the example usage for javax.media.j3d GeometryArray COLOR_3.

Prototype

int COLOR_3

To view the source code for javax.media.j3d GeometryArray COLOR_3.

Click Source Link

Document

Specifies that this GeometryArray contains an array of colors without alpha.

Usage

From source file:FarbWurfelAsQuads.java

/**
 * Erstellung des ColorCube/*w  w w  .  ja  va  2  s . c o  m*/
 * 
 * @return
 */
private QuadArray makeCube() {
    QuadArray plane = new QuadArray(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
    // Punkte und Farben
    Point3f pa = new Point3f(-1.0f, 1.0f, -1.0f);
    Point3f pb = new Point3f(-1.0f, -1.0f, -1.0f);
    Point3f pc = new Point3f(1.0f, -1.0f, -1.0f);
    Point3f pd = new Point3f(1.0f, 1.0f, -1.0f);
    Point3f pe = new Point3f(-1.0f, 1.0f, 1.0f);
    Point3f pf = new Point3f(-1.0f, -1.0f, 1.0f);
    Point3f pg = new Point3f(1.0f, -1.0f, 1.0f);
    Point3f ph = new Point3f(1.0f, 1.0f, 1.0f);
    // Coloreigenschaften
    Color3f red = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f blue = new Color3f(0.0f, 0.0f, 1.0f);
    Color3f green = new Color3f(0.0f, 1.0f, 0.0f);
    Color3f cyan = new Color3f(0.0f, 1.0f, 1.0f);
    Color3f yellow = new Color3f(1.0f, 1.0f, 0.0f);
    Color3f magenta = new Color3f(1.0f, 0.0f, 1.0f);

    // 1. Seite
    plane.setCoordinate(0, pa);
    plane.setColor(0, red);
    plane.setCoordinate(1, pb);
    plane.setColor(1, red);
    plane.setCoordinate(2, pc);
    plane.setColor(2, red);
    plane.setCoordinate(3, pd);
    plane.setColor(3, red);
    // 2. Seite
    plane.setCoordinate(4, pe);
    plane.setColor(4, blue);
    plane.setCoordinate(5, pf);
    plane.setColor(5, blue);
    plane.setCoordinate(6, pg);
    plane.setColor(6, blue);
    plane.setCoordinate(7, ph);
    plane.setColor(7, blue);
    // 3. Seite
    plane.setCoordinate(8, pe);
    plane.setColor(8, green);
    plane.setCoordinate(9, pf);
    plane.setColor(9, green);
    plane.setCoordinate(10, pb);
    plane.setColor(10, green);
    plane.setCoordinate(11, pa);
    plane.setColor(11, green);
    // 4. Seite
    plane.setCoordinate(12, pd);
    plane.setColor(12, cyan);
    plane.setCoordinate(13, pc);
    plane.setColor(13, cyan);
    plane.setCoordinate(14, pg);
    plane.setColor(14, cyan);
    plane.setCoordinate(15, ph);
    plane.setColor(15, cyan);
    // 5. Seite
    plane.setCoordinate(16, pe);
    plane.setColor(16, yellow);
    plane.setCoordinate(17, pa);
    plane.setColor(17, yellow);
    plane.setCoordinate(18, pd);
    plane.setColor(18, yellow);
    plane.setCoordinate(19, ph);
    plane.setColor(19, yellow);
    // 6. Seite
    plane.setCoordinate(20, pf);
    plane.setColor(20, magenta);
    plane.setCoordinate(21, pb);
    plane.setColor(21, magenta);
    plane.setCoordinate(22, pc);
    plane.setColor(22, magenta);
    plane.setCoordinate(23, pg);
    plane.setColor(23, magenta);
    // ubergib den Wurfel
    return plane;
}

From source file:KeyNavigatorApp.java

Shape3D createPyramid() {
    IndexedTriangleArray pyGeom = new IndexedTriangleArray(5, GeometryArray.COORDINATES | GeometryArray.COLOR_3,
            12);/*from  www.  j  a v a2  s .  c o  m*/

    pyGeom.setCoordinate(0, new Point3f(0.0f, 0.7f, 0.0f));
    pyGeom.setCoordinate(1, new Point3f(-0.4f, 0.0f, -0.4f));
    pyGeom.setCoordinate(2, new Point3f(-0.4f, 0.0f, 0.4f));
    pyGeom.setCoordinate(3, new Point3f(0.4f, 0.0f, 0.4f));
    pyGeom.setCoordinate(4, new Point3f(0.4f, 0.0f, -0.4f));

    pyGeom.setCoordinateIndex(0, 0);
    pyGeom.setCoordinateIndex(1, 1);
    pyGeom.setCoordinateIndex(2, 2);
    pyGeom.setCoordinateIndex(3, 0);
    pyGeom.setCoordinateIndex(4, 2);
    pyGeom.setCoordinateIndex(5, 3);
    pyGeom.setCoordinateIndex(6, 0);
    pyGeom.setCoordinateIndex(7, 3);
    pyGeom.setCoordinateIndex(8, 4);
    pyGeom.setCoordinateIndex(9, 0);
    pyGeom.setCoordinateIndex(10, 4);
    pyGeom.setCoordinateIndex(11, 1);

    Color3f c = new Color3f(0.6f, 0.5f, 0.55f);
    pyGeom.setColor(0, c);
    pyGeom.setColor(1, c);
    pyGeom.setColor(2, c);
    pyGeom.setColor(3, c);
    pyGeom.setColor(4, c);

    Shape3D pyramid = new Shape3D(pyGeom);
    return pyramid;
}

From source file:KeyNavigatorApp.java

Shape3D createLand() {
    LineArray landGeom = new LineArray(44, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
    float l = -50.0f;
    for (int c = 0; c < 44; c += 4) {

        landGeom.setCoordinate(c + 0, new Point3f(-50.0f, 0.0f, l));
        landGeom.setCoordinate(c + 1, new Point3f(50.0f, 0.0f, l));
        landGeom.setCoordinate(c + 2, new Point3f(l, 0.0f, -50.0f));
        landGeom.setCoordinate(c + 3, new Point3f(l, 0.0f, 50.0f));
        l += 10.0f;//from w w w  .j a  va2 s.  com
    }

    Color3f c = new Color3f(0.1f, 0.8f, 0.1f);
    for (int i = 0; i < 44; i++)
        landGeom.setColor(i, c);

    return new Shape3D(landGeom);
}

From source file:PointTest.java

private BranchGroup createPoints(final int nPointSize, final int nNumPoints, boolean bAliased) {
    BranchGroup bg = new BranchGroup();

    String szText = new String();
    szText += (nNumPoints + "X, Size:" + nPointSize + ", aliased: " + bAliased);

    Font3D f3d = new Font3D(new Font("SansSerif", Font.PLAIN, 1), new FontExtrusion());
    Text3D label3D = new Text3D(f3d, szText, new Point3f(-5, 0, 0));
    Shape3D sh = new Shape3D(label3D);

    bg.addChild(sh);//from  w w w. j  a  v  a2 s .c  o  m

    PointArray pointArray = new PointArray(nNumPoints * nNumPoints,
            GeometryArray.COORDINATES | GeometryArray.COLOR_3);

    // create the PointArray that we will be rendering
    int nPoint = 0;
    final double factor = 1.0 / nNumPoints;

    for (int n = 0; n < nNumPoints; n++) {
        for (int i = 0; i < nNumPoints; i++) {
            Point3f point = new Point3f(n - nNumPoints / 2, i - nNumPoints / 2, 0.0f);
            pointArray.setCoordinate(nPoint, point);
            pointArray.setColor(nPoint++, new Color3f(0.5f, (float) (n * factor), (float) (i * factor)));
        }
    }

    // create the material for the points
    Appearance pointApp = new Appearance();

    // enlarge the points
    pointApp.setPointAttributes(new PointAttributes(nPointSize, bAliased));

    Shape3D pointShape = new Shape3D(pointArray, pointApp);

    bg.addChild(pointShape);
    return bg;
}

From source file:IntersectTest.java

RandomColorTetrahedron() {
    super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(0.5f, 0.5f, 0.5f);
    verts[1] = new Point3f(0.5f, -0.5f, -0.5f);
    verts[2] = new Point3f(-0.5f, -0.5f, 0.5f);
    verts[3] = new Point3f(-0.5f, 0.5f, -0.5f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);

    Point3f pnts[] = new Point3f[12];
    Color3f clrs[] = new Color3f[12];

    pnts[0] = verts[2];//from   w  w w. ja  va2  s. c o m
    clrs[0] = colors[(int) (Math.random() * 3.0)];
    pnts[1] = verts[1];
    clrs[1] = colors[(int) (Math.random() * 3.0)];
    pnts[2] = verts[0];
    clrs[2] = colors[(int) (Math.random() * 3.0)];

    pnts[3] = verts[3];
    clrs[3] = colors[(int) (Math.random() * 3.0)];
    pnts[4] = verts[2];
    clrs[4] = colors[(int) (Math.random() * 3.0)];
    pnts[5] = verts[0];
    clrs[5] = colors[(int) (Math.random() * 3.0)];

    pnts[6] = verts[1];
    clrs[6] = colors[(int) (Math.random() * 3.0)];
    pnts[7] = verts[2];
    clrs[7] = colors[(int) (Math.random() * 3.0)];
    pnts[8] = verts[3];
    clrs[8] = colors[(int) (Math.random() * 3.0)];

    pnts[9] = verts[1];
    clrs[9] = colors[(int) (Math.random() * 3.0)];
    pnts[10] = verts[3];
    clrs[10] = colors[(int) (Math.random() * 3.0)];
    pnts[11] = verts[0];
    clrs[11] = colors[(int) (Math.random() * 3.0)];

    setCoordinates(0, pnts);
    setColors(0, clrs);
}

From source file:IntersectTest.java

RandomColorCube() {
    super(24, GeometryArray.COORDINATES | GeometryArray.COLOR_3);

    Point3f verts[] = new Point3f[8];
    Color3f colors[] = new Color3f[3];

    verts[0] = new Point3f(0.5f, 0.5f, 0.5f);
    verts[1] = new Point3f(-0.5f, 0.5f, 0.5f);
    verts[2] = new Point3f(-0.5f, -0.5f, 0.5f);
    verts[3] = new Point3f(0.5f, -0.5f, 0.5f);
    verts[4] = new Point3f(0.5f, 0.5f, -0.5f);
    verts[5] = new Point3f(-0.5f, 0.5f, -0.5f);
    verts[6] = new Point3f(-0.5f, -0.5f, -0.5f);
    verts[7] = new Point3f(0.5f, -0.5f, -0.5f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);

    Point3f pnts[] = new Point3f[24];
    Color3f clrs[] = new Color3f[24];

    pnts[0] = verts[0];//from  w w  w . j a va  2 s . co  m
    clrs[0] = colors[(int) (Math.random() * 3.0)];
    pnts[1] = verts[3];
    clrs[1] = colors[(int) (Math.random() * 3.0)];
    pnts[2] = verts[7];
    clrs[2] = colors[(int) (Math.random() * 3.0)];
    pnts[3] = verts[4];
    clrs[3] = colors[(int) (Math.random() * 3.0)];

    pnts[4] = verts[1];
    clrs[4] = colors[(int) (Math.random() * 3.0)];
    pnts[5] = verts[5];
    clrs[5] = colors[(int) (Math.random() * 3.0)];
    pnts[6] = verts[6];
    clrs[6] = colors[(int) (Math.random() * 3.0)];
    pnts[7] = verts[2];
    clrs[7] = colors[(int) (Math.random() * 3.0)];

    pnts[8] = verts[0];
    clrs[8] = colors[(int) (Math.random() * 3.0)];
    pnts[9] = verts[4];
    clrs[9] = colors[(int) (Math.random() * 3.0)];
    pnts[10] = verts[5];
    clrs[10] = colors[(int) (Math.random() * 3.0)];
    pnts[11] = verts[1];
    clrs[11] = colors[(int) (Math.random() * 3.0)];

    pnts[12] = verts[3];
    clrs[12] = colors[(int) (Math.random() * 3.0)];
    pnts[13] = verts[2];
    clrs[13] = colors[(int) (Math.random() * 3.0)];
    pnts[14] = verts[6];
    clrs[14] = colors[(int) (Math.random() * 3.0)];
    pnts[15] = verts[7];
    clrs[15] = colors[(int) (Math.random() * 3.0)];

    pnts[16] = verts[0];
    clrs[16] = colors[(int) (Math.random() * 3.0)];
    pnts[17] = verts[1];
    clrs[17] = colors[(int) (Math.random() * 3.0)];
    pnts[18] = verts[2];
    clrs[18] = colors[(int) (Math.random() * 3.0)];
    pnts[19] = verts[3];
    clrs[19] = colors[(int) (Math.random() * 3.0)];

    pnts[20] = verts[7];
    clrs[20] = colors[(int) (Math.random() * 3.0)];
    pnts[21] = verts[6];
    clrs[21] = colors[(int) (Math.random() * 3.0)];
    pnts[22] = verts[5];
    clrs[22] = colors[(int) (Math.random() * 3.0)];
    pnts[23] = verts[4];
    clrs[23] = colors[(int) (Math.random() * 3.0)];

    setCoordinates(0, pnts);
    setColors(0, clrs);
}

From source file:PickTest.java

TetrahedronILSA() {
    super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 8, lineLengths);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(1.0f, 1.0f, 1.0f);
    verts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    verts[2] = new Point3f(-1.0f, -1.0f, 1.0f);
    verts[3] = new Point3f(-1.0f, 1.0f, -1.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);

    int pntsIndex[] = new int[8];
    int clrsIndex[] = new int[8];

    pntsIndex[0] = 0;/*from w ww. j av  a2  s  .c o  m*/
    clrsIndex[0] = 0;
    pntsIndex[1] = 1;
    clrsIndex[1] = 1;
    pntsIndex[2] = 3;
    clrsIndex[2] = 3;
    pntsIndex[3] = 2;
    clrsIndex[3] = 2;

    pntsIndex[4] = 1;
    clrsIndex[4] = 1;
    pntsIndex[5] = 2;
    clrsIndex[5] = 2;
    pntsIndex[6] = 0;
    clrsIndex[6] = 0;
    pntsIndex[7] = 3;
    clrsIndex[7] = 3;

    setCoordinates(0, verts);
    setCoordinateIndices(0, pntsIndex);
    setColors(0, colors);
    setColorIndices(0, clrsIndex);
}

From source file:PickTest.java

TetrahedronILA() {
    super(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3, 12);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(1.0f, 1.0f, 1.0f);
    verts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    verts[2] = new Point3f(-1.0f, -1.0f, 1.0f);
    verts[3] = new Point3f(-1.0f, 1.0f, -1.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);

    int[] pntsIndex = new int[12];
    int[] clrsIndex = new int[12];

    pntsIndex[0] = 0;/*  w  w w .  ja  v a  2 s  .c  om*/
    clrsIndex[0] = 0;
    pntsIndex[1] = 1;
    clrsIndex[1] = 1;

    pntsIndex[2] = 1;
    clrsIndex[2] = 1;
    pntsIndex[3] = 2;
    clrsIndex[3] = 2;

    pntsIndex[4] = 2;
    clrsIndex[4] = 2;
    pntsIndex[5] = 0;
    clrsIndex[5] = 0;

    pntsIndex[6] = 1;
    clrsIndex[6] = 1;
    pntsIndex[7] = 3;
    clrsIndex[7] = 3;

    pntsIndex[8] = 2;
    clrsIndex[8] = 2;
    pntsIndex[9] = 3;
    clrsIndex[9] = 3;

    pntsIndex[10] = 0;
    clrsIndex[10] = 0;
    pntsIndex[11] = 3;
    clrsIndex[11] = 3;

    setCoordinates(0, verts);
    setCoordinateIndices(0, pntsIndex);
    setColors(0, colors);
    setColorIndices(0, clrsIndex);
}

From source file:PickTest.java

TetrahedronTA() {
    super(12, GeometryArray.COORDINATES | GeometryArray.COLOR_3);

    Point3f verts[] = new Point3f[4];
    Color3f colors[] = new Color3f[4];

    verts[0] = new Point3f(1.0f, 1.0f, 1.0f);
    verts[1] = new Point3f(1.0f, -1.0f, -1.0f);
    verts[2] = new Point3f(-1.0f, -1.0f, 1.0f);
    verts[3] = new Point3f(-1.0f, 1.0f, -1.0f);

    colors[0] = new Color3f(1.0f, 0.0f, 0.0f);
    colors[1] = new Color3f(0.0f, 1.0f, 0.0f);
    colors[2] = new Color3f(0.0f, 0.0f, 1.0f);
    colors[3] = new Color3f(1.0f, 1.0f, 0.0f);

    Point3f pnts[] = new Point3f[12];
    Color3f clrs[] = new Color3f[12];

    pnts[0] = verts[2];//from  w w  w .j  a v  a 2  s  .c  om
    clrs[0] = colors[0];
    pnts[1] = verts[1];
    clrs[1] = colors[0];
    pnts[2] = verts[0];
    clrs[2] = colors[0];

    pnts[3] = verts[3];
    clrs[3] = colors[1];
    pnts[4] = verts[2];
    clrs[4] = colors[1];
    pnts[5] = verts[0];
    clrs[5] = colors[1];

    pnts[6] = verts[1];
    clrs[6] = colors[2];
    pnts[7] = verts[2];
    clrs[7] = colors[2];
    pnts[8] = verts[3];
    clrs[8] = colors[2];

    pnts[9] = verts[1];
    clrs[9] = colors[3];
    pnts[10] = verts[3];
    clrs[10] = colors[3];
    pnts[11] = verts[0];
    clrs[11] = colors[3];

    setCoordinates(0, pnts);
    setColors(0, clrs);
}

From source file:AppearanceExplorer.java

Shape3D createLineArray() {

    Point3f pnt[] = new Point3f[4];
    pnt[0] = new Point3f(-1.0f, -1.0f, 0.0f);
    pnt[1] = new Point3f(1.0f, -1.0f, 0.0f);
    pnt[2] = new Point3f(1.0f, 1.0f, 0.0f);
    pnt[3] = new Point3f(-1.0f, 1.0f, 0.0f);
    Color3f colrs[] = new Color3f[4];
    colrs[0] = black;//w  w  w.  j  a  v a  2  s  .c o  m
    colrs[1] = white;
    colrs[2] = red;
    colrs[3] = green;

    LineArray la = new LineArray(4, GeometryArray.COORDINATES | GeometryArray.COLOR_3);
    la.setCoordinates(0, pnt);
    la.setColors(0, colrs);

    return new Shape3D(la, appearance);
}