List of usage examples for javax.media.j3d Transform3D setScale
public final void setScale(Vector3d scale)
From source file:OrientedPtTest.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objScale = new TransformGroup(); Transform3D textMat = new Transform3D(); // Assuming uniform size chars, set scale to fit string in view textMat.setScale(1.2 / sl); objScale.setTransform(textMat);//from w w w.j av a 2 s . c om // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objTrans); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Appearance apText = new Appearance(); Material m = new Material(); m.setLightingEnable(true); apText.setMaterial(m); Appearance apEarth = new Appearance(); Material mm = new Material(); mm.setLightingEnable(true); apEarth.setMaterial(mm); Appearance apStone = new Appearance(); apStone.setMaterial(mm); // create 3D text Font3D f3d = new Font3D(new Font(fontName, Font.PLAIN, 2), new FontExtrusion()); Point3f textPt = new Point3f(-sl / 2.0f, 3.0f, 0.0f); Text3D txt = new Text3D(f3d, textString, textPt); OrientedShape3D textShape = new OrientedShape3D(); textShape.setGeometry(txt); textShape.setAppearance(apText); textShape.setAlignmentMode(OrientedShape3D.ROTATE_ABOUT_POINT); // text is centered around 0, 3, 0. Make it rotate around 0,5,0 Point3f rotationPt = new Point3f(0.0f, 5.0f, 0.0f); textShape.setRotationPoint(rotationPt); objScale.addChild(textShape); // also add a small Sphere at the rotation point to // show that we are rotating around the right point Sphere sphere = new Sphere(0.2f); TransformGroup sphereGroup = new TransformGroup(); Transform3D sphereXform = new Transform3D(); sphereXform.set(new Vector3f(rotationPt)); sphereGroup.setTransform(sphereXform); sphereGroup.addChild(sphere); objScale.addChild(sphereGroup); // Create a simple shape leaf node, add it to the scene graph. Transform3D cubeMat = new Transform3D(); TransformGroup cubeTrans = new TransformGroup(cubeMat); cubeMat.set(new Vector3d(0.9, 0.0, -1.0)); cubeTrans.setTransform(cubeMat); cubeTrans.addChild(new ColorCube(0.3)); objTrans.addChild(cubeTrans); TextureLoader stoneTex = new TextureLoader(stoneImage, new String("RGB"), this); if (stoneTex != null) apStone.setTexture(stoneTex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.REPLACE); apStone.setTextureAttributes(texAttr); Transform3D coneMat = new Transform3D(); TransformGroup coneTrans = new TransformGroup(coneMat); coneMat.set(new Vector3d(0.0, 0.0, 0.0)); coneTrans.setTransform(coneMat); coneTrans.addChild(new Cone(.2f, 0.8f, Cone.GENERATE_NORMALS | Cone.GENERATE_TEXTURE_COORDS, apStone)); objTrans.addChild(coneTrans); TextureLoader earthTex = new TextureLoader(earthImage, new String("RGB"), this); if (earthTex != null) apEarth.setTexture(earthTex.getTexture()); apEarth.setTextureAttributes(texAttr); Transform3D cylinderMat = new Transform3D(); TransformGroup cylinderTrans = new TransformGroup(cylinderMat); cylinderMat.set(new Vector3d(-0.9, 0.5, -1.0)); cylinderTrans.setTransform(cylinderMat); cylinderTrans.addChild( new Cylinder(.35f, 2.0f, Cylinder.GENERATE_NORMALS | Cylinder.GENERATE_TEXTURE_COORDS, apEarth)); objTrans.addChild(cylinderTrans); objTrans.addChild(objScale); // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objRoot.addChild(bgNode); // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objRoot.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); objRoot.addChild(light2); apText.setMaterial(mm); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:cgview.java
public BranchGroup createSceneGraph(CompressedGeometry cg) { // 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.7); objScale.setTransform(t3d);/* ww w . ja v a 2s . c o m*/ objRoot.addChild(objScale); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objScale.addChild(objTrans); // Add compressed geometry to the scene graph. CompressedGeometryHeader hdr = new CompressedGeometryHeader(); cg.getCompressedGeometryHeader(hdr); // There isn't really enough information in the compressed geometry // header to unamiguously determine the proper rendering attributes. // The bufferDataPresent field specifies whether or not normals are // bundled with vertices, but the compressed buffer can still contain // normals that should be lit. Assume that any surface geometry // should be lit and that lines and points should not unless the // header contains the NORMAL_IN_BUFFER bit. Material m = new Material(); if ((hdr.bufferType == hdr.TRIANGLE_BUFFER) || ((hdr.bufferDataPresent & hdr.NORMAL_IN_BUFFER) == 1)) m.setLightingEnable(true); else m.setLightingEnable(false); Appearance a = new Appearance(); a.setMaterial(m); objTrans.addChild(new Shape3D(cg, a)); // Create mouse behavior scheduling bounds. 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.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objRoot.addChild(bgNode); // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objRoot.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -0.9f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); objRoot.addChild(light2); return objRoot; }
From source file:MixedTest.java
public TransformGroup[] getViewTransformGroupArray() { TransformGroup[] tgArray = new TransformGroup[1]; tgArray[0] = new TransformGroup(); // move the camera BACK a little... // note that we have to invert the matrix as // we are moving the viewer Transform3D t3d = new Transform3D(); t3d.setScale(getScale()); t3d.setTranslation(new Vector3d(0.0, 0.0, -20.0)); t3d.invert();//from w w w . ja v a 2 s .c o m tgArray[0].setTransform(t3d); return tgArray; }
From source file:MultiView.java
public TransformGroup[] getViewTransformGroupArray() { // increment the view count m_nNumViews++;// ww w .java2 s . com TransformGroup[] tgArray = new TransformGroup[1]; tgArray[0] = new TransformGroup(); Vector3d vTrans = new Vector3d(0.0, 0.0, -20); // move the camera BACK so we can view the scene // also set the scale so that the more views we have // the smaller the scene will be scaled Transform3D t3d = new Transform3D(); t3d.setTranslation(vTrans); t3d.setScale(1.0 / m_nNumViews); t3d.invert(); tgArray[0].setTransform(t3d); return tgArray; }
From source file:SwitchTest.java
TransformGroup createLabel(String szText, double scale) { Color3f colorText = new Color3f(); int nFontSizeText = 10; Text2D label3D = new Text2D(szText, colorText, "SansSerif", nFontSizeText, Font.PLAIN); TransformGroup tg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(-8, 1.5 * (3 - m_nLabelNumber), 0)); t3d.setScale(scale); tg.setTransform(t3d);/*from w w w. j a v a 2s . com*/ tg.addChild(label3D); m_nLabelNumber++; return tg; }
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); t3d.setTranslation(new Vector3d(0.0, trans, -10.0)); tg.setTransform(t3d);/*from w w w . j av a 2 s . c o m*/ // 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:SwingTest.java
/** * Get the TransformGroup for the View side of the scenegraph *//*from w w w . j a v a2s . co m*/ public TransformGroup[] getViewTransformGroupArray() { TransformGroup[] tgArray = new TransformGroup[1]; tgArray[0] = new TransformGroup(); // move the camera BACK a little... // note that we have to invert the matrix as // we are moving the viewer Transform3D t3d = new Transform3D(); t3d.setScale(getScale()); t3d.setTranslation(new Vector3d(0.0, 0.0, -20.0)); t3d.invert(); tgArray[0].setTransform(t3d); return tgArray; }
From source file:edu.uci.ics.jung.visualization3d.VisualizationViewer.java
public BranchGroup createSceneGraph(final Canvas3D canvas) { objRoot = new BranchGroup(); objRoot.setCapability(Group.ALLOW_CHILDREN_EXTEND); objRoot.setCapability(Group.ALLOW_CHILDREN_WRITE); TransformGroup objScale = new TransformGroup(); Transform3D t3d = new Transform3D(); // t3d.setScale(0.05); objScale.setTransform(t3d);//from ww w.jav a 2 s .c o m objRoot.addChild(objScale); Transform3D tt = new Transform3D(); tt.setScale(.05); tt.setTranslation(new Vector3f(0, 0, -30.f)); objTrans = new TransformGroup(tt); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objTrans.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND); objScale.addChild(objTrans); // objRoot.addChild(objTrans); // Create Colors, Materials, and Appearances. Appearance look = new Appearance(); Color3f objColor = new Color3f(0.7f, 0.7f, 0.7f); Color3f black = new Color3f(0.f, 0.f, 0.f); Color3f white = new Color3f(1.0f, 1.0f, 0.6f); Color3f gray = new Color3f(.2f, .2f, .2f); Color3f red = new Color3f(1.0f, 0, 0); Color3f yellow = new Color3f(1, 1, 0); Material objMaterial = new Material(objColor, black, objColor, white, 100.0f); Material blackMaterial = new Material(objColor, black, black, objColor, 10.0f); Material whiteMaterial = new Material(white, white, white, white, 100.0f); Material grayMaterial = new Material(gray, black, gray, gray, 100.0f); Material redMaterial = new Material(red, black, red, red, 100.0f); Material yellowMaterial = new Material(yellow, black, yellow, yellow, 100); look.setMaterial(new Material(objColor, black, objColor, white, 100.0f)); Appearance blackLook = new Appearance(); blackLook.setMaterial(blackMaterial); Appearance whiteLook = new Appearance(); whiteLook.setMaterial(whiteMaterial); Appearance grayLook = new Appearance(); grayLook.setMaterial(grayMaterial); grayLook.setCapability(Appearance.ALLOW_MATERIAL_READ); grayLook.setCapability(Appearance.ALLOW_MATERIAL_WRITE); final Appearance redLook = new Appearance(); redLook.setMaterial(redMaterial); // vertexLook = redLook; Appearance objLook = new Appearance(); objLook.setMaterial(objMaterial); grayLook = objLook; final Appearance yellowLook = new Appearance(); yellowLook.setMaterial(yellowMaterial); Bounds bounds = new BoundingSphere(new Point3d(), 300); MouseRotate behavior1 = new MouseRotate(); behavior1.setTransformGroup(objTrans); objTrans.addChild(behavior1); behavior1.setSchedulingBounds(bounds); MouseWheelZoom behavior2 = new MouseWheelZoom(); behavior2.setTransformGroup(objTrans); // behavior2.setFactor(10); objTrans.addChild(behavior2); behavior2.setSchedulingBounds(bounds); MouseTranslate behavior3 = new MouseTranslate(); behavior3.setTransformGroup(objTrans); objTrans.addChild(behavior3); behavior3.setSchedulingBounds(bounds); PickTranslateBehavior ptb = new PickTranslateBehavior(objRoot, canvas, bounds, PickTool.GEOMETRY); ptb.setSchedulingBounds(bounds); // objTrans.addChild(ptb); ptb.setupCallback(new PickingCallback() { public void transformChanged(int type, TransformGroup tg) { if (tg == null) return; Transform3D t3d = new Transform3D(); tg.getTransform(t3d); // System.err.println(tg+" transformChanged \n"+t3d); Point3f p1 = new Point3f(); V v = vertexMap.getKey(tg); // Transform3D lvw = new Transform3D(); // tg.getLocalToVworld(lvw); // System.err.println("lvw = \n"+lvw); // lvw.invert(); // System.err.println("invert lvw = \n"+lvw); Point3f p0 = layout.transform(v); // Transform3D vwip = new Transform3D(); // canvas.getVworldToImagePlate(vwip); // System.err.println("vwip=\n"+vwip); // t3d.mul(lvw); t3d.transform(p1); // scale.transform(p1); System.err.println( "change location for vertex " + v + ", transformGroup " + tg + " from " + p0 + " to " + p1); // p1.set(p1.getX()*2,p1.getY()*2,p1.getZ()*2); // layout.setLocation(v, p1); } }); PickSphereBehavior psb = new PickSphereBehavior(objRoot, canvas, bounds); PickVertexBehavior pvb = new PickVertexBehavior(objRoot, canvas, bounds, renderContext.getPickedVertexState()); objTrans.addChild(pvb); pvb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { for (V v : graph.getVertices()) { VertexGroup<V> vg = vertexMap.get(v); Appearance look = redLook; if (renderContext.getPickedVertexState().isPicked(v)) { look = yellowLook; } Node node = vg.getShape(); if (node instanceof Primitive) { ((Primitive) node).setAppearance(look); } } } }); //Shine it with two colored lights. Color3f lColor1 = new Color3f(.5f, .5f, .5f); Color3f lColor2 = new Color3f(1.0f, 1.0f, 1.0f); Vector3f lDir2 = new Vector3f(-1.0f, 0.0f, -1.0f); DirectionalLight lgt2 = new DirectionalLight(lColor2, lDir2); AmbientLight ambient = new AmbientLight(lColor1); lgt2.setInfluencingBounds(bounds); ambient.setInfluencingBounds(bounds); objRoot.addChild(lgt2); objRoot.addChild(ambient); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); // VisRunner runner = new VisRunner((IterativeContext)elayout); // runner.relax(); return objRoot; }
From source file:OrientedTest.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objScale = new TransformGroup(); Transform3D textMat = new Transform3D(); // Assuming uniform size chars, set scale to fit string in view textMat.setScale(1.2 / sl); objScale.setTransform(textMat);//www . j av a 2 s .com // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objTrans); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Appearance apText = new Appearance(); Material m = new Material(); m.setLightingEnable(true); apText.setMaterial(m); Appearance apEarth = new Appearance(); Material mm = new Material(); mm.setLightingEnable(true); apEarth.setMaterial(mm); Appearance apStone = new Appearance(); apStone.setMaterial(mm); // create 3D text Font3D f3d = new Font3D(new Font(fontName, Font.PLAIN, 2), new FontExtrusion()); Text3D txt = new Text3D(f3d, textString, new Point3f(-sl / 2.0f, 3.0f, 0.0f)); OrientedShape3D textShape = new OrientedShape3D(); textShape.setGeometry(txt); textShape.setAppearance(apText); textShape.setAlignmentAxis(0.0f, 1.0f, 0.0f); objScale.addChild(textShape); // Create a simple shape leaf node, add it to the scene graph. Transform3D cubeMat = new Transform3D(); TransformGroup cubeTrans = new TransformGroup(cubeMat); cubeMat.set(new Vector3d(0.9, 0.0, -1.0)); cubeTrans.setTransform(cubeMat); cubeTrans.addChild(new ColorCube(0.3)); objTrans.addChild(cubeTrans); TextureLoader stoneTex = new TextureLoader(stoneImage, new String("RGB"), this); if (stoneTex != null) apStone.setTexture(stoneTex.getTexture()); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); apStone.setTextureAttributes(texAttr); Transform3D coneMat = new Transform3D(); TransformGroup coneTrans = new TransformGroup(coneMat); coneMat.set(new Vector3d(0.0, 0.0, 0.0)); coneTrans.setTransform(coneMat); coneTrans.addChild(new Cone(.2f, 0.8f, Cone.GENERATE_NORMALS | Cone.GENERATE_TEXTURE_COORDS, apStone)); objTrans.addChild(coneTrans); TextureLoader earthTex = new TextureLoader(earthImage, new String("RGB"), this); if (earthTex != null) apEarth.setTexture(earthTex.getTexture()); apEarth.setTextureAttributes(texAttr); Transform3D cylinderMat = new Transform3D(); TransformGroup cylinderTrans = new TransformGroup(cylinderMat); cylinderMat.set(new Vector3d(-0.9, 0.5, -1.0)); cylinderTrans.setTransform(cylinderMat); cylinderTrans.addChild( new Cylinder(.35f, 2.0f, Cylinder.GENERATE_NORMALS | Cylinder.GENERATE_TEXTURE_COORDS, apEarth)); objTrans.addChild(cylinderTrans); objTrans.addChild(objScale); // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objRoot.addChild(bgNode); // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objRoot.addChild(ambientLightNode); // Set up the directional lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); objRoot.addChild(light2); apText.setMaterial(mm); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:AlternateAppearanceScopeTest.java
BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); // Create influencing bounds worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent Transform3D t = new Transform3D(); // move the object upwards t.set(new Vector3f(0.0f, 0.1f, 0.0f)); // Shrink the object t.setScale(0.8); TransformGroup trans = new TransformGroup(t); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); otherApp = new Appearance(); altMat = new Material(); altMat.setCapability(Material.ALLOW_COMPONENT_WRITE); altMat.setDiffuseColor(new Color3f(0.0f, 1.0f, 0.0f)); otherApp.setMaterial(altMat);/* w w w. java 2s. c o m*/ altApp = new AlternateAppearance(); altApp.setAppearance(otherApp); altApp.setCapability(AlternateAppearance.ALLOW_SCOPE_WRITE); altApp.setCapability(AlternateAppearance.ALLOW_SCOPE_READ); altApp.setInfluencingBounds(worldBounds); objRoot.addChild(altApp); // Build foreground geometry into two groups. We'll // create three directional lights below, one each with // scope to cover the first geometry group only, the // second geometry group only, or both geometry groups. Appearance app1 = new Appearance(); mat1 = new Material(); mat1.setCapability(Material.ALLOW_COMPONENT_WRITE); mat1.setDiffuseColor(new Color3f(1.0f, 0.0f, 0.0f)); app1.setMaterial(mat1); content1 = new SphereGroup(0.05f, // radius of spheres 0.4f, // x spacing 0.2f, // y spacing 3, // number of spheres in X 5, // number of spheres in Y app1, // appearance true); // alt app override = true trans.addChild(content1); shapes1 = ((SphereGroup) content1).getShapes(); content2 = new SphereGroup(0.05f, // radius of spheres .4f, // x spacing 0.2f, // y spacing 2, // number of spheres in X 5, // number of spheres in Y app1, // appearance true); // alt app override = true trans.addChild(content2); shapes2 = ((SphereGroup) content2).getShapes(); // Add lights DirectionalLight light1 = null; light1 = new DirectionalLight(); light1.setEnable(true); light1.setColor(new Color3f(0.2f, 0.2f, 0.2f)); light1.setDirection(new Vector3f(1.0f, 0.0f, -1.0f)); light1.setInfluencingBounds(worldBounds); objRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(); light2.setEnable(true); light2.setColor(new Color3f(0.2f, 0.2f, 0.2f)); light2.setDirection(new Vector3f(-1.0f, 0.0f, 1.0f)); light2.setInfluencingBounds(worldBounds); objRoot.addChild(light2); // Add an ambient light to dimly illuminate the rest of // the shapes in the scene to help illustrate that the // directional lights are being scoped... otherwise it looks // like we're just removing shapes from the scene AmbientLight ambient = new AmbientLight(); ambient.setEnable(true); ambient.setColor(new Color3f(1.0f, 1.0f, 1.0f)); ambient.setInfluencingBounds(worldBounds); objRoot.addChild(ambient); objRoot.addChild(trans); return objRoot; }