List of usage examples for javax.media.j3d Appearance Appearance
public Appearance()
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);/* ww w . j av a 2 s. c o m*/ 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:Human1.java
void createHuman() { Human_body = new TransformGroup(); // center the body tmpVector.set(0.0f, -1.5f, 0.0f);//from w w w . j a v a 2s . c om tmpTrans.set(tmpVector); Human_body.setTransform(tmpTrans); // Set up an appearance to make the body with red ambient, // black emmissive, red diffuse and white specular coloring Material material = new Material(red, black, red, white, 64); Appearance appearance = new Appearance(); appearance.setMaterial(material); // offset and place the cylinder for the body tmpTG = new TransformGroup(); // offset the shape tmpVector.set(0.0f, 1.5f, 0.0f); tmpTrans.set(tmpVector); tmpTG.setTransform(tmpTrans); tmpCyl = new Cylinder(0.75f, 3.0f, appearance); tmpTG.addChild(tmpCyl); // add the shape to the body Human_body.addChild(tmpTG); // create the r_shoulder TransformGroup Human_r_shoulder = new TransformGroup(); Human_r_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Human_r_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // translate from the waist tmpVector.set(-0.95f, 2.9f, -0.2f); tmpTrans.set(tmpVector); Human_r_shoulder.setTransform(tmpTrans); // place the sphere for the r_shoulder tmpSphere = new Sphere(0.22f, appearance); Human_r_shoulder.addChild(tmpSphere); // offset and place the cylinder for the r_shoulder tmpTG = new TransformGroup(); // offset the shape tmpVector.set(0.0f, -0.5f, 0.0f); tmpTrans.set(tmpVector); tmpTG.setTransform(tmpTrans); tmpCyl = new Cylinder(0.2f, 1.0f, appearance); tmpTG.addChild(tmpCyl); // add the shape to the r_shoulder Human_r_shoulder.addChild(tmpTG); // add the shoulder to the body group Human_body.addChild(Human_r_shoulder); // create the r_elbow TransformGroup Human_r_elbow = new TransformGroup(); Human_r_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Human_r_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tmpVector.set(0.0f, -1.054f, 0.0f); tmpTrans.set(tmpVector); Human_r_elbow.setTransform(tmpTrans); // place the sphere for the r_elbow tmpSphere = new Sphere(0.22f, appearance); Human_r_elbow.addChild(tmpSphere); // offset and place the cylinder for the r_shoulder tmpTG = new TransformGroup(); // offset the shape tmpVector.set(0.0f, -0.5f, 0.0f); tmpTrans.set(tmpVector); tmpTG.setTransform(tmpTrans); tmpCyl = new Cylinder(0.2f, 1.0f, appearance); tmpTG.addChild(tmpCyl); // add the shape to the r_shoulder Human_r_elbow.addChild(tmpTG); // add the elbow to the shoulder group Human_r_shoulder.addChild(Human_r_elbow); // create the l_shoulder TransformGroup Human_l_shoulder = new TransformGroup(); Human_l_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Human_l_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tmpVector.set(0.95f, 2.9f, -0.2f); tmpTrans.set(tmpVector); Human_l_shoulder.setTransform(tmpTrans); // place the sphere for the l_shoulder tmpSphere = new Sphere(0.22f, appearance); Human_l_shoulder.addChild(tmpSphere); // offset and place the cylinder for the l_shoulder tmpTG = new TransformGroup(); // offset the shape tmpVector.set(0.0f, -0.5f, 0.0f); tmpTrans.set(tmpVector); tmpTG.setTransform(tmpTrans); tmpCyl = new Cylinder(0.2f, 1.0f, appearance); tmpTG.addChild(tmpCyl); // add the shape to the l_shoulder Human_l_shoulder.addChild(tmpTG); // add the shoulder to the body group Human_body.addChild(Human_l_shoulder); // create the r_elbow TransformGroup Human_l_elbow = new TransformGroup(); Human_l_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Human_l_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tmpVector.set(0.0f, -1.054f, 0.0f); tmpTrans.set(tmpVector); Human_l_elbow.setTransform(tmpTrans); // place the sphere for the l_elbow tmpSphere = new Sphere(0.22f, appearance); Human_l_elbow.addChild(tmpSphere); // offset and place the cylinder for the l_elbow tmpTG = new TransformGroup(); // offset the shape tmpVector.set(0.0f, -0.5f, 0.0f); tmpTrans.set(tmpVector); tmpTG.setTransform(tmpTrans); tmpCyl = new Cylinder(0.2f, 1.0f, appearance); tmpTG.addChild(tmpCyl); // add the shape to the l_elbow Human_l_elbow.addChild(tmpTG); // add the shoulder to the body group Human_l_shoulder.addChild(Human_l_elbow); // create the skullbase TransformGroup Human_skullbase = new TransformGroup(); tmpVector.set(0.0f, 3.632f, 0.0f); tmpTrans.set(tmpVector); Human_skullbase.setTransform(tmpTrans); // offset and place the sphere for the skull tmpSphere = new Sphere(0.5f, appearance); // add the shape to the l_shoulder Human_skullbase.addChild(tmpSphere); // add the shoulder to the body group Human_body.addChild(Human_skullbase); }
From source file:SimpleIndexedQuad.java
/** * Build a cube from an IndexedQuadArray. This method creates the vertices * as a set of eight points and the normals as a set of six vectors (one for * each face). The data is then defined such that each vertex has a * different normal associated with it when it is being used for a different * face./*from w ww .ja va 2s.c o m*/ * * @return Node that is the shape. */ protected Node buildShape() { //The shape. The constructor specifies 8 vertices, that both //vertices and normals are to be defined and that there are //24 normals to be specified (4 for each of the 6 faces). IndexedQuadArray indexedCube = new IndexedQuadArray(8, IndexedQuadArray.COORDINATES | IndexedQuadArray.NORMALS, 24); //The vertex coordinates defined as an array of points. 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) }; //The vertex normals defined as an array of vectors Vector3f[] normals = { 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) }; //Define the indices used to reference vertex array int coordIndices[] = { 0, 1, 2, 3, 7, 6, 5, 4, 0, 3, 7, 4, 5, 6, 2, 1, 0, 4, 5, 1, 6, 7, 3, 2 }; //Define the indices used to reference normal array int normalIndices[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 }; //Set the data indexedCube.setCoordinates(0, cubeCoordinates); indexedCube.setNormals(0, normals); indexedCube.setCoordinateIndices(0, coordIndices); indexedCube.setNormalIndices(0, normalIndices); //Define an appearance for the shape Appearance app = new Appearance(); Color3f ambientColour = new Color3f(1.0f, 0.0f, 0.0f); Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f); Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f); Color3f diffuseColour = new Color3f(1.0f, 0.0f, 0.0f); float shininess = 20.0f; app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess)); //Create and return the shape return new Shape3D(indexedCube, app); }
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 www .java 2 s. c o m 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:ExTexture.java
public Group buildScene() { // Get the current menu choices for appearance attributes int textureMode = ((Integer) modes[currentMode].value).intValue(); Color3f color = (Color3f) colors[currentColor].value; Color3f blendColor = (Color3f) colors[currentBlendColor].value; // Turn on the example headlight setHeadlightEnable(true);//from ww w .jav a 2 s .c o m // Default to examine navigation setNavigationType(Examine); // Disable scene graph compilation for this example setCompilable(false); // Create the scene group Group scene = new Group(); // BEGIN EXAMPLE TOPIC // Set up a basic material Material mat = new Material(); mat.setAmbientColor(0.2f, 0.2f, 0.2f); mat.setDiffuseColor(1.0f, 1.0f, 1.0f); mat.setSpecularColor(0.0f, 0.0f, 0.0f); mat.setLightingEnable(true); // Set up the texturing attributes with an initial // texture mode, texture transform, and blend color texatt = new TextureAttributes(); texatt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); texatt.setTextureMode(textureMode); texatt.setTextureTransform(new Transform3D()); // Identity texatt.setTextureBlendColor(blendColor.x, blendColor.y, blendColor.z, 0.5f); // Enable changing these while the node component is live texatt.setCapability(TextureAttributes.ALLOW_MODE_WRITE); texatt.setCapability(TextureAttributes.ALLOW_BLEND_COLOR_WRITE); texatt.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE); // Create an appearance using these attributes app = new Appearance(); app.setMaterial(mat); app.setTextureAttributes(texatt); app.setTexture(tex); // And enable changing these while the node component is live app.setCapability(Appearance.ALLOW_TEXTURE_WRITE); app.setCapability(Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE); // Build a shape and enable changing its appearance shape = new Shape3D(buildGeometry(), app); shape.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); // END EXAMPLE TOPIC // Create some dummy appearance and tex attribute node components // In response to menu choices, we quickly switch the shape to // use one of these, then diddle with the main appearance or // tex attribute, then switch the shape back. This effectively // makes the appearance or tex attributes we want to change // become un-live during a change. We have to do this approach // because some texture features have no capability bits to set // to allow changes while live. dummyApp = new Appearance(); dummyAtt = new TextureAttributes(); scene.addChild(shape); return scene; }
From source file:SimpleIndexedQuadSmooth.java
/** * Build a cube from an IndexedQuadArray. This method creates the vertices * as a set of eight points and the normals as a set of six vectors (one for * each face). The data is then defined such that each vertex has a * different normal associated with it when it is being used for a different * face./*from w w w.j a v a2 s . c o m*/ * * @return Node that is the shape. */ protected Node buildShape() { //The shape. The constructor specifies 8 vertices, that both //vertices and normals are to be defined and that there are //24 normals to be specified (4 for each of the 6 faces). IndexedQuadArray indexedCube = new IndexedQuadArray(8, IndexedQuadArray.COORDINATES | IndexedQuadArray.NORMALS, 24); //The vertex coordinates defined as an array of points. 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) }; //The vertex normals defined as an array of vectors Vector3f[] normals = { new Vector3f(1.0f, 1.0f, 1.0f), new Vector3f(-1.0f, 1.0f, 1.0f), new Vector3f(-1.0f, -1.0f, 1.0f), new Vector3f(1.0f, -1.0f, 1.0f), new Vector3f(1.0f, 1.0f, -1.0f), new Vector3f(-1.0f, 1.0f, -1.0f), new Vector3f(-1.0f, -1.0f, -1.0f), new Vector3f(1.0f, -1.0f, -1.0f) }; //Define the indices used to reference vertex array int coordIndices[] = { 0, 1, 2, 3, 7, 6, 5, 4, 0, 3, 7, 4, 5, 6, 2, 1, 0, 4, 5, 1, 6, 7, 3, 2 }; //Define the indices used to reference normal array int normalIndices[] = { 0, 1, 2, 3, 7, 6, 5, 4, 0, 3, 7, 4, 5, 6, 2, 1, 0, 4, 5, 1, 6, 7, 3, 2 }; //Set the data indexedCube.setCoordinates(0, cubeCoordinates); indexedCube.setNormals(0, normals); indexedCube.setCoordinateIndices(0, coordIndices); indexedCube.setNormalIndices(0, normalIndices); //Define an appearance for the shape Appearance app = new Appearance(); Color3f ambientColour = new Color3f(1.0f, 0.0f, 0.0f); Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f); Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f); Color3f diffuseColour = new Color3f(1.0f, 0.0f, 0.0f); float shininess = 20.0f; app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess)); //Create and return the shape return new Shape3D(indexedCube, app); }
From source file:SimpleTest.java
public BranchGroup createBackground() { // create a parent BranchGroup for the Background BranchGroup backgroundGroup = new BranchGroup(); // create a new Background node Background back = new Background(); // set the range of influence of the background back.setApplicationBounds(getBoundingSphere()); // create a BranchGroup that will hold // our Sphere geometry BranchGroup bgGeometry = new BranchGroup(); // create an appearance for the Sphere Appearance app = new Appearance(); // load a texture image using the Java 3D texture loader Texture tex = new TextureLoader("back.jpg", this).getTexture(); // apply the texture to the Appearance app.setTexture(tex);/*from ww w .jav a 2s .c o m*/ // create the Sphere geometry with radius 1.0 // we tell the Sphere to generate texture coordinates // to enable the texture image to be rendered // and because we are *inside* the Sphere we have to generate // Normal coordinates inwards or the Sphere will not be visible. Sphere sphere = new Sphere(1.0f, Primitive.GENERATE_TEXTURE_COORDS | Primitive.GENERATE_NORMALS_INWARD, app); // start wiring everything together // add the Sphere to its parent BranchGroup bgGeometry.addChild(sphere); // assign the BranchGroup to the Background as geometry. back.setGeometry(bgGeometry); // add the Background node to its parent BranchGroup backgroundGroup.addChild(back); return backgroundGroup; }
From source file:AvatarTest.java
public Group createCars(Group g) { BranchGroup bg = new BranchGroup(); for (int n = (int) Road.ROAD_LENGTH; n < 0; n = n + 10) { Car car = new Car(this, bg, ComplexObject.GEOMETRY | ComplexObject.TEXTURE | ComplexObject.SOUND); car.createObject(new Appearance(), new Vector3d(getRandomNumber(0.0f, 2.0f), Car.CAR_HEIGHT / 2.0f, getRandomNumber(n, 5.0f)), new Vector3d(1, 1, 1), "car0.jpg", "car.wav", "collide.wav"); }// ww w. ja v a 2 s .c o m g.addChild(bg); return bg; }
From source file:InterleavedTest.java
BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); // Set up attributes to render lines app = new Appearance(); app.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE); transp = new TransparencyAttributes(); transp.setTransparency(0.5f);// ww w . ja va2 s.c o m transp.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE); transp.setTransparencyMode(TransparencyAttributes.NONE); app.setTransparencyAttributes(transp); // load textures TextureAttributes texAttr1 = new TextureAttributes(); texAttr1.setTextureMode(TextureAttributes.DECAL); TextureAttributes texAttr2 = new TextureAttributes(); texAttr2.setTextureMode(TextureAttributes.MODULATE); TextureLoader tex = new TextureLoader(texImage1, new String("RGB"), this); if (tex == null) return null; tex1 = tex.getTexture(); tex = new TextureLoader(texImage2, new String("RGB"), this); if (tex == null) return null; tex2 = tex.getTexture(); textureUnitState[0] = new TextureUnitState(tex1, texAttr1, null); textureUnitState[1] = new TextureUnitState(tex2, texAttr2, null); 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); 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:SimpleSounds.java
protected BranchGroup buildContentBranch() { //Create the appearance Appearance app = new Appearance(); Color3f ambientColour = new Color3f(1.0f, 0.0f, 0.0f); Color3f emissiveColour = new Color3f(0.0f, 0.0f, 0.0f); Color3f specularColour = new Color3f(1.0f, 1.0f, 1.0f); Color3f diffuseColour = new Color3f(1.0f, 0.0f, 0.0f); float shininess = 20.0f; app.setMaterial(new Material(ambientColour, emissiveColour, diffuseColour, specularColour, shininess)); //Make the cube Box myCube = new Box(1.0f, 1.0f, 1.0f, app); TransformGroup cubeGroup = new TransformGroup(); BranchGroup contentBranch = new BranchGroup(); addLights(contentBranch);//from www . j av a 2 s. c om addObjectSound(cubeGroup, sound1, new String("file:./loop1.wav"), 10.0f); addObjectSound(cubeGroup, sound2, new String("file:./loop2.wav"), 20.0f); addBackgroundSound(contentBranch, new String("file:./loop3.wav")); cubeGroup.addChild(myCube); contentBranch.addChild(cubeGroup); return contentBranch; }