Example usage for javax.media.j3d Shape3D setCapability

List of usage examples for javax.media.j3d Shape3D setCapability

Introduction

In this page you can find the example usage for javax.media.j3d Shape3D setCapability.

Prototype

public final void setCapability(int bit) 

Source Link

Document

Sets the specified capability bit.

Usage

From source file:LightsNPlanesApp.java

public LightsNPlanesApp() {
    setLayout(new BorderLayout());
    Canvas3D c = new Canvas3D(null);
    add("Center", c);

    BoundingSphere bounds = new BoundingSphere(new Point3d(), 0.1);

    Vector3f direction = new Vector3f(0.0f, -1.0f, 0.0f);
    Point3f position = new Point3f(0.0f, 0.5f, -0.3f);

    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f red = new Color3f(1.0f, 0.0f, 0.0f);
    Color3f green = new Color3f(0.0f, 1.0f, 0.0f);
    Color3f blue = new Color3f(0.0f, 0.0f, 1.0f);

    BranchGroup scene = new BranchGroup();

    IndexedQuadArray qa = new IndexedQuadArray(9, QuadArray.COORDINATES | QuadArray.NORMALS, 16);
    qa.setCoordinate(0, new Point3f(-0.3f, 0.3f, -0.3f));
    qa.setCoordinate(1, new Point3f(0.0f, 0.3f, -0.3f));
    qa.setCoordinate(2, new Point3f(0.3f, 0.3f, -0.3f));
    qa.setCoordinate(3, new Point3f(-0.3f, 0.0f, 0.0f));
    qa.setCoordinate(4, new Point3f(0.0f, 0.0f, 0.0f));
    qa.setCoordinate(5, new Point3f(0.3f, 0.0f, 0.0f));
    qa.setCoordinate(6, new Point3f(-0.3f, -0.3f, 0.3f));
    qa.setCoordinate(7, new Point3f(0.0f, -0.3f, 0.3f));
    qa.setCoordinate(8, new Point3f(0.3f, -0.3f, 0.3f));
    Vector3f n = new Vector3f(0.0f, 0.6f, 0.8f);
    n.normalize();//from  www .  j  a v a 2s .  co m
    qa.setNormal(0, n);
    qa.setNormal(1, n);
    qa.setNormal(2, n);
    qa.setNormal(3, n);
    qa.setNormal(4, n);
    qa.setNormal(5, n);
    qa.setNormal(6, n);
    qa.setNormal(7, n);
    qa.setNormal(8, n);

    qa.setCoordinateIndex(0, 0);
    qa.setCoordinateIndex(1, 3);
    qa.setCoordinateIndex(2, 4);
    qa.setCoordinateIndex(3, 1);
    qa.setCoordinateIndex(4, 1);
    qa.setCoordinateIndex(5, 4);
    qa.setCoordinateIndex(6, 5);
    qa.setCoordinateIndex(7, 2);
    qa.setCoordinateIndex(8, 3);
    qa.setCoordinateIndex(9, 6);
    qa.setCoordinateIndex(10, 7);
    qa.setCoordinateIndex(11, 4);
    qa.setCoordinateIndex(12, 4);
    qa.setCoordinateIndex(13, 7);
    qa.setCoordinateIndex(14, 8);
    qa.setCoordinateIndex(15, 5);

    TransformGroup trans1 = createTG(-0.7f, 0.0f, -0.5f);
    scene.addChild(trans1);

    TransformGroup trans2 = createTG(0.0f, 0.0f, -0.5f);
    scene.addChild(trans2);

    TransformGroup trans3 = createTG(0.7f, 0.0f, -0.5f);
    scene.addChild(trans3);

    Appearance qAppear = createMatAppear(white, white, 5.0f);
    Shape3D p1 = new Shape3D(qa, qAppear);
    //    p1.setBoundsAutoCompute(false);
    p1.setBounds(bounds);
    p1.setCapability(Node.ALLOW_BOUNDS_READ);
    trans1.addChild(p1);

    Shape3D p2 = new Shape3D(qa, qAppear);
    p2.setBounds(bounds);
    p2.setCapability(Node.ALLOW_BOUNDS_READ);
    trans2.addChild(p2);

    Shape3D p3 = new Shape3D(qa, qAppear);
    p3.setBounds(bounds);
    p3.setCapability(Node.ALLOW_BOUNDS_READ);
    trans3.addChild(p3);

    AmbientLight lightA = new AmbientLight();
    lightA.setInfluencingBounds(new BoundingSphere());
    lightA.setCapability(Light.ALLOW_INFLUENCING_BOUNDS_READ);
    scene.addChild(lightA);

    DirectionalLight lightD = new DirectionalLight();
    lightD.setInfluencingBounds(bounds);
    lightD.setBoundsAutoCompute(false);
    lightD.setCapability(Light.ALLOW_INFLUENCING_BOUNDS_READ);
    lightD.setDirection(direction);
    lightD.setColor(red);
    trans1.addChild(lightD);

    PointLight lightP = new PointLight();
    lightP.setInfluencingBounds(bounds);
    lightP.setCapability(Light.ALLOW_INFLUENCING_BOUNDS_READ);
    lightP.setPosition(position);
    lightP.setColor(green);
    trans2.addChild(lightP);

    SpotLight lightS = new SpotLight();
    lightS.setInfluencingBounds(bounds);
    lightS.setCapability(Light.ALLOW_INFLUENCING_BOUNDS_READ);
    lightS.setPosition(position);
    lightS.setDirection(direction);
    lightS.setSpreadAngle(0.3f);
    lightS.setConcentration(1.0f);
    lightS.setColor(blue);
    trans3.addChild(lightS);

    Background background = new Background();
    background.setApplicationBounds(new BoundingSphere());
    background.setColor(1.0f, 1.0f, 1.0f);
    scene.addChild(background);

    scene.compile();
    System.out.print("bounds object: ");
    System.out.println(bounds);

    System.out.print("influencing bounds for lightA: ");
    System.out.println(lightA.getInfluencingBounds());

    System.out.print("influencing bounds for lightD: ");
    System.out.println(lightD.getInfluencingBounds());

    System.out.print("influencing bounds for lightP: ");
    System.out.println(lightP.getInfluencingBounds());

    System.out.print("influencing bounds for lightS: ");
    System.out.println(lightS.getInfluencingBounds());

    System.out.print("bounds for plane1: ");
    System.out.println(p1.getBounds());

    System.out.print("bounds for plane2: ");
    System.out.println(p2.getBounds());

    System.out.print("bounds for plane3: ");
    System.out.println(p3.getBounds());

    BoundingSphere bs0 = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 0.2);
    BoundingSphere bs1 = new BoundingSphere(new Point3d(-0.1, 0.0, 0.0), 0.2);
    BoundingSphere bs2 = new BoundingSphere(new Point3d(-0.2, 0.0, 0.0), 0.2);
    BoundingSphere bs3 = new BoundingSphere(new Point3d(-0.3, 0.0, 0.0), 0.2);
    BoundingSphere bs4 = new BoundingSphere(new Point3d(-0.4, 0.0, 0.0), 0.2);
    BoundingSphere bs5 = new BoundingSphere(new Point3d(-0.5, 0.0, 0.0), 0.2);
    BoundingSphere bs6 = new BoundingSphere(new Point3d(-0.6, 0.0, 0.0), 0.2);
    BoundingSphere bs7 = new BoundingSphere(new Point3d(-0.7, 0.0, 0.0), 0.2);
    BoundingSphere bs8 = new BoundingSphere(new Point3d(-0.8, 0.0, 0.0), 0.2);
    BoundingBox bb1 = new BoundingBox(bs1);
    BoundingBox bb2 = new BoundingBox(bs2);
    BoundingBox bb3 = new BoundingBox(bs3);
    BoundingBox bb4 = new BoundingBox(bs4);
    BoundingBox bb5 = new BoundingBox(bs5);
    BoundingBox bb6 = new BoundingBox(bs6);
    BoundingBox bb7 = new BoundingBox(bs7);
    BoundingBox bb8 = new BoundingBox(bs8);

    if (bs0.intersect(bs1))
        System.out.println("bs0 intersects bs1");
    if (bs0.intersect(bs2))
        System.out.println("bs0 intersects bs2");
    if (bs0.intersect(bs3))
        System.out.println("bs0 intersects bs3");
    if (bs0.intersect(bs4))
        System.out.println("bs0 intersects bs4");
    if (bs0.intersect(bs5))
        System.out.println("bs0 intersects bs5");
    if (bs0.intersect(bs6))
        System.out.println("bs0 intersects bs6");
    if (bs0.intersect(bs7))
        System.out.println("bs0 intersects bs7");
    if (bs0.intersect(bs8))
        System.out.println("bs0 intersects bs8");

    if (bs0.intersect(bb1))
        System.out.println("bs0 intersects bb1");
    if (bs0.intersect(bb2))
        System.out.println("bs0 intersects bb2");
    if (bs0.intersect(bb3))
        System.out.println("bs0 intersects bb3");
    if (bs0.intersect(bb4))
        System.out.println("bs0 intersects bb4");
    if (bs0.intersect(bb5))
        System.out.println("bs0 intersects bb5");
    if (bs0.intersect(bb6))
        System.out.println("bs0 intersects bb6");
    if (bs0.intersect(bb7))
        System.out.println("bs0 intersects bb7");
    if (bs0.intersect(bb8))
        System.out.println("bs0 intersects bb8");

    SimpleUniverse u = new SimpleUniverse(c);

    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();

    u.addBranchGraph(scene);
}

From source file:TickTockPicking.java

private Group createObject(Appearance app, double scale, double xpos, double ypos) {

    // Create a transform group node to scale and position the object.
    Transform3D t = new Transform3D();
    t.set(scale, new Vector3d(xpos, ypos, 0.0));
    TransformGroup objTrans = new TransformGroup(t);

    // Create a second transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime.
    TransformGroup spinTg = new TransformGroup();
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // Create a simple shape leaf node and set the appearance
    Shape3D shape = new Tetrahedron();
    shape.setAppearance(app);/*from  w w w . ja v  a2s .  c  o m*/
    shape.setCapability(shape.ALLOW_APPEARANCE_READ);
    shape.setCapability(shape.ALLOW_APPEARANCE_WRITE);

    // add it to the scene graph.
    spinTg.addChild(shape);

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 5000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, spinTg, yAxis, 0.0f,
            (float) Math.PI * 2.0f);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    rotator.setSchedulingBounds(bounds);

    // Add the behavior and the transform group to the object
    objTrans.addChild(rotator);
    objTrans.addChild(spinTg);

    return objTrans;
}

From source file:TickTockPicking.java

public BranchGroup createSceneGraph(Canvas3D c) {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // Create a Transformgroup to scale all objects so they
    // appear in the scene.
    TransformGroup objScale = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(0.4);/*  w w w.ja  v  a2  s .  c  o m*/
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);

    // Create a bounds for the background and behaviors
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // Set up the background
    Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
    Background bg = new Background(bgColor);
    bg.setApplicationBounds(bounds);
    objScale.addChild(bg);

    // Set up the global lights
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
    Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);

    AmbientLight aLgt = new AmbientLight(alColor);
    aLgt.setInfluencingBounds(bounds);
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
    lgt1.setInfluencingBounds(bounds);
    objScale.addChild(aLgt);
    objScale.addChild(lgt1);

    // Create a pair of transform group nodes and initialize them to
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behaviors can modify them at runtime. Add them to the
    // root of the subgraph.
    TransformGroup objTrans1 = new TransformGroup();
    objTrans1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objScale.addChild(objTrans1);

    TransformGroup objTrans2 = new TransformGroup();
    objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans1.addChild(objTrans2);

    // Create the positioning and scaling transform group node.
    Transform3D t = new Transform3D();
    t.set(0.3, new Vector3d(0.0, -1.5, 0.0));
    TransformGroup objTrans3 = new TransformGroup(t);
    objTrans2.addChild(objTrans3);

    // Create a simple shape leaf node, set it's appearance, and
    // add it to the scene graph.
    Shape3D shape = new Cube();
    Appearance a = new Appearance();
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f objColor = new Color3f(0.8f, 0.0f, 0.0f);
    a.setMaterial(new Material(objColor, black, objColor, white, 80.0f));
    shape.setAppearance(a);
    shape.setCapability(shape.ALLOW_APPEARANCE_READ);
    shape.setCapability(shape.ALLOW_APPEARANCE_WRITE);
    objTrans3.addChild(shape);

    // Create a new Behavior object that will perform the desired
    // rotation on the specified transform object and add it into
    // the scene graph.
    Transform3D yAxis1 = new Transform3D();
    yAxis1.rotX(Math.PI / 2.0);
    Alpha tickTockAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 5000, 2500,
            200, 5000, 2500, 200);

    RotationInterpolator tickTock = new RotationInterpolator(tickTockAlpha, objTrans1, yAxis1,
            -(float) Math.PI / 2.0f, (float) Math.PI / 2.0f);
    tickTock.setSchedulingBounds(bounds);
    objTrans2.addChild(tickTock);

    // Create a new Behavior object that will perform the desired
    // rotation on the specified transform object and add it into
    // the scene graph.
    Transform3D yAxis2 = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans2, yAxis2, 0.0f,
            (float) Math.PI * 2.0f);
    rotator.setSchedulingBounds(bounds);
    objTrans2.addChild(rotator);

    // Now create the simple picking behavior
    PickHighlightBehavior pickBeh = new PickHighlightBehavior(c, objRoot, bounds);

    // Create a bunch of objects with a behavior and add them
    // into the scene graph.

    int row, col;
    Appearance[][] app = new Appearance[3][3];

    for (row = 0; row < 3; row++)
        for (col = 0; col < 3; col++)
            app[row][col] = createAppearance(row * 3 + col);

    for (int i = 0; i < 3; i++) {
        double ypos = (double) (i - 1) * 1.5;
        for (int j = 0; j < 3; j++) {
            double xpos = (double) (j - 1) * 1.5;
            objScale.addChild(createObject(app[i][j], 0.3, xpos, ypos));
        }
    }

    // Have Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
}

From source file:ffx.potential.MolecularAssembly.java

/**
 * <p>//w w w  . ja  v a2s  .  com
 * createBox</p>
 */
public void createBox() {
    int vertices = 8;
    LineArray la = new LineArray(4 * vertices,
            GeometryArray.COORDINATES | GeometryArray.COLOR_4 | GeometryArray.NORMALS);
    la.setCapability(LineArray.ALLOW_COORDINATE_WRITE);
    la.setCapability(LineArray.ALLOW_COORDINATE_READ);
    la.setCapability(LineArray.ALLOW_COLOR_WRITE);
    la.setCapability(LineArray.ALLOW_COUNT_READ);
    la.setCapability(LineArray.ALLOW_INTERSECT);
    la.setCapability(LineArray.ALLOW_FORMAT_READ);
    // Create a normal
    // for (ListIterator li = bondlist.listIterator(); li.hasNext(); ){
    // la.setCoordinate(i, a1);
    // la.setColor(i, col);
    // la.setNormal(i++, a1);
    // }
    ColoringAttributes cola = new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_GOURAUD);
    Appearance app = new Appearance();
    lineAttributes = new LineAttributes();
    lineAttributes.setLineWidth(RendererCache.bondwidth);
    lineAttributes.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttributes.setLineAntialiasingEnable(true);
    app.setLineAttributes(lineAttributes);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    RenderingAttributes ra = new RenderingAttributes();
    ra.setAlphaTestValue(0.1f);
    ra.setAlphaTestFunction(RenderingAttributes.GREATER);
    ra.setDepthBufferEnable(true);
    ra.setDepthBufferWriteEnable(true);
    app.setRenderingAttributes(ra);
    app.setColoringAttributes(cola);
    Shape3D wireframe = new Shape3D(la, app);
    // PickTool.setCapabilities(wire, PickTool.INTERSECT_COORD);
    wireframe.setUserData(this);
    wireframe.setBounds(new BoundingSphere(new Point3d(0, 0, 0), 10.0));
    try {
        wireframe.setBoundsAutoCompute(false);
    } catch (Exception e) {
        e.printStackTrace();
    }
    wireframe.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    wireframe.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    // return wire;
}

From source file:ffx.potential.MolecularAssembly.java

private Shape3D renderWire() {
    ArrayList<ROLS> bonds = getBondList();
    int numbonds = bonds.size();
    if (numbonds < 1) {
        return null;
    }// w  ww.  j  a v  a 2  s. co  m

    Vector3d bondmidpoint = new Vector3d();
    double[] mid = { 0, 0, 0 };
    Vector3d v1 = new Vector3d();
    Vector3d v2 = new Vector3d();
    float[] a1 = { 0, 0, 0 };
    float[] a2 = { 0, 0, 0 };
    float[] col = new float[4];
    Bond bond;

    Atom atom1, atom2;
    LineArray la = new LineArray(4 * numbonds,
            GeometryArray.COORDINATES | GeometryArray.COLOR_4 | GeometryArray.NORMALS);
    la.setCapability(LineArray.ALLOW_COORDINATE_WRITE);
    la.setCapability(LineArray.ALLOW_COORDINATE_READ);
    la.setCapability(LineArray.ALLOW_COLOR_WRITE);
    la.setCapability(LineArray.ALLOW_COUNT_READ);
    la.setCapability(LineArray.ALLOW_INTERSECT);
    la.setCapability(LineArray.ALLOW_FORMAT_READ);
    atomLookUp = new Atom[4 * numbonds];
    int i = 0;
    col[3] = 0.9f;
    for (ListIterator li = bonds.listIterator(); li.hasNext();) {
        bond = (Bond) li.next();
        bond.setWire(la, i);
        atom1 = bond.getAtom(0);
        atom2 = bond.getAtom(1);
        atom1.getV3D(v1);
        atom2.getV3D(v2);
        a1[0] = (float) v1.x;
        a1[1] = (float) v1.y;
        a1[2] = (float) v1.z;
        a2[0] = (float) v2.x;
        a2[1] = (float) v2.y;
        a2[2] = (float) v2.z;
        // Find the bond center
        bondmidpoint.add(v1, v2);
        bondmidpoint.scale(0.5d);
        bondmidpoint.get(mid);
        // Atom #1
        Atom.AtomColor.get(atom1.getAtomicNumber()).get(col);
        atomLookUp[i] = atom1;
        la.setCoordinate(i, a1);
        la.setColor(i, col);
        la.setNormal(i, a2);
        i++;

        atomLookUp[i] = atom1;
        la.setCoordinate(i, mid);
        la.setColor(i, col);
        la.setNormal(i, a2);
        i++;
        // Atom #2

        Atom.AtomColor.get(atom2.getAtomicNumber()).get(col);
        atomLookUp[i] = atom2;
        la.setCoordinate(i, a2);
        la.setColor(i, col);
        la.setNormal(i, a1);
        i++;

        atomLookUp[i] = atom2;
        la.setCoordinate(i, mid);
        la.setColor(i, col);
        la.setNormal(i, a1);
        i++;

    }

    ColoringAttributes cola = new ColoringAttributes(new Color3f(), ColoringAttributes.SHADE_GOURAUD);
    Appearance app = new Appearance();
    lineAttributes = new LineAttributes();
    lineAttributes.setLineWidth(RendererCache.bondwidth);
    lineAttributes.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttributes.setLineAntialiasingEnable(true);
    app.setLineAttributes(lineAttributes);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_READ);
    app.setCapability(Appearance.ALLOW_LINE_ATTRIBUTES_WRITE);
    RenderingAttributes ra = new RenderingAttributes();
    ra.setAlphaTestValue(0.1f);
    ra.setAlphaTestFunction(RenderingAttributes.GREATER);
    ra.setDepthBufferEnable(true);
    ra.setDepthBufferWriteEnable(true);
    app.setRenderingAttributes(ra);
    app.setColoringAttributes(cola);
    Shape3D wireframe = new Shape3D(la, app);
    // PickTool.setCapabilities(wire, PickTool.INTERSECT_COORD);
    wireframe.setUserData(this);
    wireframe.setBounds(new BoundingSphere(new Point3d(0, 0, 0), 1000.0));
    try {
        wireframe.setBoundsAutoCompute(false);
    } catch (Exception e) {
        e.printStackTrace();
    }

    wireframe.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
    wireframe.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
    wireframe.setCapability(Shape3D.ALLOW_LOCAL_TO_VWORLD_READ);
    return wireframe;
}

From source file:PickTest.java

private Group createObject(int index, double scale, double xpos, double ypos) {

    Shape3D shape = null;
    Geometry geom = null;/*from  ww  w  . jav  a2s.  c  om*/

    // Create a transform group node to scale and position the object.
    Transform3D t = new Transform3D();
    t.set(scale, new Vector3d(xpos, ypos, 0.0));
    TransformGroup objTrans = new TransformGroup(t);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING);

    // Create a second transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime.
    TransformGroup spinTg = new TransformGroup();
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    spinTg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);

    Appearance appearance = new Appearance();

    switch (index) {
    case 0:
        geom = new GullCG();
        break;
    case 1:
        geom = new TetrahedronTA();
        break;
    case 2:
        geom = new OctahedronTFA();
        break;
    case 3:
        geom = new IcosahedronTSA();
        break;
    case 4:
        geom = new CubeIQA();
        break;
    case 5:
        geom = new TetrahedronITA();
        break;
    case 6:
        geom = new OctahedronITFA();
        break;
    case 7:
        geom = new IcosahedronITSA();
        break;
    case 8:
        geomMorph[0] = new ColorPyramidUp();
        geomMorph[1] = new ColorCube();
        geomMorph[2] = new ColorPyramidDown();
        break;
    case 9:
        geom = new TetrahedronLA();
        break;
    case 10:
        geom = new TetrahedronILA();
        break;
    case 11:
        geom = new TetrahedronLSA();
        break;
    case 12:
        geom = new TetrahedronILSA();
        break;
    case 13:
        geom = new TetrahedronPA();
        break;
    case 14:
        geom = new TetrahedronIPA();
        break;
    // TODO: other geo types, Text3D?
    case 15:
        geom = new TetrahedronTA();
        break;
    }

    Material m = new Material();

    if (index == 8) {
        m.setLightingEnable(false);
        appearance.setMaterial(m);
        morph = new Morph((GeometryArray[]) geomMorph, appearance);
        morph.setCapability(Morph.ALLOW_WEIGHTS_READ);
        morph.setCapability(Morph.ALLOW_WEIGHTS_WRITE);
        PickTool.setCapabilities(morph, PickTool.INTERSECT_FULL);
        spinTg.addChild(morph);
    } else {
        // Geometry picking require this to be set.
        if (index == 0)
            m.setLightingEnable(true);
        else
            m.setLightingEnable(false);
        appearance.setMaterial(m);

        if ((index == 13) || (index == 14)) {
            PointAttributes pa = new PointAttributes();
            pa.setPointSize(4.0f);
            appearance.setPointAttributes(pa);
        }

        shape = new Shape3D(geom, appearance);
        shape.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
        shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
        shape.setCapability(Shape3D.ENABLE_PICK_REPORTING);
        PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
        spinTg.addChild(shape);
    }

    // add it to the scene graph.
    objTrans.addChild(spinTg);

    return objTrans;
}