List of usage examples for javax.media.j3d TransformGroup ALLOW_TRANSFORM_WRITE
int ALLOW_TRANSFORM_WRITE
To view the source code for javax.media.j3d TransformGroup ALLOW_TRANSFORM_WRITE.
Click Source Link
From source file:AWTInteraction.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. objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);/*from ww w .j a va 2 s . co m*/ // Create a simple shape leaf node, add it to the scene graph. objTrans.addChild(new ColorCube(0.4)); // create the AWTInteractionBehavior AWTInteractionBehavior awtBehavior = new AWTInteractionBehavior(objTrans); rotateB.addActionListener(awtBehavior); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); awtBehavior.setSchedulingBounds(bounds); objRoot.addChild(awtBehavior); 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 w w . ja va2s . 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);/*www. j a v a 2 s.c om*/ 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 va 2 s .c o m objTrans.addChild(createColorCubes()); objRoot.addChild(objTrans); return objRoot; }
From source file:SimpleBehaviorApp.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objRotate = new TransformGroup(); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objRotate);/*from www.ja v a 2s . c o m*/ objRotate.addChild(new ColorCube(0.4)); SimpleBehavior myRotationBehavior = new SimpleBehavior(objRotate); myRotationBehavior.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myRotationBehavior); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); 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 ww w . ja v a 2 s . com*/ 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);// w w w . ja v a 2 s .c om 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 w w . j a v a2s . 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:ReadRaster.java
public BranchGroup createSceneGraph(BufferedImage bImage, Raster readRaster) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // Create a Raster shape. Add it to the root of the subgraph ImageComponent2D drawImageComponent = new ImageComponent2D(ImageComponent.FORMAT_RGB, bImage); Raster drawRaster = new Raster(new Point3f(0.0f, 0.0f, 0.0f), Raster.RASTER_COLOR, 0, 0, bImage.getWidth(), bImage.getHeight(), drawImageComponent, null); Shape3D shape = new Shape3D(drawRaster); drawRaster.setCapability(Raster.ALLOW_IMAGE_WRITE); objRoot.addChild(shape);/*from w w w .j a va 2 s. c o m*/ // Ceate the transform greup 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); TransformGroup cubeScale = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(-0.5, 0.5, 0.0)); cubeScale.setTransform(t3d); cubeScale.addChild(objTrans); objRoot.addChild(cubeScale); // Create a simple shape leaf node, add it to the scene graph. objTrans.addChild(new ColorCube(0.3)); // 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); myRotationInterpolator rotator = new myRotationInterpolator(drawRaster, readRaster, 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:Text2DTest.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 w w w. j a v a 2 s. c om 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); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); TransformGroup textTranslationGroup; Transform3D textTranslation; float yPos = -.5f; Shape3D textObject = new Text2D("Rotating Yellow Text", new Color3f(1f, 1f, 0f), "Serif", 60, Font.BOLD); Appearance app = textObject.getAppearance(); PolygonAttributes pa = app.getPolygonAttributes(); if (pa == null) pa = new PolygonAttributes(); pa.setCullFace(PolygonAttributes.CULL_NONE); if (app.getPolygonAttributes() == null) app.setPolygonAttributes(pa); objTrans.addChild(textObject); textTranslation = new Transform3D(); textTranslation.setTranslation(new Vector3f(0f, yPos, 0f)); textTranslationGroup = new TransformGroup(textTranslation); textTranslationGroup.addChild(objTrans); objScale.addChild(textTranslationGroup); yPos += .5f; /* Blue 40point text */ textObject = new Text2D("Blue 40point Text", new Color3f(0f, 0f, 1f), "Serif", 40, Font.BOLD); textTranslation = new Transform3D(); textTranslation.setTranslation(new Vector3f(0f, yPos, 0f)); textTranslationGroup = new TransformGroup(textTranslation); textTranslationGroup.addChild(textObject); objScale.addChild(textTranslationGroup); yPos += .5f; /* Green italic text */ textObject = new Text2D("Green Italic Text", new Color3f(0f, 1f, 0f), "Serif", 70, Font.ITALIC); textTranslation = new Transform3D(); textTranslation.setTranslation(new Vector3f(0f, yPos, 0f)); textTranslationGroup = new TransformGroup(textTranslation); textTranslationGroup.addChild(textObject); objScale.addChild(textTranslationGroup); yPos += .5f; // 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); rotator.setSchedulingBounds(bounds); objTrans.addChild(rotator); return objRoot; }