Example usage for javax.media.j3d Shape3D Shape3D

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

Introduction

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

Prototype

public Shape3D(Geometry geometry, Appearance appearance) 

Source Link

Document

Constructs and initializes a Shape3D node with the specified geometry and appearance components.

Usage

From source file:FarbWurfelAsQuads.java

/**
 * Erstellt den Szenegraphen/*from  w  w w .ja va2 s .  c o m*/
 * 
 * @return BranchGroup
 */
public BranchGroup macheSzene() {
    BranchGroup objWurzel = new BranchGroup();
    // Transformation, 2 Rotationen:
    Transform3D drehung = new Transform3D();
    Transform3D drehung2 = new Transform3D();
    drehung.rotX(Math.PI / 4.0d);
    drehung2.rotY(Math.PI / 5.0d);
    drehung.mul(drehung2);
    drehung.setScale(0.5d);
    TransformGroup objDreh = new TransformGroup(drehung);
    Shape3D shape = new Shape3D(makeCube(), makeAppearance());
    objDreh.addChild(shape);

    objWurzel.addChild(objDreh);
    return objWurzel;
}

From source file:BoundsTest.java

protected Group createPoints() {
    Group group = new Group();

    final int kNumPoints = 200;
    final double kRadius = 10.0;
    Point3d points[] = new Point3d[kNumPoints];

    for (int n = 0; n < kNumPoints; n++) {
        double randX = (java.lang.Math.random() * kRadius) - kRadius / 2;
        double randY = (java.lang.Math.random() * kRadius) - kRadius / 2;
        double randZ = (java.lang.Math.random() * kRadius) - kRadius / 2;

        points[n] = new Point3d(randX, randY, randZ);
    }/*www  . j  a  v  a 2 s.  c o m*/

    PointArray pointArray = new PointArray(points.length, GeometryArray.COLOR_4 | GeometryArray.COORDINATES);
    pointArray.setCoordinates(0, points);
    Shape3D shapePoints = new Shape3D(pointArray, new Appearance());

    group.addChild(shapePoints);
    return group;
}

From source file:BillboardTest.java

private TransformGroup createBillboard(String szText, Point3f locationPoint, int nMode, Point3f billboardPoint,
        BoundingSphere bounds) {//  w  w  w  .java2s.  c om
    TransformGroup subTg = new TransformGroup();
    subTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    Font3D f3d = new Font3D(new Font("SansSerif", Font.PLAIN, 10), new FontExtrusion());
    Text3D label3D = new Text3D(f3d, szText, locationPoint);

    Appearance app = new Appearance();

    Color3f black = new Color3f(0.1f, 0.1f, 0.1f);
    Color3f objColor = new Color3f(0.2f, 0.2f, 0.2f);

    app.setMaterial(new Material(objColor, black, objColor, black, 90.0f));
    Shape3D sh = new Shape3D(label3D, app);

    subTg.addChild(sh);

    Billboard billboard = new Billboard(subTg, nMode, billboardPoint);
    billboard.setSchedulingBounds(bounds);
    subTg.addChild(billboard);

    return subTg;
}

From source file:SimpleWorld.java

/**
 * This constructs a cube as an array of quadrilateral polygons. There are
 * six faces, each with four vertices (obviously!). The cube extends 1 unit
 * along each axis in the positive and negavtive directions and is centred
 * on the origin./* w  ww  .  j a v  a  2  s.  c  om*/
 * 
 * @return Shape3D that is the cube
 */
protected Shape3D buildCube() {
    //Create the array of numbers that will form the
    //vertex information.
    float[] cubeFaces = { 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f,
            -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f,
            1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f,
            1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f,
            1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f };

    //Create the array of quadrilaterals from the vertices
    QuadArray cubeData = new QuadArray(24, QuadArray.COORDINATES);
    cubeData.setCoordinates(0, cubeFaces);

    //Create a default appearance
    Appearance app = new Appearance();

    //Create and return the cube
    return new Shape3D(cubeData, app);
}

From source file:LineTypes.java

Group createLineTypes() {

    Group lineGroup = new Group();

    Appearance app = new Appearance();
    ColoringAttributes ca = new ColoringAttributes(black, ColoringAttributes.SHADE_FLAT);
    app.setColoringAttributes(ca);//from  ww w  .j  a  v  a  2 s.c  om

    // Plain line
    Point3f[] plaPts = new Point3f[2];
    plaPts[0] = new Point3f(-0.9f, -0.7f, 0.0f);
    plaPts[1] = new Point3f(-0.5f, 0.7f, 0.0f);
    LineArray pla = new LineArray(2, LineArray.COORDINATES);
    pla.setCoordinates(0, plaPts);
    Shape3D plShape = new Shape3D(pla, app);
    lineGroup.addChild(plShape);

    // line pattern dot
    Point3f[] dotPts = new Point3f[2];
    dotPts[0] = new Point3f(-0.4f, -0.7f, 0.0f);
    dotPts[1] = new Point3f(-0.0f, 0.7f, 0.0f);
    LineArray dot = new LineArray(2, LineArray.COORDINATES);
    dot.setCoordinates(0, dotPts);
    LineAttributes dotLa = new LineAttributes();
    dotLa.setLineWidth(2.0f);
    dotLa.setLinePattern(LineAttributes.PATTERN_DOT);
    Appearance dotApp = new Appearance();
    dotApp.setLineAttributes(dotLa);
    dotApp.setColoringAttributes(ca);
    Shape3D dotShape = new Shape3D(dot, dotApp);
    lineGroup.addChild(dotShape);

    // line pattern dash
    Point3f[] dashPts = new Point3f[2];
    dashPts[0] = new Point3f(-0.0f, -0.7f, 0.0f);
    dashPts[1] = new Point3f(0.4f, 0.7f, 0.0f);
    LineArray dash = new LineArray(2, LineArray.COORDINATES);
    dash.setCoordinates(0, dashPts);
    LineAttributes dashLa = new LineAttributes();
    dashLa.setLineWidth(4.0f);
    dashLa.setLinePattern(LineAttributes.PATTERN_DASH);
    Appearance dashApp = new Appearance();
    dashApp.setLineAttributes(dashLa);
    dashApp.setColoringAttributes(ca);
    Shape3D dashShape = new Shape3D(dash, dashApp);
    lineGroup.addChild(dashShape);

    // line pattern dot-dash
    Point3f[] dotDashPts = new Point3f[2];
    dotDashPts[0] = new Point3f(0.5f, -0.7f, 0.0f);
    dotDashPts[1] = new Point3f(0.9f, 0.7f, 0.0f);
    LineArray dotDash = new LineArray(2, LineArray.COORDINATES);
    dotDash.setCoordinates(0, dotDashPts);
    LineAttributes dotDashLa = new LineAttributes();
    dotDashLa.setLineWidth(4.0f);
    dotDashLa.setLinePattern(LineAttributes.PATTERN_DASH_DOT);
    Appearance dotDashApp = new Appearance();
    dotDashApp.setLineAttributes(dotDashLa);
    dotDashApp.setColoringAttributes(ca);
    Shape3D dotDashShape = new Shape3D(dotDash, dotDashApp);
    lineGroup.addChild(dotDashShape);

    return lineGroup;

}

From source file:Pyramid2Cube.java

private BranchGroup createSceneGraph() {
    // 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);/*  ww w .j a va2s  . com*/
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);

    // Create a bounds for the background and behavior
    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);

    //
    // Create the transform group nodes for the 3 original objects
    // and the morphed object. Add them to the root of the
    // branch graph.
    //
    TransformGroup objTrans[] = new TransformGroup[4];

    for (int i = 0; i < 4; i++) {
        objTrans[i] = new TransformGroup();
        objScale.addChild(objTrans[i]);
    }

    Transform3D tr = new Transform3D();
    Transform3D rotY15 = new Transform3D();
    rotY15.rotY(15.0 * Math.PI / 180.0);

    objTrans[0].getTransform(tr);
    tr.setTranslation(new Vector3d(-3.0, 1.5, -6.5));
    tr.mul(rotY15);
    objTrans[0].setTransform(tr);

    objTrans[1].getTransform(tr);
    tr.setTranslation(new Vector3d(0.0, 1.5, -6.5));
    tr.mul(rotY15);
    objTrans[1].setTransform(tr);

    objTrans[2].getTransform(tr);
    tr.setTranslation(new Vector3d(3.0, 1.5, -6.5));
    tr.mul(rotY15);
    objTrans[2].setTransform(tr);

    objTrans[3].getTransform(tr);
    tr.setTranslation(new Vector3d(0.0, -2.0, -5.0));
    tr.mul(rotY15);
    objTrans[3].setTransform(tr);

    // Now create simple geometries.

    QuadArray g[] = new QuadArray[3];
    Shape3D shape[] = new Shape3D[3];
    for (int i = 0; i < 3; i++) {
        g[i] = null;
        shape[i] = null;
    }

    g[0] = new ColorPyramidUp();
    g[1] = new ColorCube();
    g[2] = new ColorPyramidDown();

    Appearance a = new Appearance();

    for (int i = 0; i < 3; i++) {
        shape[i] = new Shape3D(g[i], a);
        objTrans[i].addChild(shape[i]);
    }

    //
    // Create a Morph node, and set the appearance and input geometry
    // arrays. Set the Morph node's capability bits to allow the weights
    // to be modified at runtime.
    //
    Morph morph = new Morph((GeometryArray[]) g, a);
    morph.setCapability(Morph.ALLOW_WEIGHTS_READ);
    morph.setCapability(Morph.ALLOW_WEIGHTS_WRITE);

    objTrans[3].addChild(morph);

    // Now create the Alpha object that controls the speed of the
    // morphing operation.
    Alpha morphAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 4000, 1000, 500,
            4000, 1000, 500);

    // Finally, create the morphing behavior
    MorphingBehavior mBeh = new MorphingBehavior(morphAlpha, morph);
    mBeh.setSchedulingBounds(bounds);
    objScale.addChild(mBeh);

    return objRoot;
}

From source file:RedGreenGriffin.java

public BranchGroup createSceneGraph(int i) {
    System.out.println("Creating scene for: " + URLString);
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();
    try {/* w w  w.ja  v  a  2 s.  c o m*/
        Transform3D myTransform3D = new Transform3D();
        myTransform3D.setTranslation(new Vector3f(+0.0f, -0.15f, -3.6f));
        TransformGroup objTrans = new TransformGroup(myTransform3D);
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        Transform3D t = new Transform3D();
        TransformGroup tg = new TransformGroup(t);
        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objTrans.addChild(tg);
        URL url = new URL(URLString);
        ObjectFile f = new ObjectFile();
        f.setFlags(ObjectFile.RESIZE | ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY);
        System.out.println("About to load");

        Scene s = f.load(url);
        Transform3D myTrans = new Transform3D();
        myTrans.setTranslation(new Vector3f(eyeOffset, -eyeOffset, 0F));
        TransformGroup mytg = new TransformGroup(myTrans);
        //mytg.addChild(s.getSceneGroup());
        tg.addChild(mytg);
        Transform3D myTrans2 = new Transform3D();
        myTrans2.setTranslation(new Vector3f(-eyeOffset, +eyeOffset, 0F));
        TransformGroup mytg2 = new TransformGroup(myTrans2);
        //mytg2.addChild(s.getSceneGroup());
        Hashtable table = s.getNamedObjects();
        for (Enumeration e = table.keys(); e.hasMoreElements();) {
            Object key = e.nextElement();
            System.out.println(key);
            Object obj = table.get(key);
            System.out.println(obj.getClass().getName());
            Shape3D shape = (Shape3D) obj;
            //shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
            Appearance ap = new Appearance();
            Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
            Color3f red = new Color3f(0.7f, .0f, .15f);
            Color3f green = new Color3f(0f, .7f, .15f);
            ap.setMaterial(new Material(green, black, green, black, 1.0f));
            Appearance ap2 = new Appearance();
            ap2.setMaterial(new Material(red, black, red, black, 1.0f));
            float transparencyValue = 0.5f;
            TransparencyAttributes t_attr = new TransparencyAttributes(TransparencyAttributes.BLENDED,
                    transparencyValue, TransparencyAttributes.BLEND_SRC_ALPHA,
                    TransparencyAttributes.BLEND_ONE);
            ap2.setTransparencyAttributes(t_attr);
            ap2.setRenderingAttributes(new RenderingAttributes());
            ap.setTransparencyAttributes(t_attr);
            ap.setRenderingAttributes(new RenderingAttributes());
            // bg.addChild(ap);
            shape.setAppearance(ap);
            mytg2.addChild(new Shape3D(shape.getGeometry(), ap2));
            mytg.addChild(new Shape3D(shape.getGeometry(), ap));
        }
        tg.addChild(mytg2);
        System.out.println("Finished Loading");
        BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
        Color3f light1Color = new Color3f(.9f, 0.9f, 0.9f);
        Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
        DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
        light1.setInfluencingBounds(bounds);
        objTrans.addChild(light1);
        // Set up the ambient light
        Color3f ambientColor = new Color3f(1.0f, .4f, 0.3f);
        AmbientLight ambientLightNode = new AmbientLight(ambientColor);
        ambientLightNode.setInfluencingBounds(bounds);
        objTrans.addChild(ambientLightNode);

        MouseRotate behavior = new MouseRotate();
        behavior.setTransformGroup(tg);
        objTrans.addChild(behavior);
        // Create the translate behavior node
        MouseTranslate behavior3 = new MouseTranslate();
        behavior3.setTransformGroup(tg);
        objTrans.addChild(behavior3);
        behavior3.setSchedulingBounds(bounds);

        KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(tg);
        keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0));
        objTrans.addChild(keyNavBeh);

        behavior.setSchedulingBounds(bounds);
        objRoot.addChild(objTrans);
    } catch (Throwable t) {
        System.out.println("Error: " + t);
    }
    return objRoot;
}

From source file:TriangulatorTest.java

protected BranchGroup createSceneBranchGroup() {
    BranchGroup objRoot = super.createSceneBranchGroup();

    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, 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);

    objTrans.addChild(rotator);//  w w  w  .  ja  v  a 2 s .co  m

    // triangulate the polygon
    GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);

    gi.setCoordinates(m_VertexArray);

    int[] stripCountArray = { 10, 5 };
    int[] countourCountArray = { stripCountArray.length };

    gi.setContourCounts(countourCountArray);
    gi.setStripCounts(stripCountArray);

    Triangulator triangulator = new Triangulator();
    triangulator.triangulate(gi);

    NormalGenerator normalGenerator = new NormalGenerator();
    normalGenerator.generateNormals(gi);

    // create an appearance
    Appearance ap = new Appearance();

    // render as a wireframe
    PolygonAttributes polyAttrbutes = new PolygonAttributes();
    polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
    ap.setPolygonAttributes(polyAttrbutes);

    // add both a wireframe and a solid version
    // of the triangulated surface
    Shape3D shape1 = new Shape3D(gi.getGeometryArray(), ap);
    Shape3D shape2 = new Shape3D(gi.getGeometryArray());

    objTrans.addChild(shape1);
    objTrans.addChild(shape2);
    objRoot.addChild(objTrans);

    return objRoot;
}

From source file:Text3DTest.java

TransformGroup createText3D(TornadoRotation rotator, String szText, int nSize, float scale, float trans,
        int nPath) {
    TransformGroup tg = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(scale);/*from   ww  w . ja va 2s  . c o m*/
    t3d.setTranslation(new Vector3d(0.0, trans, -10.0));
    tg.setTransform(t3d);

    // use a customized FontExtrusion object to control the depth of the
    // text
    double X1 = 0;
    double Y1 = 0;
    double X2 = 3;
    double Y2 = 0;
    Shape extrusionShape = new java.awt.geom.Line2D.Double(X1, Y1, X2, Y2);

    FontExtrusion fontEx = new FontExtrusion(extrusionShape);

    Font3D f3d = new Font3D(new Font("TimesRoman", Font.PLAIN, nSize), fontEx);

    TornadoText3D text3D = new TornadoText3D(f3d, szText, new Point3f(0.0f, 0.0f, 0.0f), Text3D.ALIGN_CENTER,
            nPath);

    rotator.addTornadoText3D(text3D);

    // create an appearance
    Color3f black = new Color3f(0.1f, 0.1f, 0.1f);
    Color3f objColor = new Color3f(0.2f, 0.2f, 0.2f);

    Appearance app = new Appearance();
    app.setMaterial(new Material(objColor, black, objColor, black, 90.0f));

    // render as a wireframe
    PolygonAttributes polyAttrbutes = new PolygonAttributes();
    polyAttrbutes.setPolygonMode(PolygonAttributes.POLYGON_LINE);
    polyAttrbutes.setCullFace(PolygonAttributes.CULL_NONE);
    app.setPolygonAttributes(polyAttrbutes);

    tg.addChild(new Shape3D(text3D, app));
    return tg;
}

From source file:SpotLightApp.java

public SpotLightApp() {
    BoundingSphere bound1 = new BoundingSphere(new Point3d(0.0, 0.9, 0.0), 0.5);
    BoundingSphere bound2 = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 0.5);
    BoundingSphere bound3 = new BoundingSphere(new Point3d(0.0, -0.9, 0.0), 0.5);

    Vector3f direction = new Vector3f(0.0f, 0.0f, -1.0f);

    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();

    final int X = 101, Y = 102;
    final float dx = 0.01f, dy = -0.01f;
    final float epx = dx / 2.0f, epy = dy / 2.0f;
    final float top = 0.5f, left = -0.5f;
    final float right = left + dx * (X - 1);
    final float bottom = top + dy * (Y - 1);

    IndexedQuadArray qa = new IndexedQuadArray(X * Y, QuadArray.COORDINATES | QuadArray.NORMALS,
            (X - 1) * (Y - 1) * 4);//from   w  w w. ja  v  a  2 s .  co m

    float x, y;
    int i = 0;
    System.out.print("set " + X * Y + " coordiantes.....  ");
    for (y = top; y >= bottom - epx; y += dy)
        for (x = left; x <= right + epx; x += dx)
            qa.setCoordinate(i++, new Point3f(x, y, 0.0f));

    System.out.println(i + " coordiantes done");
    int row, col;
    i = 0;
    Vector3f n = new Vector3f(0.0f, 0.0f, 1.0f);

    System.out.print("set " + (X - 1) * (Y - 1) * 4 + " coordinate indices.....  ");
    for (row = 0; row < (Y - 1); row++) {
        for (col = 0; col < (X - 1); col++) {
            qa.setNormal(row * X + col, n);
            qa.setCoordinateIndex(i++, row * X + col);
            qa.setCoordinateIndex(i++, (row + 1) * X + col);
            qa.setCoordinateIndex(i++, (row + 1) * X + col + 1);
            qa.setCoordinateIndex(i++, row * X + col + 1);
        }
        qa.setNormal(row * X + col + 1, n);
    }
    System.out.println(i + " coordinate indices done");

    for (col = 0; col < (X - 1); col++) {
        qa.setNormal(X * (Y - 1) + 1 + col, n);
    }
    System.out.println("coordinate normals done");

    Appearance qAppear = createMatAppear(blue, white, 5.0f);
    Shape3D plane = new Shape3D(qa, qAppear);

    Transform3D translate = new Transform3D();
    translate.set(new Vector3f(-0.5f, 0.5f, 0.0f));
    TransformGroup tg1 = new TransformGroup(translate);
    scene.addChild(tg1);
    Shape3D plane1 = new Shape3D(qa, qAppear);
    plane1.setBounds(bound1);
    tg1.addChild(plane1);

    translate.set(new Vector3f(0.5f, 0.5f, 0.0f));
    TransformGroup tg2 = new TransformGroup(translate);
    scene.addChild(tg2);
    Shape3D plane2 = new Shape3D(qa, qAppear);
    plane2.setBounds(bound1);
    tg2.addChild(plane2);

    translate.set(new Vector3f(-0.5f, -0.5f, 0.0f));
    TransformGroup tg3 = new TransformGroup(translate);
    scene.addChild(tg3);
    Shape3D plane3 = new Shape3D(qa, qAppear);
    plane3.setBounds(bound3);
    tg3.addChild(plane3);

    translate.set(new Vector3f(0.5f, -0.5f, 0.0f));
    TransformGroup tg4 = new TransformGroup(translate);
    scene.addChild(tg4);
    Shape3D plane4 = new Shape3D(qa, qAppear);
    plane4.setBounds(bound3);
    tg4.addChild(plane4);

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

    scene.addChild(newSpotLight(bound1, new Point3f(-0.7f, 0.7f, 0.5f), 0.1f, 5.0f));
    scene.addChild(newSpotLight(bound1, new Point3f(0.0f, 0.7f, 0.5f), 0.1f, 50.0f));
    scene.addChild(newSpotLight(bound1, new Point3f(0.7f, 0.7f, 0.5f), 0.1f, 100.0f));
    scene.addChild(newSpotLight(bound2, new Point3f(-0.7f, 0.0f, 0.5f), 0.3f, 5.0f));
    scene.addChild(newSpotLight(bound2, new Point3f(0.0f, 0.0f, 0.5f), 0.3f, 50.0f));
    scene.addChild(newSpotLight(bound2, new Point3f(0.7f, 0.0f, 0.5f), 0.3f, 100.0f));
    scene.addChild(newSpotLight(bound3, new Point3f(-0.7f, -0.7f, 0.5f), 0.5f, 5.0f));
    scene.addChild(newSpotLight(bound3, new Point3f(0.0f, -0.7f, 0.5f), 0.5f, 50.0f));
    scene.addChild(newSpotLight(bound3, new Point3f(0.7f, -0.7f, 0.5f), 0.5f, 100.0f));

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

    scene.compile();

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

    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);
}