List of usage examples for javax.media.j3d BranchGroup compile
public void compile()
From source file:MouseNavigatorApp.java
public BranchGroup createSceneGraph(SimpleUniverse su) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup vpTrans = null;/* ww w. j av a 2s . com*/ BoundingSphere mouseBounds = null; vpTrans = su.getViewingPlatform().getViewPlatformTransform(); objRoot.addChild(new ColorCube(0.4)); objRoot.addChild(new Axis()); mouseBounds = new BoundingSphere(new Point3d(), 1000.0); MouseRotate myMouseRotate = new MouseRotate(MouseBehavior.INVERT_INPUT); myMouseRotate.setTransformGroup(vpTrans); myMouseRotate.setSchedulingBounds(mouseBounds); objRoot.addChild(myMouseRotate); MouseTranslate myMouseTranslate = new MouseTranslate(MouseBehavior.INVERT_INPUT); myMouseTranslate.setTransformGroup(vpTrans); myMouseTranslate.setSchedulingBounds(mouseBounds); objRoot.addChild(myMouseTranslate); MouseZoom myMouseZoom = new MouseZoom(MouseBehavior.INVERT_INPUT); myMouseZoom.setTransformGroup(vpTrans); myMouseZoom.setSchedulingBounds(mouseBounds); objRoot.addChild(myMouseZoom); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:HelloUniverse1.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create the TransformGroup node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at run time. Add it to // the root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);//www . ja v a 2 s .co m // Create a simple Shape3D node; add it to the scene graph. objTrans.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the // desired operation on the specified transform and add // it into the scene graph. Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, 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); objRoot.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:KeyNavigatorApp.java
public BranchGroup createSceneGraph(SimpleUniverse su) { // Create the root of the branch graph TransformGroup vpTrans = null;//w w w .j a va 2s . c o m BranchGroup objRoot = new BranchGroup(); Vector3f translate = new Vector3f(); Transform3D T3D = new Transform3D(); TransformGroup TG = null; objRoot.addChild(createLand()); SharedGroup share = new SharedGroup(); share.addChild(createPyramid()); float[][] position = { { 0.0f, 0.0f, -3.0f }, { 6.0f, 0.0f, 0.0f }, { 6.0f, 0.0f, 6.0f }, { 3.0f, 0.0f, -10.0f }, { 13.0f, 0.0f, -30.0f }, { -13.0f, 0.0f, 30.0f }, { -13.0f, 0.0f, 23.0f }, { 13.0f, 0.0f, 3.0f } }; for (int i = 0; i < position.length; i++) { translate.set(position[i]); T3D.setTranslation(translate); TG = new TransformGroup(T3D); TG.addChild(new Link(share)); objRoot.addChild(TG); } vpTrans = su.getViewingPlatform().getViewPlatformTransform(); translate.set(0.0f, 0.3f, 0.0f); T3D.setTranslation(translate); vpTrans.setTransform(T3D); KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(vpTrans); keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0)); objRoot.addChild(keyNavBeh); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:MousePickApp.java
public BranchGroup createSceneGraph(Canvas3D canvas) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objRotate = null;//from w w w .ja va 2 s . co m PickRotateBehavior pickRotate = null; Transform3D transform = new Transform3D(); BoundingSphere behaveBounds = new BoundingSphere(); // create ColorCube and PickRotateBehavior objects transform.setTranslation(new Vector3f(-0.6f, 0.0f, -0.6f)); objRotate = new TransformGroup(transform); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); pickRotate = new PickRotateBehavior(objRoot, canvas, behaveBounds); objRoot.addChild(pickRotate); // add a second ColorCube object to the scene graph transform.setTranslation(new Vector3f(0.6f, 0.0f, -0.6f)); objRotate = new TransformGroup(transform); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:AxisClassDemoApp.java
public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); objRoot.addChild(new Axis()); // 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 objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // 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, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); rotator.setSchedulingBounds(bounds); Transform3D trans = new Transform3D(); trans.set(new Vector3f(0.5f, 0.0f, 0.0f)); TransformGroup objTrans = new TransformGroup(trans); objRoot.addChild(objSpin);/* ww w . j a va 2 s . c om*/ objSpin.addChild(objTrans); objSpin.addChild(rotator); objTrans.addChild(new ColorCube(0.1)); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:MouseRotate2App.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objRotate = null;/*ww w .j ava 2s .co m*/ MouseRotate myMouseRotate = null; Transform3D transform = new Transform3D(); // create ColorCube and MouseRotate behvaior objects transform.setTranslation(new Vector3f(-0.6f, 0.0f, -0.6f)); objRotate = new TransformGroup(transform); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); myMouseRotate = new MouseRotate(); myMouseRotate.setTransformGroup(objRotate); myMouseRotate.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myMouseRotate); // create ColorCube and MouseRotate behvaior objects transform.setTranslation(new Vector3f(0.6f, 0.0f, -0.6f)); objRotate = new TransformGroup(transform); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); myMouseRotate = new MouseRotate(); myMouseRotate.setTransformGroup(objRotate); myMouseRotate.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myMouseRotate); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:PickCallbackApp.java
public BranchGroup createSceneGraph(Canvas3D canvas) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objRotate = null;/*from w w w .j a v a 2s. c om*/ PickRotateBehavior pickRotate = null; Transform3D transform = new Transform3D(); BoundingSphere behaveBounds = new BoundingSphere(); // create ColorCube and PickRotateBehavior objects transform.setTranslation(new Vector3f(-0.6f, 0.0f, -0.6f)); objRotate = new TransformGroup(transform); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); pickRotate = new PickRotateBehavior(objRoot, canvas, behaveBounds); objRoot.addChild(pickRotate); PickingCallback myCallback = new MyCallbackClass(); // Register the class callback to be called pickRotate.setupCallback(myCallback); // add a second ColorCube object to the scene graph transform.setTranslation(new Vector3f(0.6f, 0.0f, -0.6f)); objRotate = new TransformGroup(transform); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING); objRoot.addChild(objRotate); objRotate.addChild(new ColorCube(0.4)); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:SimpleGeometry.java
public BranchGroup createSceneGraph() { // 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);/*from www .j ava 2s.co m*/ objScale.setTransform(t3d); objRoot.addChild(objScale); // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objScale.addChild(objTrans); // Create a simple shape leaf node, add it to the scene graph. objTrans.addChild(new ColorCube()); // 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, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, 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); objTrans.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:TextureImage.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // 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); objRoot.addChild(objTrans);//w w w . j ava 2 s . co m // Create appearance object for textured cube Appearance app = new Appearance(); Texture tex = new TextureLoader(texImage, this).getTexture(); app.setTexture(tex); TextureAttributes texAttr = new TextureAttributes(); texAttr.setTextureMode(TextureAttributes.MODULATE); app.setTextureAttributes(texAttr); // Create textured cube and add it to the scene graph. Box textureCube = new Box(0.4f, 0.4f, 0.4f, Box.GENERATE_TEXTURE_COORDS, app); objTrans.addChild(textureCube); // 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, 4000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, 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); objTrans.addChild(rotator); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:LOD.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); createLights(objRoot);/*from w w w. jav a2 s . c om*/ // Create the transform group node and initialize it to the // identity. Enable the TRANSFORM_WRITE capability so that // our behavior code can modify it at runtime. Add it to the // root of the subgraph. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objTrans); // Create a switch to hold the different levels of detail Switch sw = new Switch(0); sw.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_READ); sw.setCapability(javax.media.j3d.Switch.ALLOW_SWITCH_WRITE); // Create several levels for the switch, with less detailed // spheres for the ones which will be used when the sphere is // further away sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 40)); sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 20)); sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 10)); sw.addChild(new Sphere(0.4f, Sphere.GENERATE_NORMALS, 3)); // Add the switch to the main group objTrans.addChild(sw); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // set up the DistanceLOD behavior float[] distances = new float[3]; distances[0] = 5.0f; distances[1] = 10.0f; distances[2] = 25.0f; DistanceLOD lod = new DistanceLOD(distances); lod.addSwitch(sw); lod.setSchedulingBounds(bounds); objTrans.addChild(lod); // Have Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }