List of usage examples for javax.media.j3d Transform3D Transform3D
public Transform3D()
From source file:PlatformTest.java
ViewingPlatform createViewer(Canvas3D c, String szName, Color3f objColor, double x, double z) { // create a Viewer and attach to its canvas // a Canvas3D can only be attached to a single Viewer Viewer viewer2 = new Viewer(c); // create a ViewingPlatform with 1 TransformGroups above the // ViewPlatform ViewingPlatform vp2 = new ViewingPlatform(1); // create and assign the PlatformGeometry to the Viewer vp2.setPlatformGeometry(createPlatformGeometry(szName)); // create and assign the ViewerAvatar to the Viewer viewer2.setAvatar(createViewerAvatar(szName, objColor)); // set the initial position for the Viewer Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(x, 0, z)); vp2.getViewPlatformTransform().setTransform(t3d); // set capabilities on the TransformGroup so that the // KeyNavigatorBehavior // can modify the Viewer's position vp2.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); vp2.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // attach a navigation behavior to the position of the viewer KeyNavigatorBehavior key = new KeyNavigatorBehavior(vp2.getViewPlatformTransform()); key.setSchedulingBounds(m_Bounds); key.setEnable(false);//from ww w . j a va 2 s . co m // add the KeyNavigatorBehavior to the ViewingPlatform vp2.addChild(key); // set the ViewingPlatform for the Viewer viewer2.setViewingPlatform(vp2); // associate the name of the Viewer with its KeyNavigatorBehavior m_KeyHashtable.put(szName, key); // create a button to switch the Viewer ON. Button button = new Button(szName); button.addActionListener(this); add(button); return vp2; }
From source file:ScenegraphTest.java
private TransformGroup addLimb(Group parentGroup, String szName, double radius, double length, double rotMin, double rotMax) { // create the rotator TransformGroup tgJoint = new TransformGroup(); tgJoint.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tgJoint.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // add a rotator if necessary if (rotMin != rotMax) { Transform3D xAxis = new Transform3D(); xAxis.rotX(Math.PI / 2.0); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, tgJoint, xAxis, (float) rotMin, (float) rotMax); rotator.setSchedulingBounds(createApplicationBounds()); tgJoint.addChild(rotator);//w w w . java2s . com } // create a cylinder using length and radius tgJoint.addChild(createLimb(radius, length)); // create the joint (the *next* TG should // be offset by the length of this limb) TransformGroup tgOffset = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(0, length, 0)); tgOffset.setTransform(t3d); tgJoint.addChild(tgOffset); parentGroup.addChild(tgJoint); // return the offset TG, so any child TG's will be added // in the correct position. return tgOffset; }
From source file:TexCoordTest.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.rotX(0.4);/*from ww w . j a v a2s. com*/ t3d.setScale(getScale()); t3d.setTranslation(new Vector3d(0.0, 0, -20.0)); t3d.invert(); tgArray[0].setTransform(t3d); return tgArray; }
From source file:SimpleCollision2.java
/** * Creates the content branch of the scene graph. * /*from w ww .j av a2 s . c om*/ * @return BranchGroup with content attached. */ protected BranchGroup buildContentBranch() { //First create a different appearance for each cube Appearance app1 = new Appearance(); Appearance app2 = new Appearance(); Appearance app3 = new Appearance(); Color3f ambientColour1 = new Color3f(1.0f, 0.0f, 0.0f); Color3f ambientColour2 = new Color3f(1.0f, 1.0f, 0.0f); Color3f ambientColour3 = new Color3f(1.0f, 1.0f, 1.0f); Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f); Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f); Color3f diffuseColour1 = new Color3f(1.0f, 0.0f, 0.0f); Color3f diffuseColour2 = new Color3f(1.0f, 1.0f, 0.0f); Color3f diffuseColour3 = new Color3f(1.0f, 1.0f, 1.0f); float shininess = 20.0f; app1.setMaterial(new Material(ambientColour1, emissiveColour, diffuseColour1, specularColour, shininess)); app2.setMaterial(new Material(ambientColour2, emissiveColour, diffuseColour2, specularColour, shininess)); app3.setMaterial(new Material(ambientColour3, emissiveColour, diffuseColour3, specularColour, shininess)); //Build the vertex array for the cubes. We can use the same //data for each cube so we just define one set of data IndexedQuadArray indexedCube = new IndexedQuadArray(8, IndexedQuadArray.COORDINATES | IndexedQuadArray.NORMALS, 24); Point3f[] cubeCoordinates = { new Point3f(1.0f, 1.0f, 1.0f), new Point3f(-1.0f, 1.0f, 1.0f), new Point3f(-1.0f, -1.0f, 1.0f), new Point3f(1.0f, -1.0f, 1.0f), new Point3f(1.0f, 1.0f, -1.0f), new Point3f(-1.0f, 1.0f, -1.0f), new Point3f(-1.0f, -1.0f, -1.0f), new Point3f(1.0f, -1.0f, -1.0f) }; Vector3f[] cubeNormals = { new Vector3f(0.0f, 0.0f, 1.0f), new Vector3f(0.0f, 0.0f, -1.0f), new Vector3f(1.0f, 0.0f, 0.0f), new Vector3f(-1.0f, 0.0f, 0.0f), new Vector3f(0.0f, 1.0f, 0.0f), new Vector3f(0.0f, -1.0f, 0.0f) }; int cubeCoordIndices[] = { 0, 1, 2, 3, 7, 6, 5, 4, 0, 3, 7, 4, 5, 6, 2, 1, 0, 4, 5, 1, 6, 7, 3, 2 }; int cubeNormalIndices[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; indexedCube.setCoordinates(0, cubeCoordinates); indexedCube.setNormals(0, cubeNormals); indexedCube.setCoordinateIndices(0, cubeCoordIndices); indexedCube.setNormalIndices(0, cubeNormalIndices); //Create the three cubes leftCube = new Shape3D(indexedCube, app1); rightCube = new Shape3D(indexedCube, app2); moveCube = new Shape3D(indexedCube, app3); //Define some user data so that we can print meaningful messages leftCube.setUserData(new String("left cube")); rightCube.setUserData(new String("right cube")); //Create the content branch and add the lights BranchGroup contentBranch = new BranchGroup(); addLights(contentBranch); //Set up the transform to position the left cube Transform3D leftGroupXfm = new Transform3D(); leftGroupXfm.set(new Vector3d(-1.5, 0.0, 0.0)); leftGroup = new TransformGroup(leftGroupXfm); //Set up the transform to position the right cube Transform3D rightGroupXfm = new Transform3D(); rightGroupXfm.set(new Vector3d(1.5, 0.0, 0.0)); rightGroup = new TransformGroup(rightGroupXfm); //Create the movable cube's transform with a scale and //a translation. Set up the //capabilities so it can be moved by the behaviour Transform3D moveXfm = new Transform3D(); moveXfm.set(0.7, new Vector3d(0.0, 2.0, 1.0)); moveGroup = new TransformGroup(moveXfm); moveGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); moveGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); moveGroup.setCapability(TransformGroup.ENABLE_PICK_REPORTING); //Create the behaviour to move the movable cube PickTranslateBehavior pickTranslate = new PickTranslateBehavior(contentBranch, myCanvas3D, bounds); contentBranch.addChild(pickTranslate); //Create and add the two colision detectors CollisionDetector2 myColDetLeft = new CollisionDetector2(leftCube, bounds); contentBranch.addChild(myColDetLeft); CollisionDetector2 myColDetRight = new CollisionDetector2(rightCube, bounds); contentBranch.addChild(myColDetRight); //Set up the scene graph contentBranch.addChild(moveGroup); contentBranch.addChild(leftGroup); contentBranch.addChild(rightGroup); moveGroup.addChild(moveCube); leftGroup.addChild(leftCube); rightGroup.addChild(rightCube); return contentBranch; }
From source file:BehaviorTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); // create a TransformGroup to rotate the hand TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // create a RotationInterpolator behavior to rotate the hand Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); m_RotationInterpolator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); m_RotationInterpolator.setSchedulingBounds(createApplicationBounds()); objTrans.addChild(m_RotationInterpolator); // create an Appearance and Material Appearance app = new Appearance(); TextureLoader tex = new TextureLoader("earth.jpg", this); app.setTexture(tex.getTexture());/*from w w w . ja va 2 s . c o m*/ Sphere sphere = new Sphere(3, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, 32, app); // connect the scenegraph objTrans.addChild(sphere); objRoot.addChild(objTrans); m_FpsBehavior = new FpsBehavior(); m_FpsBehavior.setSchedulingBounds(getApplicationBounds()); objRoot.addChild(m_FpsBehavior); m_BoundsBehavior = new BoundsBehavior(sphere); m_BoundsBehavior.setSchedulingBounds(getApplicationBounds()); m_BoundsBehavior.addBehaviorToParentGroup(objTrans); m_StretchBehavior = new StretchBehavior((GeometryArray) sphere.getShape().getGeometry()); m_StretchBehavior.setSchedulingBounds(getApplicationBounds()); objRoot.addChild(m_StretchBehavior); m_StretchBehavior.setEnable(false); m_SizeBehavior = new ObjectSizeBehavior((GeometryArray) sphere.getShape().getGeometry()); m_SizeBehavior.setSchedulingBounds(getApplicationBounds()); objRoot.addChild(m_SizeBehavior); m_SizeBehavior.setEnable(false); m_ExplodeBehavior = new ExplodeBehavior(sphere.getShape(), 10000, 20, this); m_ExplodeBehavior.setSchedulingBounds(getApplicationBounds()); objRoot.addChild(m_ExplodeBehavior); return objRoot; }
From source file:SimpleGame.java
/** * Creates the duck. This loads the two duck geometries from the files * 'duck.obj' and 'deadduck.obj' and loads these into a switch. The access * rights to the switch are then set so we can write to this switch to swap * between the two duck models. It also creates a transform group and an * interpolator to move the duck./*from w ww . j a v a2 s . c o m*/ * * @return BranchGroup with content attached. */ protected BranchGroup buildDuck() { BranchGroup theDuck = new BranchGroup(); duckSwitch = new Switch(0); duckSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); ObjectFile f1 = new ObjectFile(); ObjectFile f2 = new ObjectFile(); Scene s1 = null; Scene s2 = null; try { s1 = f1.load("duck.obj"); s2 = f2.load("deadduck.obj"); } catch (Exception e) { System.exit(1); } TransformGroup duckRotXfmGrp = new TransformGroup(); Transform3D duckRotXfm = new Transform3D(); Matrix3d duckRotMat = new Matrix3d(); duckRotMat.rotY(Math.PI / 2); duckRotXfm.set(duckRotMat, new Vector3d(0.0, 0.0, -30.0), 1.0); duckRotXfmGrp.setTransform(duckRotXfm); duckRotXfmGrp.addChild(duckSwitch); duckSwitch.addChild(s1.getSceneGroup()); duckSwitch.addChild(s2.getSceneGroup()); TransformGroup duckMovXfmGrp = new TransformGroup(); duckMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); duckMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); duckMovXfmGrp.addChild(duckRotXfmGrp); duckAlpha = new Alpha(-1, 0, 0, 3000, 0, 0); Transform3D axis = new Transform3D(); PositionInterpolator moveDuck = new PositionInterpolator(duckAlpha, duckMovXfmGrp, axis, -30.0f, 30.0f); moveDuck.setSchedulingBounds(bounds); theDuck.addChild(moveDuck); theDuck.addChild(duckMovXfmGrp); return theDuck; }
From source file:ConicWorld.java
private Group createObject(int i, int j, 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); Primitive obj = null;/*w w w. ja v a 2 s .c o m*/ if (i % 3 == 2) { obj = (Primitive) new Sphere(1.0f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS, j * 8 + 4, app); } else if (i % 3 == 1) { obj = (Primitive) new Cylinder(1.0f, 2.0f, Cylinder.GENERATE_TEXTURE_COORDS | Cylinder.GENERATE_NORMALS, j * 8 + 4, j * 8 + 4, app); } else if (i % 3 == 0) { obj = (Primitive) new Cone(1.0f, 2.0f, Cone.GENERATE_NORMALS | Cone.GENERATE_TEXTURE_COORDS, j * 8 + 4, j * 8 + 4, app); } // add it to the scene graph. spinTg.addChild(obj); // 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:LineTypes.java
BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create a TransformGroup to scale the scene down by 3.5x // TODO: move view platform instead of scene using orbit behavior TransformGroup objScale = new TransformGroup(); Transform3D scaleTrans = new Transform3D(); //scaleTrans.set(1 / 3.5f); // scale down by 3.5x objScale.setTransform(scaleTrans);/* w ww.ja v a 2 s . c o m*/ objRoot.addChild(objScale); // Create a TransformGroup and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // the mouse behaviors 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 the primitives to the scene objTrans.addChild(createLineTypes()); BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0); Background bg = new Background(new Color3f(1.0f, 1.0f, 1.0f)); bg.setApplicationBounds(bounds); objTrans.addChild(bg); // set up the mouse rotation behavior MouseRotate mr = new MouseRotate(); mr.setTransformGroup(objTrans); mr.setSchedulingBounds(bounds); mr.setFactor(0.007); objTrans.addChild(mr); // 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, 1.0f); Vector3f light1Direction = new Vector3f(0.0f, -0.2f, -1.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); return objRoot; }
From source file:GeometryByReferenceTest.java
BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); // Set up attributes to render lines app = new Appearance(); transp = new TransparencyAttributes(); transp.setTransparency(0.5f);//from ww w.java2s . c om transp.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE); transp.setTransparencyMode(TransparencyAttributes.NONE); app.setTransparencyAttributes(transp); tetraRegular = createGeometry(1); tetraStrip = createGeometry(2); tetraIndexed = createGeometry(3); tetraIndexedStrip = createGeometry(4); geoArrays[0] = tetraRegular; geoArrays[1] = tetraStrip; geoArrays[2] = tetraIndexed; geoArrays[3] = tetraIndexedStrip; shape = new Shape3D(tetraRegular, app); shape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ); Transform3D t = new Transform3D(); // move the object upwards t.set(new Vector3f(0.0f, 0.3f, 0.0f)); // rotate the shape Transform3D temp = new Transform3D(); temp.rotX(Math.PI / 4.0d); t.mul(temp); temp.rotY(Math.PI / 4.0d); t.mul(temp); // Shrink the object t.setScale(0.6); TransformGroup trans = new TransformGroup(t); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(trans); trans.addChild(shape); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // 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); objRoot.addChild(aLgt); objRoot.addChild(lgt1); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:LightScopeApp.java
BranchGroup createScene() { BranchGroup scene = new BranchGroup(); TransformGroup tableTG = new TransformGroup(); TransformGroup lampTG = new TransformGroup(); TransformGroup litBoxTG = new TransformGroup(); TransformGroup unLitBoxTG = new TransformGroup(); scene.addChild(tableTG);/*from www .j av a 2s . c o m*/ tableTG.addChild(lampTG); tableTG.addChild(litBoxTG); tableTG.addChild(unLitBoxTG); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); Color3f red = new Color3f(1.0f, 0.0f, 0.0f); Color3f blue = new Color3f(0.0f, 1.0f, 0.0f); Color3f green = new Color3f(0.0f, 0.0f, 1.0f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Vector3f transVector = new Vector3f(); Transform3D transTransform = new Transform3D(); transVector.set(0.0f, -0.4f, 0.5f); transTransform.setTranslation(transVector); tableTG.setTransform(transTransform); transVector.set(-0.4f, 0.001f, 0.1f); transTransform.setTranslation(transVector); lampTG.setTransform(transTransform); transVector.set(-0.2f, 0.1f, 0.2f); transTransform.setTranslation(transVector); litBoxTG.setTransform(transTransform); transVector.set(0.3f, 0.1f, -0.4f); transTransform.setTranslation(transVector); unLitBoxTG.setTransform(transTransform); Shape3D tablePlane = createXZPlane(new Point3f(-1.0f, 0.0f, -1.0f), new Point3f(-1.0f, 0.0f, 1.0f), new Point3f(1.0f, 0.0f, 1.0f), new Point3f(1.0f, 0.0f, -1.0f)); tablePlane.setAppearance(createMaterialAppearance(white)); tableTG.addChild(tablePlane); litBoxTG.addChild(new Box(0.1f, 0.1f, 0.1f, Box.GENERATE_NORMALS, createMaterialAppearance(red))); Shape3D shadowPlane = createXZPlane(new Point3f(0.1f, -0.095f, -0.1f), new Point3f(0.1f, -0.095f, 0.1f), new Point3f(0.2f, -0.095f, 0.15f), new Point3f(0.2f, -0.095f, -0.15f)); shadowPlane.setAppearance(createMaterialAppearance(black)); litBoxTG.addChild(shadowPlane); Appearance redGlowMat = createMaterialAppearance(red); // redGlowMat.getMaterial().setEmissiveColor(0.5f, 0.5f, 0.5f); unLitBoxTG.addChild(new Box(0.1f, 0.1f, 0.1f, Box.GENERATE_NORMALS, redGlowMat)); Shape3D lamp = createLampShape(); Appearance lampAppearance = createMaterialAppearance(blue); PolygonAttributes polyAttrib = new PolygonAttributes(); polyAttrib.setCullFace(PolygonAttributes.CULL_NONE); polyAttrib.setBackFaceNormalFlip(true); lampAppearance.setPolygonAttributes(polyAttrib); lamp.setAppearance(lampAppearance); lampTG.addChild(lamp); PointLight lampLight = new PointLight(); lampLight.setPosition(0.1f, 0.5f, -0.1f); lampLight.setInfluencingBounds(new BoundingSphere()); lampTG.addChild(lampLight); Shape3D litPlane = createXZPlane(new Point3f(-0.4f, 0.0f, -0.4f), new Point3f(-0.4f, 0.0f, 0.4f), new Point3f(0.4f, 0.0f, 0.4f), new Point3f(0.4f, 0.0f, -0.4f)); litPlane.setAppearance(createMaterialAppearance(white)); lampTG.addChild(litPlane); lampLight.addScope(lampTG); lampLight.addScope(litBoxTG); AmbientLight lightA = new AmbientLight(); lightA.setInfluencingBounds(new BoundingSphere()); scene.addChild(lightA); DirectionalLight lightD1 = new DirectionalLight(); lightD1.setInfluencingBounds(new BoundingSphere()); lightD1.setColor(new Color3f(0.4f, 0.4f, 0.4f)); Vector3f lightDir = new Vector3f(-1.0f, -1.0f, -1.0f); lightDir.normalize(); lightD1.setDirection(lightDir); scene.addChild(lightD1); DirectionalLight lightD2 = new DirectionalLight(); lightD2.setInfluencingBounds(new BoundingSphere()); lightD2.setColor(new Color3f(0.2f, 0.2f, 0.2f)); lightDir.set(1.0f, -1.0f, -1.0f); lightDir.normalize(); lightD2.setDirection(lightDir); scene.addChild(lightD2); Background bg = new Background(); bg.setColor(1.0f, 1.0f, 1.0f); bg.setApplicationBounds(new BoundingSphere()); scene.addChild(bg); return scene; }