List of usage examples for javax.media.j3d TransformGroup addChild
public void addChild(Node child)
From source file:ExHenge.java
public Group buildScene() { // Turn off the example headlight setHeadlightEnable(false);//w w w . j a v a2 s .co m // Default to walk navigation setNavigationType(Walk); // // Preload the texture images // if (debug) System.err.println(" textures..."); Texture groundTex = null; Texture spurTex = null; Texture domeTex = null; TextureLoader texLoader = null; ImageComponent image = null; texLoader = new TextureLoader("mud01.jpg", this); image = texLoader.getImage(); if (image == null) System.err.println("Cannot load mud01.jpg texture"); else { groundTex = texLoader.getTexture(); groundTex.setBoundaryModeS(Texture.WRAP); groundTex.setBoundaryModeT(Texture.WRAP); groundTex.setMinFilter(Texture.NICEST); groundTex.setMagFilter(Texture.NICEST); groundTex.setMipMapMode(Texture.BASE_LEVEL); groundTex.setEnable(true); } texLoader = new TextureLoader("stonebrk2.jpg", this); image = texLoader.getImage(); if (image == null) System.err.println("Cannot load stonebrk2.jpg texture"); else { spurTex = texLoader.getTexture(); spurTex.setBoundaryModeS(Texture.WRAP); spurTex.setBoundaryModeT(Texture.WRAP); spurTex.setMinFilter(Texture.NICEST); spurTex.setMagFilter(Texture.NICEST); spurTex.setMipMapMode(Texture.BASE_LEVEL); spurTex.setEnable(true); } texLoader = new TextureLoader("fire.jpg", this); image = texLoader.getImage(); if (image == null) System.err.println("Cannot load fire.jpg texture"); else { domeTex = texLoader.getTexture(); domeTex.setBoundaryModeS(Texture.WRAP); domeTex.setBoundaryModeT(Texture.WRAP); domeTex.setMinFilter(Texture.NICEST); domeTex.setMagFilter(Texture.NICEST); domeTex.setMipMapMode(Texture.BASE_LEVEL); domeTex.setEnable(true); } // // Build some shapes we'll need // if (debug) System.err.println(" flying buttresses..."); // Build three types of spurs (flying buttresses) Appearance spurApp = new Appearance(); Material spurMat = new Material(); spurMat.setAmbientColor(0.6f, 0.6f, 0.6f); spurMat.setDiffuseColor(1.0f, 1.0f, 1.0f); spurMat.setSpecularColor(0.0f, 0.0f, 0.0f); spurApp.setMaterial(spurMat); Transform3D tr = new Transform3D(); tr.setIdentity(); tr.setScale(new Vector3d(1.0, 4.0, 1.0)); TextureAttributes spurTexAtt = new TextureAttributes(); spurTexAtt.setTextureMode(TextureAttributes.MODULATE); spurTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); spurTexAtt.setTextureTransform(tr); spurApp.setTextureAttributes(spurTexAtt); if (spurTex != null) spurApp.setTexture(spurTex); Arch spur1 = new Arch(0.0, // start Phi 1.571, // end Phi 9, // nPhi -0.0982, // start Theta 0.0982, // end Theta (11.25 degrees) 2, // nTheta 2.5, // start radius 1.0, // end radius 0.05, // start phi thickness 0.025, // end phi thickness spurApp); // appearance Arch spur2 = new Arch(0.0, // start Phi 1.571, // end Phi 9, // nPhi -0.0982, // start Theta 0.0982, // end Theta (11.25 degrees) 2, // nTheta 1.5, // start radius 2.0, // end radius 0.05, // start phi thickness 0.025, // end phi thickness spurApp); // appearance Arch spur3 = new Arch(0.0, // start Phi 1.571, // end Phi 9, // nPhi -0.0982, // start Theta 0.0982, // end Theta (11.25 degrees) 2, // nTheta 1.5, // start radius 1.0, // end radius 0.05, // start phi thickness 0.025, // end phi thickness spurApp); // appearance Arch spur4 = new Arch(0.0, // start Phi 1.178, // end Phi 9, // nPhi -0.0982, // start Theta 0.0982, // end Theta (11.25 degrees) 2, // nTheta 4.0, // start radius 4.0, // end radius 0.05, // start phi thickness 0.025, // end phi thickness spurApp); // appearance // Put each spur into a shared group so we can instance // the spurs multiple times SharedGroup spur1Group = new SharedGroup(); spur1Group.addChild(spur1); spur1Group.compile(); SharedGroup spur2Group = new SharedGroup(); spur2Group.addChild(spur2); spur2Group.compile(); SharedGroup spur3Group = new SharedGroup(); spur3Group.addChild(spur3); spur3Group.compile(); SharedGroup spur4Group = new SharedGroup(); spur4Group.addChild(spur4); spur4Group.compile(); // Build a central dome if (debug) System.err.println(" central dome..."); Appearance domeApp = new Appearance(); // No material needed - we want the dome to glow, // so use a REPLACE mode texture only TextureAttributes domeTexAtt = new TextureAttributes(); domeTexAtt.setTextureMode(TextureAttributes.REPLACE); domeTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); domeApp.setTextureAttributes(domeTexAtt); if (domeTex != null) domeApp.setTexture(domeTex); Arch dome = new Arch(0.0, // start Phi 1.571, // end Phi 5, // nPhi 0.0, // start Theta 2.0 * Math.PI, // end Theta (360 degrees) 17, // nTheta 1.0, // start radius 1.0, // end radius 0.0, // start phi thickness 0.0, // end phi thickness domeApp); // appearance // Build the ground. Use a trick to get better lighting // effects by using an elevation grid. The idea is this: // for interactive graphics systems, such as those // controlled by Java3D, lighting effects are computed only // at triangle vertexes. Imagine a big rectangular ground // underneath a PointLight (added below). If the // PointLight is above the center of the square, in the real // world we'd expect a bright spot below it, fading to // darkness at the edges of the square. Not so in // interactive graphics. Since lighting is only computed // at vertexes, and the square's vertexes are each // equidistant from a centered PointLight, all four square // coordinates get the same brightness. That brightness // is interpolated across the square, giving a *constant* // brightness for the entire square! There is no bright // spot under the PointLight. So, here's the trick: use // more triangles. Pretty simple. Split the ground under // the PointLight into a grid of smaller squares. Each // smaller square is shaded using light brightness computed // at the square's vertexes. Squares directly under the // PointLight get brighter lighting at their vertexes, and // thus they are bright. This gives the desired bright // spot under the PointLight. The more squares we use // (a denser grid), the more accurate the bright spot and // the smoother the lighting gradation from bright directly // under the PointLight, to dark at the distant edges. Of // course, with more squares, we also get more polygons to // draw and a performance slow-down. So there is a // tradeoff between lighting quality and drawing speed. // For this example, we'll use a coarse mesh of triangles // created using an ElevationGrid shape. if (debug) System.err.println(" ground..."); Appearance groundApp = new Appearance(); Material groundMat = new Material(); groundMat.setAmbientColor(0.3f, 0.3f, 0.3f); groundMat.setDiffuseColor(0.7f, 0.7f, 0.7f); groundMat.setSpecularColor(0.0f, 0.0f, 0.0f); groundApp.setMaterial(groundMat); tr = new Transform3D(); tr.setScale(new Vector3d(8.0, 8.0, 1.0)); TextureAttributes groundTexAtt = new TextureAttributes(); groundTexAtt.setTextureMode(TextureAttributes.MODULATE); groundTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); groundTexAtt.setTextureTransform(tr); groundApp.setTextureAttributes(groundTexAtt); if (groundTex != null) groundApp.setTexture(groundTex); ElevationGrid ground = new ElevationGrid(11, // X dimension 11, // Z dimension 2.0f, // X spacing 2.0f, // Z spacing // Automatically use zero heights groundApp); // Appearance // // Build the scene using the shapes above. Place everything // withing a TransformGroup. // // Build the scene root TransformGroup scene = new TransformGroup(); tr = new Transform3D(); tr.setTranslation(new Vector3f(0.0f, -1.6f, 0.0f)); scene.setTransform(tr); // Create influencing bounds BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // General Ambient light ambient = new AmbientLight(); ambient.setEnable(ambientOnOff); ambient.setColor(new Color3f(0.3f, 0.3f, 0.3f)); ambient.setCapability(AmbientLight.ALLOW_STATE_WRITE); ambient.setInfluencingBounds(worldBounds); scene.addChild(ambient); // Bright Ambient light brightAmbient = new AmbientLight(); brightAmbient.setEnable(brightAmbientOnOff); brightAmbient.setColor(new Color3f(1.0f, 1.0f, 1.0f)); brightAmbient.setCapability(AmbientLight.ALLOW_STATE_WRITE); brightAmbient.setInfluencingBounds(worldBounds); scene.addChild(brightAmbient); // Red directional light redDirectional = new DirectionalLight(); redDirectional.setEnable(redDirectionalOnOff); redDirectional.setColor(new Color3f(1.0f, 0.0f, 0.0f)); redDirectional.setDirection(new Vector3f(1.0f, -0.5f, -0.5f)); redDirectional.setCapability(AmbientLight.ALLOW_STATE_WRITE); redDirectional.setInfluencingBounds(worldBounds); scene.addChild(redDirectional); // Yellow directional light yellowDirectional = new DirectionalLight(); yellowDirectional.setEnable(yellowDirectionalOnOff); yellowDirectional.setColor(new Color3f(1.0f, 0.8f, 0.0f)); yellowDirectional.setDirection(new Vector3f(-1.0f, 0.5f, 1.0f)); yellowDirectional.setCapability(AmbientLight.ALLOW_STATE_WRITE); yellowDirectional.setInfluencingBounds(worldBounds); scene.addChild(yellowDirectional); // Orange point light orangePoint = new PointLight(); orangePoint.setEnable(orangePointOnOff); orangePoint.setColor(new Color3f(1.0f, 0.5f, 0.0f)); orangePoint.setPosition(new Point3f(0.0f, 0.5f, 0.0f)); orangePoint.setCapability(AmbientLight.ALLOW_STATE_WRITE); orangePoint.setInfluencingBounds(worldBounds); scene.addChild(orangePoint); // Ground scene.addChild(ground); // Dome scene.addChild(dome); // Spur 1's Group g = buildRing(spur1Group); scene.addChild(g); // Spur 2's TransformGroup tg = new TransformGroup(); tr = new Transform3D(); tr.rotY(0.3927); tg.setTransform(tr); g = buildRing(spur2Group); tg.addChild(g); scene.addChild(tg); // Spur 3's g = buildRing(spur3Group); scene.addChild(g); // Spur 4's tg = new TransformGroup(); tg.setTransform(tr); g = buildRing(spur4Group); tg.addChild(g); scene.addChild(tg); return scene; }
From source file:ExSound.java
private Group buildTumblingBox(float width, float height, float depth, Appearance app, int xDur, int yDur, int zDur) { BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Build a box to tumble Shape3D box = buildBox(width, height, depth, app); // Build a set of nested transform groups. Attach // to each one a behavior that rotates around an X, // Y, or Z axis. Use different rotation speeds for // each axis to create a tumbling effect. TransformGroup outerGroup = new TransformGroup(); outerGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D yAxis = new Transform3D(); Alpha alpha = new Alpha(-1, // loop count: -1 = forever Alpha.INCREASING_ENABLE, // increasing 0, // trigger time: 0 = now 0, // delay: 0 = none xDur, // increasing duration 0, // increasing ramp duration 0, // at one (sustain) duration 0, // decreasing duration 0, // decreasing ramp duration 0); // at zero duration RotationInterpolator rot = new RotationInterpolator(alpha, // Alpha // control outerGroup, // Target transform group yAxis, // Y axis rotation 0.0f, // Minimum angle 2.0f * (float) Math.PI);// Maximum angle rot.setSchedulingBounds(worldBounds); outerGroup.addChild(rot); TransformGroup middleGroup = new TransformGroup(); middleGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D xAxis = new Transform3D(); xAxis.rotZ(-1.571f);//from w ww . ja v a 2s .c o m alpha = new Alpha(-1, // loop count: -1 = forever Alpha.INCREASING_ENABLE, // increasing 0, // trigger time: 0 = now 0, // delay: 0 = none yDur, // increasing duration 0, // increasing ramp duration 0, // at one (sustain) duration 0, // decreasing duration 0, // decreasing ramp duration 0); // at zero duration rot = new RotationInterpolator(alpha, // Alpha control middleGroup, // Target transform group xAxis, // Y axis rotation 0.0f, // Minimum angle 2.0f * (float) Math.PI);// Maximum angle rot.setSchedulingBounds(worldBounds); middleGroup.addChild(rot); outerGroup.addChild(middleGroup); TransformGroup innerGroup = new TransformGroup(); innerGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D zAxis = new Transform3D(); zAxis.rotX(1.571f); alpha = new Alpha(-1, // loop count: -1 = forever Alpha.INCREASING_ENABLE, // increasing 0, // trigger time: 0 = now 0, // delay: 0 = none zDur, // increasing duration 0, // increasing ramp duration 0, // at one (sustain) duration 0, // decreasing duration 0, // decreasing ramp duration 0); // at zero duration rot = new RotationInterpolator(alpha, // Alpha control innerGroup, // Target transform group zAxis, // Y axis rotation 0.0f, // Minimum angle 2.0f * (float) Math.PI);// Maximum angle rot.setSchedulingBounds(worldBounds); innerGroup.addChild(rot); middleGroup.addChild(innerGroup); innerGroup.addChild(box); return outerGroup; }
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);// w w w . j av a 2 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; }
From source file:InterpolatorTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); // create a root TG in case we need to scale the scene TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // create the Appearance for the Shape3D Appearance app = new Appearance(); // create a Material, modified by the ColorInterpolator Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Material mat = new Material(objColor, black, objColor, black, 80.0f); mat.setCapability(Material.ALLOW_COMPONENT_WRITE); app.setMaterial(mat);/* ww w . j a va 2 s .c o m*/ // create a TransparencyAttributes, modified by the // TransparencyInterpolator TransparencyAttributes transparency = new TransparencyAttributes(); transparency.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE); transparency.setTransparencyMode(TransparencyAttributes.NICEST); app.setTransparencyAttributes(transparency); // create a Switch Node and set capabilities Switch switchNode = new Switch(); switchNode.setCapability(Switch.ALLOW_SWITCH_WRITE); // create a Alpha object for the Interpolators Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 500, 100, 5000, 2000, 1000, 5000, 2000, 500); // add each BG and Interpolator as a child of the Switch Node TransformGroup tg = createSharedGroup(app); switchNode.addChild(createBranchGroup(tg, new ColorInterpolator(alpha, app.getMaterial()))); tg = createSharedGroup(app); switchNode.addChild(createBranchGroup(tg, new PositionInterpolator(alpha, tg))); tg = createSharedGroup(app); switchNode.addChild(createBranchGroup(tg, new RotationInterpolator(alpha, tg))); tg = createSharedGroup(app); switchNode.addChild(createBranchGroup(tg, new ScaleInterpolator(alpha, tg))); tg = createSharedGroup(app); switchNode.addChild(createBranchGroup(tg, new TransparencyInterpolator(alpha, app.getTransparencyAttributes(), 0, 0.8f))); // define the data for the RotPosScalePathInterpolator float[] knots = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.6f, 0.8f, 0.9f, 1.0f }; float[] scales = { 0.2f, 0.5f, 0.8f, 2.3f, 5.4f, 0.6f, 0.4f, 0.2f, 0.1f }; Quat4f[] quats = new Quat4f[9]; Point3f[] positions = new Point3f[9]; quats[0] = new Quat4f(0.3f, 1.0f, 1.0f, 0.0f); quats[1] = new Quat4f(1.0f, 0.0f, 0.0f, 0.3f); quats[2] = new Quat4f(0.2f, 1.0f, 0.0f, 0.0f); quats[3] = new Quat4f(0.0f, 0.2f, 1.0f, 0.0f); quats[4] = new Quat4f(1.0f, 0.0f, 0.4f, 0.0f); quats[5] = new Quat4f(0.0f, 1.0f, 1.0f, 0.2f); quats[6] = new Quat4f(0.3f, 0.3f, 0.0f, 0.0f); quats[7] = new Quat4f(1.0f, 0.0f, 1.0f, 1.0f); quats[8] = quats[0]; positions[0] = new Point3f(0.0f, 0.0f, -1.0f); positions[1] = new Point3f(1.0f, -2.0f, -2.0f); positions[2] = new Point3f(-2.0f, 2.0f, -3.0f); positions[3] = new Point3f(1.0f, 1.0f, -4.0f); positions[4] = new Point3f(-4.0f, -2.0f, -5.0f); positions[5] = new Point3f(2.0f, 0.3f, -6.0f); positions[6] = new Point3f(-4.0f, 0.5f, -7.0f); positions[7] = new Point3f(0.0f, -1.5f, -4.0f); positions[8] = positions[0]; tg = createSharedGroup(app); // create the Interpolator RotPosScalePathInterpolator rotPosScalePathInterplator = new RotPosScalePathInterpolator(alpha, tg, new Transform3D(), knots, quats, positions, scales); // add a BG for the Interpolator switchNode.addChild(createBranchGroup(tg, rotPosScalePathInterplator)); // create a RandomAlpha object to control a SwitchInterpolator // to set the Switches active child node randomly RandomAlpha randomAlpha = new RandomAlpha(); // create the interpolator SwitchValueInterpolator switchInterpolator = new SwitchValueInterpolator(randomAlpha, switchNode); switchInterpolator.setSchedulingBounds(getApplicationBounds()); // connect the scenegraph objTrans.addChild(switchNode); objTrans.addChild(switchInterpolator); // 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()); // add the lights objRoot.addChild(aLgt); objRoot.addChild(lgt1); // connect objRoot.addChild(objTrans); return objRoot; }
From source file:FourByFour.java
/** * Create the scenegraph for the 3D view. *//*from www . jav a 2s . c o m*/ public BranchGroup createScene3D() { // Define colors Color3f white = new Color3f(1.0f, 1.0f, 1.0f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f red = new Color3f(0.80f, 0.20f, 0.2f); Color3f ambient = new Color3f(0.25f, 0.25f, 0.25f); Color3f diffuse = new Color3f(0.7f, 0.7f, 0.7f); Color3f specular = new Color3f(0.9f, 0.9f, 0.9f); Color3f ambientRed = new Color3f(0.2f, 0.05f, 0.0f); Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); // Create the branch group BranchGroup branchGroup = new BranchGroup(); // Create the bounding leaf node BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 1000.0); BoundingLeaf boundingLeaf = new BoundingLeaf(bounds); branchGroup.addChild(boundingLeaf); // Create the background Background bg = new Background(bgColor); bg.setApplicationBounds(bounds); branchGroup.addChild(bg); // Create the ambient light AmbientLight ambLight = new AmbientLight(white); ambLight.setInfluencingBounds(bounds); branchGroup.addChild(ambLight); // Create the directional light Vector3f dir = new Vector3f(-1.0f, -1.0f, -1.0f); DirectionalLight dirLight = new DirectionalLight(white, dir); dirLight.setInfluencingBounds(bounds); branchGroup.addChild(dirLight); // Create the pole appearance Material poleMaterial = new Material(ambient, black, diffuse, specular, 110.f); poleMaterial.setLightingEnable(true); Appearance poleAppearance = new Appearance(); poleAppearance.setMaterial(poleMaterial); // Create the transform group node TransformGroup transformGroup = new TransformGroup(); transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); transformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); branchGroup.addChild(transformGroup); // Create the poles Poles poles = new Poles(poleAppearance); transformGroup.addChild(poles.getChild()); // Add the position markers to the transform group transformGroup.addChild(positions.getChild()); // Let the positions object know about the transform group positions.setTransformGroup(transformGroup); // Create the mouse pick and drag behavior node PickDragBehavior behavior = new PickDragBehavior(canvas2D, canvas3D, positions, branchGroup, transformGroup); behavior.setSchedulingBounds(bounds); transformGroup.addChild(behavior); return branchGroup; }
From source file:FourByFour.java
public Positions() { // Define colors for lighting Color3f white = new Color3f(1.0f, 1.0f, 1.0f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); Color3f red = new Color3f(0.9f, 0.1f, 0.2f); Color3f blue = new Color3f(0.3f, 0.3f, 0.8f); Color3f yellow = new Color3f(1.0f, 1.0f, 0.0f); Color3f ambRed = new Color3f(0.3f, 0.03f, 0.03f); Color3f ambBlue = new Color3f(0.03f, 0.03f, 0.3f); Color3f ambYellow = new Color3f(0.3f, 0.3f, 0.03f); Color3f ambWhite = new Color3f(0.3f, 0.3f, 0.3f); Color3f specular = new Color3f(1.0f, 1.0f, 1.0f); // Create the red appearance node redMat = new Material(ambRed, black, red, specular, 100.f); redMat.setLightingEnable(true);//from w ww .j a v a2 s . c o m redApp = new Appearance(); redApp.setMaterial(redMat); // Create the blue appearance node blueMat = new Material(ambBlue, black, blue, specular, 100.f); blueMat.setLightingEnable(true); blueApp = new Appearance(); blueApp.setMaterial(blueMat); // Create the yellow appearance node yellowMat = new Material(ambYellow, black, yellow, specular, 100.f); yellowMat.setLightingEnable(true); yellowApp = new Appearance(); yellowApp.setMaterial(yellowMat); // Create the white appearance node whiteMat = new Material(ambWhite, black, white, specular, 100.f); whiteMat.setLightingEnable(true); whiteApp = new Appearance(); whiteApp.setMaterial(whiteMat); // Load the point array with the offset (coordinates) for each of // the 64 positions. point = new Vector3f[64]; int count = 0; for (int i = -30; i < 40; i += 20) { for (int j = -30; j < 40; j += 20) { for (int k = -30; k < 40; k += 20) { point[count] = new Vector3f((float) k, (float) j, (float) i); count++; } } } // Create the switch nodes posSwitch = new Switch(Switch.CHILD_MASK); humanSwitch = new Switch(Switch.CHILD_MASK); machineSwitch = new Switch(Switch.CHILD_MASK); // Set the capability bits posSwitch.setCapability(Switch.ALLOW_SWITCH_READ); posSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); humanSwitch.setCapability(Switch.ALLOW_SWITCH_READ); humanSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); machineSwitch.setCapability(Switch.ALLOW_SWITCH_READ); machineSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); // Create the bit masks posMask = new BitSet(); humanMask = new BitSet(); machineMask = new BitSet(); // Create the small white spheres that mark unoccupied // positions. posSphere = new Sphere[64]; for (int i = 0; i < 64; i++) { Transform3D transform3D = new Transform3D(); transform3D.set(point[i]); TransformGroup transformGroup = new TransformGroup(transform3D); posSphere[i] = new Sphere(2.0f, Sphere.GENERATE_NORMALS | Sphere.ENABLE_APPEARANCE_MODIFY, 12, whiteApp); Shape3D shape = posSphere[i].getShape(); ID id = new ID(i); shape.setUserData(id); transformGroup.addChild(posSphere[i]); posSwitch.addChild(transformGroup); posMask.set(i); } // Create the red spheres that mark the user's positions. for (int i = 0; i < 64; i++) { Transform3D transform3D = new Transform3D(); transform3D.set(point[i]); TransformGroup transformGroup = new TransformGroup(transform3D); transformGroup.addChild(new Sphere(7.0f, redApp)); humanSwitch.addChild(transformGroup); humanMask.clear(i); } // Create the blue cubes that mark the computer's positions. for (int i = 0; i < 64; i++) { Transform3D transform3D = new Transform3D(); transform3D.set(point[i]); TransformGroup transformGroup = new TransformGroup(transform3D); BigCube cube = new BigCube(blueApp); transformGroup.addChild(cube.getChild()); machineSwitch.addChild(transformGroup); machineMask.clear(i); } // Set the positions mask posSwitch.setChildMask(posMask); humanSwitch.setChildMask(humanMask); machineSwitch.setChildMask(machineMask); // Throw everything into a single group group = new Group(); group.addChild(posSwitch); group.addChild(humanSwitch); group.addChild(machineSwitch); }
From source file:ExLinearFog.java
public ColumnScene(Component observer) { BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Add a few lights AmbientLight ambient = new AmbientLight(); ambient.setEnable(true);//from www .j a v a 2s . c om ambient.setColor(new Color3f(0.2f, 0.2f, 0.2f)); ambient.setInfluencingBounds(worldBounds); addChild(ambient); DirectionalLight dir1 = new DirectionalLight(); dir1.setEnable(true); dir1.setColor(new Color3f(1.0f, 1.0f, 1.0f)); dir1.setDirection(new Vector3f(0.8f, -0.35f, 0.5f)); dir1.setInfluencingBounds(worldBounds); addChild(dir1); DirectionalLight dir2 = new DirectionalLight(); dir2.setEnable(true); dir2.setColor(new Color3f(0.75f, 0.75f, 1.0f)); dir2.setDirection(new Vector3f(-0.7f, -0.35f, -0.5f)); dir2.setInfluencingBounds(worldBounds); addChild(dir2); // Load textures TextureLoader texLoader = new TextureLoader("grass06.jpg", observer); Texture grassTex = texLoader.getTexture(); if (grassTex == null) System.err.println("Cannot load grass06.jpg texture"); else { grassTex.setBoundaryModeS(Texture.WRAP); grassTex.setBoundaryModeT(Texture.WRAP); grassTex.setMinFilter(Texture.NICEST); grassTex.setMagFilter(Texture.NICEST); grassTex.setMipMapMode(Texture.BASE_LEVEL); grassTex.setEnable(true); } texLoader = new TextureLoader("marble10.jpg", observer); Texture walkTex = texLoader.getTexture(); if (walkTex == null) System.err.println("Cannot load marble10.jpg texture"); else { walkTex.setBoundaryModeS(Texture.WRAP); walkTex.setBoundaryModeT(Texture.WRAP); walkTex.setMinFilter(Texture.NICEST); walkTex.setMagFilter(Texture.NICEST); walkTex.setMipMapMode(Texture.BASE_LEVEL); walkTex.setEnable(true); } texLoader = new TextureLoader("granite07rev.jpg", observer); columnTex = texLoader.getTexture(); if (columnTex == null) System.err.println("Cannot load granite07rev.jpg texture"); else { columnTex.setBoundaryModeS(Texture.WRAP); columnTex.setBoundaryModeT(Texture.WRAP); columnTex.setMinFilter(Texture.NICEST); columnTex.setMagFilter(Texture.NICEST); columnTex.setMipMapMode(Texture.BASE_LEVEL); columnTex.setEnable(true); } // // Build the ground // +-----+---+-----+ // | | | | // | G | W | G | // | | | | // +-----+---+-----+ // // where "G" is grass, and "W" is a walkway between columns // Vector3f trans = new Vector3f(); Transform3D tr = new Transform3D(); TransformGroup tg; // Walkway appearance Appearance walkApp = new Appearance(); Material walkMat = new Material(); walkMat.setAmbientColor(0.5f, 0.5f, 0.5f); walkMat.setDiffuseColor(1.0f, 1.0f, 1.0f); walkMat.setSpecularColor(0.0f, 0.0f, 0.0f); walkApp.setMaterial(walkMat); TextureAttributes walkTexAtt = new TextureAttributes(); walkTexAtt.setTextureMode(TextureAttributes.MODULATE); walkTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); tr.setIdentity(); tr.setScale(new Vector3d(1.0, 6.0, 1.0)); walkTexAtt.setTextureTransform(tr); walkApp.setTextureAttributes(walkTexAtt); if (walkTex != null) walkApp.setTexture(walkTex); // Grass appearance Appearance grassApp = new Appearance(); Material grassMat = new Material(); grassMat.setAmbientColor(0.5f, 0.5f, 0.5f); grassMat.setDiffuseColor(1.0f, 1.0f, 1.0f); grassMat.setSpecularColor(0.0f, 0.0f, 0.0f); grassApp.setMaterial(grassMat); TextureAttributes grassTexAtt = new TextureAttributes(); grassTexAtt.setTextureMode(TextureAttributes.MODULATE); grassTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); tr.setIdentity(); tr.setScale(new Vector3d(2.0, 8.0, 1.0)); grassTexAtt.setTextureTransform(tr); grassApp.setTextureAttributes(grassTexAtt); if (grassTex != null) grassApp.setTexture(grassTex); // Left grass trans.set(-LawnWidth / 2.0f - WalkwayWidth / 2.0f, -1.6f, 0.0f); tr.set(trans); tg = new TransformGroup(tr); ElevationGrid grass1 = new ElevationGrid(2, // X dimension 2, // Z dimension LawnWidth, // X spacing LawnDepth, // Z spacing grassApp); // appearance tg.addChild(grass1); addChild(tg); // Right grass trans.set(LawnWidth / 2.0f + WalkwayWidth / 2.0f, -1.6f, 0.0f); tr.set(trans); tg = new TransformGroup(tr); ElevationGrid grass2 = new ElevationGrid(2, // X dimension 2, // Z dimension LawnWidth, // X spacing LawnDepth, // Z spacing grassApp); // appearance tg.addChild(grass2); addChild(tg); // Walkway trans.set(0.0f, -1.6f, 0.0f); tr.set(trans); tg = new TransformGroup(tr); ElevationGrid walk = new ElevationGrid(2, // X dimension 2, // Z dimension WalkwayWidth, // X spacing WalkwayDepth, // Z spacing walkApp); // appearance tg.addChild(walk); addChild(tg); // // Build several columns on the floor // SharedGroup column = buildSharedColumn(); Group columns = buildColumns(column); addChild(columns); }
From source file:ExSound.java
private Group buildForeground() { ////w w w .j av a 2 s .c o m // Create a group for the foreground, and move // everything up a bit. // TransformGroup group = new TransformGroup(); Transform3D tr = new Transform3D(); tr.setTranslation(new Vector3f(0.0f, -1.6f, 0.0f)); group.setTransform(tr); // // Load textures // if (debug) System.err.println(" textures..."); Texture groundTex = null; Texture spurTex = null; Texture domeTex = null; TextureLoader texLoader = null; ImageComponent image = null; texLoader = new TextureLoader("flooring.jpg", this); image = texLoader.getImage(); if (image == null) System.err.println("Cannot load flooring.jpg texture"); else { groundTex = texLoader.getTexture(); groundTex.setBoundaryModeS(Texture.WRAP); groundTex.setBoundaryModeT(Texture.WRAP); groundTex.setMinFilter(Texture.NICEST); groundTex.setMagFilter(Texture.NICEST); groundTex.setMipMapMode(Texture.BASE_LEVEL); groundTex.setEnable(true); } texLoader = new TextureLoader("granite07rev.jpg", this); Texture columnTex = texLoader.getTexture(); if (columnTex == null) System.err.println("Cannot load granite07rev.jpg texture"); else { columnTex.setBoundaryModeS(Texture.WRAP); columnTex.setBoundaryModeT(Texture.WRAP); columnTex.setMinFilter(Texture.NICEST); columnTex.setMagFilter(Texture.NICEST); columnTex.setMipMapMode(Texture.BASE_LEVEL); columnTex.setEnable(true); } texLoader = new TextureLoader("brtsky.jpg", this); Texture boxTex = texLoader.getTexture(); if (boxTex == null) System.err.println("Cannot load brtsky.jpg texture"); else { boxTex.setBoundaryModeS(Texture.WRAP); boxTex.setBoundaryModeT(Texture.WRAP); boxTex.setMinFilter(Texture.NICEST); boxTex.setMagFilter(Texture.NICEST); boxTex.setMipMapMode(Texture.BASE_LEVEL); boxTex.setEnable(true); } // // Build the ground // if (debug) System.err.println(" ground..."); Appearance groundApp = new Appearance(); Material groundMat = new Material(); groundMat.setAmbientColor(0.3f, 0.3f, 0.3f); groundMat.setDiffuseColor(0.7f, 0.7f, 0.7f); groundMat.setSpecularColor(0.0f, 0.0f, 0.0f); groundApp.setMaterial(groundMat); tr = new Transform3D(); tr.setScale(new Vector3d(16.0, 4.0, 1.0)); TextureAttributes groundTexAtt = new TextureAttributes(); groundTexAtt.setTextureMode(TextureAttributes.MODULATE); groundTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); groundTexAtt.setTextureTransform(tr); groundApp.setTextureAttributes(groundTexAtt); if (groundTex != null) groundApp.setTexture(groundTex); ElevationGrid ground = new ElevationGrid(11, // X dimension 11, // Z dimension 2.0f, // X spacing 2.0f, // Z spacing // Automatically use zero heights groundApp); // Appearance group.addChild(ground); // // Create a column appearance used for both columns. // Appearance columnApp = new Appearance(); Material columnMat = new Material(); columnMat.setAmbientColor(0.6f, 0.6f, 0.6f); columnMat.setDiffuseColor(1.0f, 1.0f, 1.0f); columnMat.setSpecularColor(0.0f, 0.0f, 0.0f); columnApp.setMaterial(columnMat); TextureAttributes columnTexAtt = new TextureAttributes(); columnTexAtt.setTextureMode(TextureAttributes.MODULATE); columnTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); columnApp.setTextureAttributes(columnTexAtt); if (columnTex != null) columnApp.setTexture(columnTex); // // To give the point sound an apparent location, // build a column and a set of three co-located // tumbling boxes hovering above the column. // TransformGroup pointGroup = new TransformGroup(); tr.setIdentity(); tr.setTranslation(new Vector3f(pointX, 0.0f, 0.0f)); pointGroup.setTransform(tr); GothicColumn column = new GothicColumn(1.0f, // height 0.2f, // radius GothicColumn.BUILD_TOP, // flags columnApp); // appearance pointGroup.addChild(column); TransformGroup rotThing = new TransformGroup(); tr.setIdentity(); tr.setTranslation(new Vector3f(0.0f, soundHeight, 0.0f)); rotThing.setTransform(tr); Appearance boxApp = new Appearance(); // No material -- make it emissive TextureAttributes boxTexAtt = new TextureAttributes(); boxTexAtt.setTextureMode(TextureAttributes.REPLACE); boxTexAtt.setPerspectiveCorrectionMode(TextureAttributes.NICEST); boxApp.setTextureAttributes(boxTexAtt); if (boxTex != null) boxApp.setTexture(boxTex); rotThing.addChild(buildTumblingBox(0.4f, 0.4f, 0.4f, // width, height, // depth boxApp, // Appearance 40000, 32000, 26000));// XYZ tumble durations rotThing.addChild(buildTumblingBox(0.4f, 0.4f, 0.4f, // width, height, // depth boxApp, // Appearance 38000, 30000, 28000));// XYZ tumble durations rotThing.addChild(buildTumblingBox(0.4f, 0.4f, 0.4f, // width, height, // depth boxApp, // Appearance 30000, 26000, 34000));// XYZ tumble durations pointGroup.addChild(rotThing); group.addChild(pointGroup); return group; }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
/** * Creates new form Display3DPanel//from w w w . j a va 2 s . co m */ public Display3DPanel() { initComponents(); effectiveHeight = getHeight(); effectiveWidth = getWidth(); logger.debug("creating Display3DPanel"); this.setMinimumSize(new Dimension(200, 200)); this.setPreferredSize(new Dimension(800, 600)); GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D(); template.setStereo(GraphicsConfigTemplate3D.PREFERRED); // Get the GraphicsConfiguration that best fits our needs. logger.debug("getting config"); GraphicsConfiguration gcfg = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getBestConfiguration(template); logger.debug("creating canvas"); canvas = new Canvas3D(gcfg) { @Override public void postRender() { vGraphics = super.getGraphics2D(); vGraphics.setFont(new Font("sans-serif", Font.PLAIN, 10)); vGraphics.setColor(Color.YELLOW); locToWin.update(); fireProjectionChanged(new ProjectionEvent(this, locToWin)); draw2D(vGraphics, locToWin, effectiveWidth, effectiveHeight); vGraphics.flush(false); } @Override public void postSwap() { if (postRenderSilent || waitForExternalTrigger) { return; } if (!(storingJPEG || storingPNG || storingFrames)) { fireFrameRendered(); } if (storingFrames) { if (storingJPEG) { writeImage(new File(controlsPanel.getMovieCreationPanel().getCurrentFrameFileName())); } else { writeYUV(controlsPanel.getMovieCreationPanel().getGenericFrameFileName()); } } } }; canvas.setStereoEnable(false); add("Center", canvas); pickObject = new PickObject(canvas, objScene, rootObject.getGeometryObj(), objRotate); canvas.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { if (evt.isShiftDown()) { // if (e.isShiftDown()) // System.out.println(""+e.getX() + " " + e.getY()); } if (evt.getButton() == MouseEvent.BUTTON1) { if (evt.getClickCount() > 1) { reset(); } else if (pickObject.consumeEmulated3DPick(evt.getX(), evt.getY())) { /* Nothing must be done - everything was done in consumeEmulated3DPick() */ } else { pickObject.consume2DSelectModule(evt.getX(), evt.getY()); } rootObject.firePickChanged(evt, locToWin); } if (evt.getButton() == MouseEvent.BUTTON3) { if (getControlsFrame() != null) { getControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500); getControlsFrame().setVisible(true); } else if (getTransientControlsFrame() != null) { getTransientControlsFrame().setBounds(evt.getXOnScreen() - 130, evt.getYOnScreen(), 240, 500); getTransientControlsFrame().setVisible(true); } else if (application != null) { application.getFrames().getGuiPanel().selectModule(name); } } if (evt.getButton() == MouseEvent.BUTTON2) { reset(); } } @Override public void mouseEntered(java.awt.event.MouseEvent evt) { mouseOn = true; mouseObserverThread = new Thread(new MouseObserver()); mouseObserverThread.start(); } @Override public void mouseExited(java.awt.event.MouseEvent evt) { mouseObserverThread = null; mouseOn = false; } }); canvas.addMouseMotionListener(new java.awt.event.MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) { // if (e.isShiftDown()) // System.out.println(""+e.getX() + " " + e.getY()); } @Override public void mouseMoved(MouseEvent e) { } }); canvas.addMouseWheelListener(new java.awt.event.MouseWheelListener() { @Override public void mouseWheelMoved(java.awt.event.MouseWheelEvent evt) { rescaleFromMouseWheel(evt); } }); canvas.addKeyListener(new java.awt.event.KeyAdapter() { @Override public void keyTyped(KeyEvent evt) { formKeyTyped(evt); } @Override public void keyPressed(KeyEvent evt) { formKeyPressed(evt); } @Override public void keyReleased(KeyEvent evt) { formKeyReleased(evt); } }); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(true); universe = new SimpleUniverse(canvas); view = canvas.getView(); view.setProjectionPolicy(View.PERSPECTIVE_PROJECTION); view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY); objScene.addChild(rootObject.getGeometryObj()); rootObject.setRenderingWindow(this); rootObject.getGeometryObj().setUserData(null); bg.setCapability(Background.ALLOW_COLOR_WRITE); bg.setCapability(Background.ALLOW_COLOR_READ); bg.setCapability(Background.ALLOW_IMAGE_WRITE); bg.setCapability(Background.ALLOW_IMAGE_READ); bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_READ); bg.setCapability(Background.ALLOW_IMAGE_SCALE_MODE_WRITE); bg.setImageScaleMode(Background.SCALE_FIT_ALL); bg.setApplicationBounds(bounds); myFog.setCapability(LinearFog.ALLOW_DISTANCE_WRITE); myFog.setCapability(LinearFog.ALLOW_COLOR_WRITE); myFog.setInfluencingBounds(bounds); myFog.setFrontDistance(1.); myFog.setBackDistance(4.); myFogGroup.addChild(myFog); mouseRotate.setTransformGroup(objRotate); mouseRotate.setSchedulingBounds(bounds); mouseRotate.setFactor(mouseRotateSensitivity); mouseTranslate.setTransformGroup(objRotate); mouseTranslate.setSchedulingBounds(bounds); mouseTranslate.setFactor(mouseTranslateSensitivity); mouseZoom.setTransformGroup(objRotate); mouseZoom.setSchedulingBounds(bounds); windowRootObject.addChild(mouseRotate); windowRootObject.addChild(mouseTranslate); windowRootObject.addChild(mouseZoom); objTranslate.addChild(objScene); objScale.addChild(objTranslate); objRotate.addChild(bg); objRotate.addChild(objScale); windowRootObject.addChild(objRotate); ambientLight = new EditableAmbientLight(new Color3f(.25f, .25f, .25f), bounds, "ambient light", true); windowRootObject.addChild(ambientLight.getLight()); directionalLights.add(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f), new Vector3f(.1f, .08f, -.5f), bounds, "light 1", true, true)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.2f, 0.15f, 0.1f), new Vector3f(-1.f, -0.4f, -.5f), bounds, "light 2", true, false)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f), new Vector3f(0.f, 0.6f, -1.f), bounds, "light 3", true, false)); directionalLights.add(new EditableDirectionalLight(new Color3f(0.1f, 0.1f, 0.15f), new Vector3f(0.f, -0.6f, -1.f), bounds, "light 3", false, false)); for (int i = 0; i < directionalLights.size(); i++) { TransformGroup lightTransform = new TransformGroup(); lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); lightTransform.setName("light" + i + "Transform"); directionalLightTransforms.add(lightTransform); OpenBranchGroup lightGroup = new OpenBranchGroup(); EditableDirectionalLight light = directionalLights.get(i); lightGroup.addChild(light.getLight()); lightGroup.addChild(light.getBackLight()); lightTransform.addChild(lightGroup); windowRootObject.addChild(lightTransform); } modelClip.setCapability(ModelClip.ALLOW_ENABLE_READ); modelClip.setCapability(ModelClip.ALLOW_ENABLE_WRITE); modelClip.setCapability(ModelClip.ALLOW_PLANE_READ); modelClip.setCapability(ModelClip.ALLOW_PLANE_WRITE); modelClip.setInfluencingBounds(bounds); objScene.addChild(modelClip); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); pointLights .add(new EditablePointLight(new Color3f(0.4f, 0.4f, 0.4f), bounds, null, null, "light 1", false)); for (int i = 0; i < pointLights.size(); i++) { TransformGroup lightTransform = new TransformGroup(); lightTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); lightTransform.setName("light" + i + "Transform"); pointLightTransforms.add(lightTransform); OpenBranchGroup lightGroup = new OpenBranchGroup(); EditablePointLight light = pointLights.get(i); lightGroup.addChild(light.getLight()); lightTransform.addChild(lightGroup); windowRootObject.addChild(lightTransform); } alternateTransformObj.addChild(alternateRootObj); alternateTransormBranch.addChild(alternateTransformObj); windowRootObject.addChild(alternateTransormBranch); universe.getViewingPlatform().setNominalViewingTransform(); universe.addBranchGraph(windowRootObject); view.getPhysicalBody().getLeftEyePosition(defaultLeftEye); view.getPhysicalBody().getRightEyePosition(defaultRightEye); controlsFrame = new Display3DControlsFrame(this); controlsPanel = controlsFrame.getControlPanel(); universe.getViewingPlatform().getViewPlatformTransform().getTransform(initialCameraTransform); objReper.addChild(reper.getGeometryObj()); positionedReper.addChild(objReper); positionedReper.setTransform( new Transform3D(new float[] { .15f, 0, 0, -.8f, 0, .15f, 0, .76f, 0, 0, .15f, 0, 0, 0, 0, 1 })); reperGroup.addChild(positionedReper); OpenBranchGroup reperLightGroup = new OpenBranchGroup(); reperLightGroup.addChild(new AmbientLight(new Color3f(.6f, .6f, .6f))); reperLightGroup.addChild(new EditableDirectionalLight(new Color3f(0.4f, 0.4f, 0.4f), new Vector3f(.1f, .08f, -1f), bounds, "light 1", true, true).getLight()); reperGroup.addChild(reperLightGroup); universe.addBranchGraph(reperGroup); locToWin = new LocalToWindow(rootObject.getGeometryObj(), canvas); /** * The line below binds reper with scene rotation when using any method that calls * objRotate.setTransform(), so: keyboard (explicitly calling), mouse (Java3D is calling * setTransform) and some custom ways (e.g. in haptic pointer) */ objRotate.addTransformListener(objReper); // mouseRotate.setupCallback(objReper); // it is not needed, because Java3D calls objRotate.setTranform which fires callback to the reper }