List of usage examples for javax.media.j3d DirectionalLight setInfluencingBounds
public void setInfluencingBounds(Bounds region)
From source file:TexCoordTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objPosition = new TransformGroup(); objPosition.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D axisTranslate = new Transform3D(); axisTranslate.rotZ(Math.toRadians(90)); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 6000, 0, 0, 0, 0, 0); m_PositionInterpolator = new PositionInterpolator(rotationAlpha, objPosition, axisTranslate, 0, 70); m_PositionInterpolator.setSchedulingBounds(createApplicationBounds()); objPosition.addChild(m_PositionInterpolator); m_PositionInterpolator.setEnable(false); m_RotationInterpolator = new RotationInterpolator(rotationAlpha, objRotate, new Transform3D(), 0.0f, (float) Math.PI * 2.0f); m_RotationInterpolator.setSchedulingBounds(getApplicationBounds()); objRotate.addChild(m_RotationInterpolator); m_RotationInterpolator.setEnable(true); TransformGroup tgLand = new TransformGroup(); Transform3D t3dLand = new Transform3D(); t3dLand.setTranslation(new Vector3d(0, -30, 0)); tgLand.setTransform(t3dLand);/*from www. j a v a2 s . co m*/ tgLand.addChild(createDemLandscape()); objRotate.addChild(tgLand); objPosition.addChild(objRotate); objRoot.addChild(objPosition); // create some lights for the scene Color3f lColor1 = new Color3f(0.3f, 0.3f, 0.3f); Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f); Color3f alColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight aLgt = new AmbientLight(alColor); aLgt.setInfluencingBounds(getApplicationBounds()); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(getApplicationBounds()); // add the lights to the parent BranchGroup objRoot.addChild(aLgt); objRoot.addChild(lgt1); return objRoot; }
From source file:VrmlPickingTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); Bounds lightBounds = getApplicationBounds(); AmbientLight ambLight = new AmbientLight(true, new Color3f(1.0f, 1.0f, 1.0f)); ambLight.setInfluencingBounds(lightBounds); objRoot.addChild(ambLight);/* w ww . j ava2s .c o m*/ DirectionalLight headLight = new DirectionalLight(); headLight.setInfluencingBounds(lightBounds); objRoot.addChild(headLight); TransformGroup mouseGroup = createMouseBehaviorsGroup(); String vrmlFile = null; try { URL codebase = getWorkingDirectory(); vrmlFile = codebase.toExternalForm() + "BoxConeSphere.wrl"; } catch (Exception e) { e.printStackTrace(); } if (m_szCommandLineArray != null) { switch (m_szCommandLineArray.length) { case 0: break; case 1: vrmlFile = m_szCommandLineArray[0]; break; default: System.err.println("Usage: VrmlPickingTest [pathname|URL]"); System.exit(-1); } } BranchGroup sceneRoot = loadVrmlFile(vrmlFile); if (sceneRoot != null) mouseGroup.addChild(sceneRoot); objRoot.addChild(mouseGroup); return objRoot; }
From source file:PlatformTest.java
public BranchGroup createSceneGraph() { final int LAND_WIDTH = 12; final float LAND_HEIGHT = -1.0f; final int LAND_LENGTH = 12; final int nTileSize = 2; // calculate how many vertices we need to store all the "tiles" // that compose the QuadArray. final int nNumTiles = ((LAND_LENGTH / nTileSize) * 2) * ((LAND_WIDTH / nTileSize) * 2); final int nVertexCount = 4 * nNumTiles; Point3f[] coordArray = new Point3f[nVertexCount]; Point2f[] texCoordArray = new Point2f[nVertexCount]; // create an Appearance and load a texture Appearance app = new Appearance(); Texture tex = new TextureLoader("land.jpg", this).getTexture(); app.setTexture(tex);/*from w w w .ja v a 2 s .c om*/ // create the parent BranchGroup BranchGroup bg = new BranchGroup(); int nItem = 0; // loop over all the tiles in the environment for (int x = -LAND_WIDTH; x <= LAND_WIDTH; x += nTileSize) { for (int z = -LAND_LENGTH; z <= LAND_LENGTH; z += nTileSize) { // if we are on the border of the environment create a // TransformGroup to position a ColorCube to create a "wall" if (x == -LAND_WIDTH || x == LAND_WIDTH || z == -LAND_LENGTH || z == LAND_LENGTH) { TransformGroup tg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(x, 0, z)); tg.setTransform(t3d); tg.addChild(new ColorCube(nTileSize / 2)); bg.addChild(tg); } // if we are not on the last row or column create a "tile" // and add to the QuadArray. Use CCW winding and assign texture // coordinates. if (z < LAND_LENGTH && x < LAND_WIDTH) { coordArray[nItem] = new Point3f(x, LAND_HEIGHT, z); texCoordArray[nItem++] = new Point2f(0, 0); coordArray[nItem] = new Point3f(x, LAND_HEIGHT, z + nTileSize); texCoordArray[nItem++] = new Point2f(1, 0); coordArray[nItem] = new Point3f(x + nTileSize, LAND_HEIGHT, z + nTileSize); texCoordArray[nItem++] = new Point2f(1, 1); coordArray[nItem] = new Point3f(x + nTileSize, LAND_HEIGHT, z); texCoordArray[nItem++] = new Point2f(0, 1); } } } // create a GeometryInfo and generate Normal vectors // for the QuadArray that was populated. GeometryInfo gi = new GeometryInfo(GeometryInfo.QUAD_ARRAY); gi.setCoordinates(coordArray); gi.setTextureCoordinates(texCoordArray); NormalGenerator normalGenerator = new NormalGenerator(); normalGenerator.generateNormals(gi); // wrap the GeometryArray in a Shape3D Shape3D shape = new Shape3D(gi.getGeometryArray(), app); // add the Shape3D to the parent BranchGroup bg.addChild(shape); // create some lights for the scene 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(m_Bounds); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(m_Bounds); // add the lights to the parent BranchGroup bg.addChild(aLgt); bg.addChild(lgt1); // create a light gray background Background back = new Background(new Color3f(0.9f, 0.9f, 0.9f)); back.setApplicationBounds(m_Bounds); bg.addChild(back); // compile the whole scene //bg.compile(); return bg; }
From source file:TextureByReference.java
public BranchGroup createSceneGraph() { // create the root of the branch group BranchGroup objRoot = new BranchGroup(); // create the transform group node and initialize it // enable the TRANSFORM_WRITE capability so that it can be modified // at runtime. Add it to the root of the subgraph Transform3D rotate = new Transform3D(); TransformGroup objTrans = new TransformGroup(rotate); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);/*from w w w .j a v a 2 s.com*/ // bounds BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // set up some light Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f); Vector3f lDir1 = new Vector3f(-1.0f, -0.5f, -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); Appearance appearance = new Appearance(); // enable the TEXTURE_WRITE so we can modify it at runtime appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE); // load the first texture TextureLoader loader = new TextureLoader(urls[0], TextureLoader.BY_REFERENCE | TextureLoader.Y_UP, this); // get the texture from the loader Texture2D tex = (Texture2D) loader.getTexture(); // get the BufferedImage to convert to TYPE_4BYTE_ABGR and flip // get the ImageComponent because we need it anyway ImageComponent2D imageComp = (ImageComponent2D) tex.getImage(0); BufferedImage bImage = imageComp.getImage(); // convert the image bImage = ImageOps.convertImage(bImage, BufferedImage.TYPE_4BYTE_ABGR); // flip the image ImageOps.flipImage(bImage); imageComp.set(bImage); tex.setCapability(Texture.ALLOW_IMAGE_WRITE); tex.setBoundaryModeS(Texture.CLAMP); tex.setBoundaryModeT(Texture.CLAMP); tex.setBoundaryColor(1.0f, 1.0f, 1.0f, 1.0f); // set the image of the texture tex.setImage(0, imageComp); // set the texture on the appearance appearance.setTexture(tex); // set texture attributes TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); appearance.setTextureAttributes(texAttr); // set material properties Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); appearance.setMaterial(new Material(white, black, white, black, 1.0f)); // create a scale transform Transform3D scale = new Transform3D(); scale.set(.6); TransformGroup objScale = new TransformGroup(scale); objTrans.addChild(objScale); tetra = new Tetrahedron(true); tetra.setAppearance(appearance); objScale.addChild(tetra); // create the behavior animate = new AnimateTexturesBehavior(tex, urls, appearance, this); animate.setSchedulingBounds(bounds); objTrans.addChild(animate); // add a rotation behavior so we can see all sides of the tetrahedron Transform3D yAxis = new Transform3D(); Alpha rotorAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotorAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator); // have java3d perform optimizations on this scene graph objRoot.compile(); return objRoot; }
From source file:LoaderTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); // create a TransformGroup to flip the hand onto its end and enlarge it. TransformGroup objTrans1 = new TransformGroup(); Transform3D tr = new Transform3D(); objTrans1.getTransform(tr);/* w w w . j a va 2s.c o m*/ tr.rotX(90.0 * Math.PI / 180.0); tr.setScale(10.0); objTrans1.setTransform(tr); // create a TransformGroup to rotate the hand TransformGroup objTrans2 = new TransformGroup(); objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // 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); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans2, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(bounds); objTrans2.addChild(rotator); // 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); // load the object file Scene scene = null; Shape3D shape = null; // read in the geometry information from the data file ObjectFile objFileloader = new ObjectFile(ObjectFile.RESIZE); try { scene = objFileloader.load("hand1.obj"); } catch (Exception e) { scene = null; System.err.println(e); } if (scene == null) System.exit(1); // retrieve the Shape3D object from the scene BranchGroup branchGroup = scene.getSceneGroup(); shape = (Shape3D) branchGroup.getChild(0); // create an Appearance and Material Appearance app = new Appearance(); Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); // assign the appearance to the Shape shape.setAppearance(app); // connect the scenegraph objTrans2.addChild(scene.getSceneGroup()); objTrans1.addChild(objTrans2); objRoot.addChild(objTrans1); return objRoot; }
From source file:TransformExplorer.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 TransformGroup objScale = new TransformGroup(); Transform3D scaleTrans = new Transform3D(); scaleTrans.set(1 / 3.5f); // scale down by 3.5x objScale.setTransform(scaleTrans);// w w w.jav a2s . 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(createConeTransformGroup()); // the cone rotAxis = new RotAxis(rotAxisLength); // the axis objTrans.addChild(rotAxis); coordSys = new CoordSys(coordSysLength); // the coordSys objTrans.addChild(coordSys); BoundingSphere bounds = new BoundingSphere(new Point3d(), 100.0); // The book used a white background for the figures //Background bg = new Background(new Color3f(1.0f, 1.0f, 1.0f)); //bg.setApplicationBounds(bounds); //objTrans.addChild(bg); // 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:GearTest.java
BranchGroup createBranchEnvironment() { // Create the root of the branch graph BranchGroup branchRoot = new BranchGroup(); // Create a bounds for the background and lights 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); branchRoot.addChild(bgNode);//from w w w .j a va 2 s . c o m // Set up the ambient light Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); branchRoot.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); branchRoot.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); branchRoot.addChild(light2); return branchRoot; }
From source file:GearTest.java
public BranchGroup createSceneGraph(int toothCount) { // 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 .jav a 2 s .com objScale.setTransform(t3d); objRoot.addChild(objScale); // Create a bounds for the background and lights 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 bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objScale.addChild(bgNode); // Set up the global lights Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f); Color3f light2Color = new Color3f(0.3f, 0.3f, 0.4f); Vector3f light2Direction = new Vector3f(-6.0f, -2.0f, -1.0f); Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objScale.addChild(ambientLightNode); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objScale.addChild(light1); DirectionalLight light2 = new DirectionalLight(light2Color, light2Direction); light2.setInfluencingBounds(bounds); objScale.addChild(light2); // 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); objScale.addChild(objTrans); // Create an Appearance. Appearance look = new Appearance(); Color3f objColor = new Color3f(0.5f, 0.5f, 0.6f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f white = new Color3f(1.0f, 1.0f, 1.0f); look.setMaterial(new Material(objColor, black, objColor, white, 100.0f)); // Create a gear, add it to the scene graph. // SpurGear gear = new SpurGear(toothCount, 1.0f, 0.2f, SpurGear gear = new SpurGearThinBody(toothCount, 1.0f, 0.2f, 0.05f, 0.05f, 0.3f, 0.28f, look); objTrans.addChild(gear); // Create a new Behavior object that will rotate the object and // add it into the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 8000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:PickTest.java
public BranchGroup createSceneGraph(Canvas3D canvas) { // 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(1.0);//from w w w . j a v a 2s. c o m objScale.setTransform(t3d); objRoot.addChild(objScale); // Create a bunch of objects with a behavior and add them // into the scene graph. int row, col; int numRows = 4, numCols = 4; for (int i = 0; i < numRows; i++) { double ypos = (double) (i - numRows / 2) * 0.45 + 0.25; for (int j = 0; j < numCols; j++) { double xpos = (double) (j - numCols / 2) * 0.45 + 0.25; objScale.addChild(createObject(i * numCols + j, 0.1, xpos, ypos)); } } BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Add a light. Color3f lColor = new Color3f(1.0f, 1.0f, 1.0f); Vector3f lDir = new Vector3f(0.0f, 0.0f, -1.0f); DirectionalLight lgt = new DirectionalLight(lColor, lDir); lgt.setInfluencingBounds(bounds); objRoot.addChild(lgt); // 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); objRoot.addChild(mBeh); behavior1 = new PickRotateBehavior(objRoot, canvas, bounds); objRoot.addChild(behavior1); behavior2 = new PickZoomBehavior(objRoot, canvas, bounds); objRoot.addChild(behavior2); behavior3 = new PickTranslateBehavior(objRoot, canvas, bounds); objRoot.addChild(behavior3); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:AppearanceTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup zoomTg = new TransformGroup(); zoomTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); zoomTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // attach a navigation behavior to the position of the viewer KeyNavigatorBehavior key = new KeyNavigatorBehavior(zoomTg); key.setSchedulingBounds(createApplicationBounds()); key.setEnable(true);//from w ww . ja va2 s.c o m objRoot.addChild(key); // create a TransformGroup to flip the hand onto its end and enlarge it. TransformGroup objTrans1 = new TransformGroup(); Transform3D tr = new Transform3D(); objTrans1.getTransform(tr); tr.setEuler(new Vector3d(0.5 * Math.PI, 0.6, 0)); objTrans1.setTransform(tr); // 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(getApplicationBounds()); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(getApplicationBounds()); objRoot.addChild(aLgt); objRoot.addChild(lgt1); int nScale = 50; Box box = new Box(nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, m_Appearance); Shape3D frontFace = box.getShape(Box.LEFT); // create a new left face so we can // assign per-vertex colors GeometryArray geometry = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR_4 | GeometryArray.TEXTURE_COORDINATE_2); nScale = 40; final float[] verts = { // left face -1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale }; final float[] colors = { // left face 1, 0, 0, 0, 0, 1, 0, 0.2f, 0, 0, 1, 0.8f, 0, 0, 0, 1, }; float[] tcoords = { // left 1, 0, 1, 1, 0, 1, 0, 0 }; Vector3f normalVector = new Vector3f(-1.0f, 0.0f, 0.0f); geometry.setColors(0, colors, 0, 4); for (int n = 0; n < 4; n++) geometry.setNormal(n, normalVector); geometry.setTextureCoordinates(0, tcoords, 0, 4); geometry.setCoordinates(0, verts); frontFace.setGeometry(geometry); // connect the scenegraph objTrans1.addChild(box); zoomTg.addChild(objTrans1); objRoot.addChild(zoomTg); return objRoot; }