List of usage examples for javax.media.j3d TransformGroup addChild
public void addChild(Node child)
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);/* w ww . j av a 2 s . c o 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:Erscheinungsbild.java
/** * Erstellt den Szenegraphen/*from www . j av a2 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); objDreh.addChild(new Box(0.5f, 0.5f, 0.5f, makeAppearance())); objWurzel.addChild(objDreh); return objWurzel; }
From source file:TextureMapping.java
/** * Erstellt den Szenegraphen/*from w w w . j av a 2 s.com*/ * * @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); objDreh.addChild(new Box(0.5f, 0.5f, 0.5f, Box.GENERATE_TEXTURE_COORDS, makeAppearance())); objWurzel.addChild(objDreh); return objWurzel; }
From source file:HelloJava3Db.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // rotate object has composited transformation matrix Transform3D rotate = new Transform3D(); Transform3D tempRotate = new Transform3D(); rotate.rotX(Math.PI / 4.0d);// www . j a va 2s . c om tempRotate.rotY(Math.PI / 5.0d); rotate.mul(tempRotate); TransformGroup objRotate = new TransformGroup(rotate); 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:HelloJava3Dbalt.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); // rotate object has composited transformation matrix Transform3D rotate = new Transform3D(); Transform3D tempRotate = new Transform3D(); rotate.rotX(Math.PI / 4.0d);/*ww w . j ava 2 s. co m*/ tempRotate.rotY(Math.PI / 5.0d); tempRotate.mul(rotate); TransformGroup objRotate = new TransformGroup(tempRotate); 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:Rotation.java
/** * Erstellt den Szenegraphen/*from www .jav a2 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:SimpleCone.java
/** * This builds the content branch of our scene graph. It uses the buildShape * function to create the actual shape, adding to to the transform group so * that the shape is slightly tilted to reveal its 3D shape. * /*from w w w . ja v a2 s. c o m*/ * @param shape * Node that represents the geometry for the content * @return BranchGroup that is the root of the content branch */ protected BranchGroup buildContentBranch() { BranchGroup contentBranch = new BranchGroup(); Transform3D rotateCube = new Transform3D(); rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0)); TransformGroup rotationGroup = new TransformGroup(rotateCube); contentBranch.addChild(rotationGroup); rotationGroup.addChild(new Cone(1.0f, 2.0f, 0, new Appearance())); return contentBranch; }
From source file:SimpleWire.java
/** * This builds the content branch of our scene graph. It uses the buildCube * function to create the actual shape, adding to to the transform group so * that the shape is slightly tilted to reveal its 3D shape. * /*from ww w . ja va 2 s .c o m*/ * @param shape * Node that represents the geometry for the content * @return BranchGroup that is the root of the content branch */ protected BranchGroup buildContentBranch(Node shape) { BranchGroup contentBranch = new BranchGroup(); Transform3D rotateCube = new Transform3D(); rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0)); TransformGroup rotationGroup = new TransformGroup(rotateCube); contentBranch.addChild(rotationGroup); rotationGroup.addChild(shape); return contentBranch; }
From source file:BasicConstruct.java
/** * Adds a box to the universe// ww w .j a v a 2s .c o m * * @param x * The x dimension of the box * @param y * The y dimension of the box * @param z * The z dimension of the box */ public void addBox(float x, float y, float z, Color3f diffuse, Color3f spec) { // Add a box with the given dimension // First setup an appearance for the box Appearance app = new Appearance(); Material mat = new Material(); mat.setDiffuseColor(diffuse); mat.setSpecularColor(spec); mat.setShininess(5.0f); app.setMaterial(mat); Box box = new Box(x, y, z, app); // Create a TransformGroup and make it the parent of the box TransformGroup tg = new TransformGroup(); tg.addChild(box); // Then add it to the rootBranchGroup rootBranchGroup.addChild(tg); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); MouseRotate myMouseRotate = new MouseRotate(); myMouseRotate.setTransformGroup(tg); myMouseRotate.setSchedulingBounds(new BoundingSphere()); rootBranchGroup.addChild(myMouseRotate); MouseTranslate myMouseTranslate = new MouseTranslate(); myMouseTranslate.setTransformGroup(tg); myMouseTranslate.setSchedulingBounds(new BoundingSphere()); rootBranchGroup.addChild(myMouseTranslate); MouseZoom myMouseZoom = new MouseZoom(); myMouseZoom.setTransformGroup(tg); myMouseZoom.setSchedulingBounds(new BoundingSphere()); rootBranchGroup.addChild(myMouseZoom); }
From source file:SimpleCylinder.java
/** * This builds the content branch of our scene graph. It uses the Cylinder * utility class to create the actual shape, adding to to the transform * group so that the shape is slightly tilted to reveal its 3D shape. * /*from w ww. j a v a 2s .c o m*/ * @param shape * Node that represents the geometry for the content * @return BranchGroup that is the root of the content branch */ protected BranchGroup buildContentBranch() { BranchGroup contentBranch = new BranchGroup(); Transform3D rotateCube = new Transform3D(); rotateCube.set(new AxisAngle4d(1.0, 1.0, 0.0, Math.PI / 4.0)); TransformGroup rotationGroup = new TransformGroup(rotateCube); contentBranch.addChild(rotationGroup); //Create the shape and add it to the branch rotationGroup.addChild(new Cylinder(1.0f, 1.0f, new Appearance())); return contentBranch; }