List of usage examples for javax.media.j3d RotationInterpolator setSchedulingBounds
public void setSchedulingBounds(Bounds region)
From source file:HelloWorld.java
private static BranchGroup createSceneGraph() { // Make a scene graph branch BranchGroup branch = new BranchGroup(); // Make a changeable 3D transform TransformGroup trans = new TransformGroup(); trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); branch.addChild(trans);//from w ww .ja va 2s. co m // Make a shape ColorCube demo = new ColorCube(0.4); trans.addChild(demo); // Make a behavor to spin the shape Alpha spinAlpha = new Alpha(-1, 4000); RotationInterpolator spinner = new RotationInterpolator(spinAlpha, trans); spinner.setSchedulingBounds(new BoundingSphere(new Point3d(), 1000.0)); trans.addChild(spinner); return branch; }
From source file:Rotation.java
/** * Erstellt den Szenegraphen// w w w . j a va 2 s . c o m * * @return BranchGroup */ public BranchGroup macheSzene() { BranchGroup objWurzel = new BranchGroup(); // Transformation, 2 Rotationen: Transform3D drehung = new Transform3D(); Transform3D drehung2 = new Transform3D(); drehung.rotX(Math.PI / 4.0d); drehung2.rotY(Math.PI / 5.0d); drehung.mul(drehung2); TransformGroup objDreh = new TransformGroup(drehung); TransformGroup spin = new TransformGroup(); spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); spin.addChild(new ColorCube(0.4)); objDreh.addChild(spin); objWurzel.addChild(objDreh); // Drehung Alpha spinAlpha = new Alpha(-1, 5000); RotationInterpolator dreher = new RotationInterpolator(spinAlpha, spin); BoundingSphere zone = new BoundingSphere(); dreher.setSchedulingBounds(zone); spin.addChild(dreher); return objWurzel; }
From source file:ConeYoyoApp.java
public BranchGroup createSceneGraph() { 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 objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin);/*from w w w .ja v a 2s .co m*/ objSpin.addChild(new ConeYoyo().getBG()); // 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); objSpin.addChild(rotator); // 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);/*from w ww. j a v a2 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:YoyoPointApp.java
public BranchGroup createSceneGraph() { 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 objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin);/*from w ww . ja v a 2 s . c om*/ objSpin.addChild(new Yoyo()); // 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); objSpin.addChild(rotator); // Let Java 3D perform optimizations on this scene graph. objRoot.compile(); return objRoot; }
From source file:HelloJava3Dc.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. Add it to the root of the subgraph. TransformGroup objSpin = new TransformGroup(); objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objSpin);//from w ww .j a v a 2 s . c o m // Create a simple shape leaf node, add it to the scene graph. // ColorCube is a Convenience Utility class objSpin.addChild(new ColorCube(0.4)); // Create a new Behavior object that will perform the desired // operation on the specified transform object and add it into // the scene graph. Alpha rotationAlpha = new Alpha(-1, 4000); RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objSpin); // a bounding sphere specifies a region a behavior is active // create a sphere centered at the origin with radius of 100 BoundingSphere bounds = new BoundingSphere(); rotator.setSchedulingBounds(bounds); objSpin.addChild(rotator); 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);/*from ww w. j a va 2 s .c o m*/ 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: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);// ww w .ja v a 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: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 w w w . j av a 2s.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); 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: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 www . jav a 2s . com 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; }