List of usage examples for javax.media.j3d TransformGroup ALLOW_TRANSFORM_READ
int ALLOW_TRANSFORM_READ
To view the source code for javax.media.j3d TransformGroup ALLOW_TRANSFORM_READ.
Click Source Link
From source file:StereoGirl.java
public BranchGroup createSceneGraph(int i) { System.out.println("Creating scene for: " + URLString); // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); try {//from w w w .j a va 2 s . com Transform3D myTransform3D = new Transform3D(); myTransform3D.setTranslation(new Vector3f(+0.0f, -0.1f, -1.2f)); TransformGroup objTrans = new TransformGroup(myTransform3D); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D t = new Transform3D(); TransformGroup tg = new TransformGroup(t); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.addChild(tg); URL url = new URL(URLString); ObjectFile f = new ObjectFile(); f.setFlags(ObjectFile.RESIZE | ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY); System.out.println("About to load"); Scene s = f.load(url); tg.addChild(s.getSceneGroup()); System.out.println("Finished Loading"); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Color3f light1Color = new Color3f(.9f, 0.8f, 0.8f); Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objTrans.addChild(light1); // Set up the ambient light Color3f ambientColor = new Color3f(1.0f, .4f, 0.3f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objTrans.addChild(ambientLightNode); MouseRotate behavior = new MouseRotate(); behavior.setTransformGroup(tg); objTrans.addChild(behavior); // Create the translate behavior node MouseTranslate behavior3 = new MouseTranslate(); behavior3.setTransformGroup(tg); objTrans.addChild(behavior3); behavior3.setSchedulingBounds(bounds); KeyNavigatorBehavior keyNavBeh = new KeyNavigatorBehavior(tg); keyNavBeh.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0)); objTrans.addChild(keyNavBeh); behavior.setSchedulingBounds(bounds); objRoot.addChild(objTrans); } catch (Throwable t) { System.out.println("Error: " + t); } return objRoot; }
From source file:BillboardTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); 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); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator);// w ww. j av a 2s .c om objTrans.addChild(createBillboard("AXIS - 0,1,0", new Point3f(-40.0f, 40.0f, 0.0f), Billboard.ROTATE_ABOUT_AXIS, new Point3f(0.0f, 1.0f, 0.0f), bounds)); objTrans.addChild(createBillboard("POINT - 10,0,0", new Point3f(40.0f, 00.0f, 0.0f), Billboard.ROTATE_ABOUT_POINT, new Point3f(10.0f, 0.0f, 0.0f), bounds)); objTrans.addChild(new ColorCube(20.0)); objRoot.addChild(objTrans); return objRoot; }
From source file:Text3DTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 4000, 0, 0, 0); TornadoRotation rotator = new TornadoRotation(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator);/*from www . ja v a 2 s .c o m*/ objTrans.addChild(createText3D(rotator, "setString", 1, 10.0f, 6.0f, Text3D.PATH_RIGHT)); objRoot.addChild(objTrans); return objRoot; }
From source file:CompileTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); // do NOT auto compute bounds for this node objRoot.setBoundsAutoCompute(false); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); 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); rotator.setSchedulingBounds(createApplicationBounds()); objTrans.addChild(rotator);//from www . j a v a 2 s . com objTrans.addChild(createColorCubes()); objRoot.addChild(objTrans); return objRoot; }
From source file:ModelClipTest.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // 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 w w w . j a va 2 s .co m*/ objScale.setTransform(t3d); objRoot.addChild(objScale); // This Transformgroup is used by the mouse manipulators to // move the CYlinder. TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objScale.addChild(objTrans); //Create Model Clip ModelClip mc = new ModelClip(); boolean enables[] = { false, false, false, false, false, false }; Vector4d eqn1 = new Vector4d(0.0, 1.0, 0.0, 0.0); Vector4d eqn2 = new Vector4d(1.0, 1.0, 0.0, 0.0); mc.setEnables(enables); mc.setPlane(1, eqn1); mc.setPlane(2, eqn2); mc.setEnable(1, true); mc.setEnable(2, true); mc.setInfluencingBounds(bounds); objTrans.addChild(mc); //Create a cylinder PolygonAttributes attr = new PolygonAttributes(); attr.setCullFace(PolygonAttributes.CULL_NONE); Appearance ap = new Appearance(); Material mat = new Material(); mat.setLightingEnable(true); ap.setMaterial(mat); ap.setPolygonAttributes(attr); Cylinder CylinderObj = new Cylinder(1.0f, 2.0f, ap); objTrans.addChild(CylinderObj); // Create the rotate behavior node MouseRotate behavior = new MouseRotate(objTrans); objTrans.addChild(behavior); behavior.setSchedulingBounds(bounds); // Create the zoom behavior node MouseZoom behavior2 = new MouseZoom(objTrans); objTrans.addChild(behavior2); behavior2.setSchedulingBounds(bounds); //Shine it with two colored lights. Color3f lColor1 = new Color3f(0.5f, 0.0f, 0.5f); Color3f lColor2 = new Color3f(0.7f, 0.7f, 0.0f); Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, 1.0f); Vector3f lDir2 = new Vector3f(0.0f, 0.0f, -1.0f); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); DirectionalLight lgt2 = new DirectionalLight(lColor2, lDir2); lgt1.setInfluencingBounds(bounds); lgt2.setInfluencingBounds(bounds); objScale.addChild(lgt1); objScale.addChild(lgt2); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:PointTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 14000, 0, 0, 0, 0, 0); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(getApplicationBounds()); objTrans.addChild(rotator);/*from ww w . java2s .c o m*/ Switch switchGroup = new Switch(); switchGroup.setCapability(Switch.ALLOW_SWITCH_WRITE); switchGroup.addChild(createPoints(1, 5, false)); switchGroup.addChild(createPoints(1, 5, true)); switchGroup.addChild(createPoints(8, 10, false)); switchGroup.addChild(createPoints(8, 10, true)); switchGroup.addChild(createPoints(2, 5, false)); switchGroup.addChild(createPoints(2, 5, true)); switchGroup.addChild(createPoints(2, 20, false)); switchGroup.addChild(createPoints(2, 20, true)); // create a SwitchValueInterpolator to // cycle through the child nodes in the Switch Node Alpha switchAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 15000, 0, 0, 0, 0, 0); SwitchValueInterpolator switchInterpolator = new SwitchValueInterpolator(switchAlpha, switchGroup); switchInterpolator.setSchedulingBounds(getApplicationBounds()); switchInterpolator.setEnable(true); // WARNING: do not add the SwitchValueInterpolator to the Switch Node! objRoot.addChild(switchInterpolator); objTrans.addChild(switchGroup); objRoot.addChild(objTrans); return objRoot; }
From source file:TextureTransformTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); Transform3D yAxis = new Transform3D(); Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); // create the rotation interpolator to rotate the scene RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); rotator.setSchedulingBounds(createApplicationBounds()); objTrans.addChild(rotator);/* w ww . ja va 2s . c o m*/ // create the box final int nScale = 50; Appearance app = new Appearance(); Box box = new Box(nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, app); // load the texture image TextureLoader texLoader = new TextureLoader("texture.gif", this); app.setTexture(texLoader.getTexture()); // set the texture attributes and ensure we // can write to the Transform for the texture attributes m_TextureAttributes = new TextureAttributes(); m_TextureAttributes.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE); app.setTextureAttributes(m_TextureAttributes); // connect all the elements objTrans.addChild(box); objRoot.addChild(objTrans); objRoot.addChild(createRotator()); return objRoot; }
From source file:TextureTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // add an Interpolator to rotate the scene objTrans.addChild(createInterpolator(objTrans)); // process the texture input files and add the geometry objTrans.addChild(createTextureGroup("ann.txt", -5, -5, -3, false)); objTrans.addChild(createTextureGroup("daniel.txt", -5, 5, 3, false)); objTrans.addChild(createTextureGroup("ann.txt", 5, 5, 3, false)); objTrans.addChild(createTextureGroup("daniel.txt", 5, -5, -3, false)); objRoot.addChild(objTrans);/*from w ww . j av a 2s. c o m*/ return objRoot; }
From source file:MixedTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); 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); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator);/* ww w . jav a2 s. c o m*/ objTrans.addChild(new ColorCube()); objRoot.addChild(objTrans); return objRoot; }
From source file:ObjLoad.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.7);/* w w w . j av a 2s . c o 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); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objScale.addChild(objTrans); int flags = ObjectFile.RESIZE; if (!noTriangulate) flags |= ObjectFile.TRIANGULATE; if (!noStripify) flags |= ObjectFile.STRIPIFY; ObjectFile f = new ObjectFile(flags, (float) (creaseAngle * Math.PI / 180.0)); Scene s = null; try { s = f.load(filename); } catch (FileNotFoundException e) { System.err.println(e); System.exit(1); } catch (ParsingErrorException e) { System.err.println(e); System.exit(1); } catch (IncorrectFormatException e) { System.err.println(e); System.exit(1); } objTrans.addChild(s.getSceneGroup()); bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); if (spin) { 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); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator); } // Set up the background Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f); Background bgNode = new Background(bgColor); bgNode.setApplicationBounds(bounds); objRoot.addChild(bgNode); return objRoot; }