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: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 ww w. 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:Rotation.java
/** * Erstellt den Szenegraphen// ww w .j a v 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:SimpleLOD.java
/** * Build the view branch of the scene graph. In this case a key navigation * utility object is created and associated with the view transform so that * the view can be changed via the keyboard. * //from ww w . j a va2 s .co m * @return BranchGroup that is the root of the view branch */ protected BranchGroup buildViewBranch(Canvas3D c) { BranchGroup viewBranch = new BranchGroup(); Transform3D viewXfm = new Transform3D(); viewXfm.set(new Vector3f(0.0f, 0.0f, 10.0f)); TransformGroup viewXfmGroup = new TransformGroup(viewXfm); viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); BoundingLeaf boundLeaf = new BoundingLeaf(movingBounds); ViewPlatform myViewPlatform = new ViewPlatform(); viewXfmGroup.addChild(boundLeaf); PhysicalBody myBody = new PhysicalBody(); PhysicalEnvironment myEnvironment = new PhysicalEnvironment(); viewXfmGroup.addChild(myViewPlatform); viewBranch.addChild(viewXfmGroup); View myView = new View(); myView.addCanvas3D(c); myView.attachViewPlatform(myViewPlatform); myView.setPhysicalBody(myBody); myView.setPhysicalEnvironment(myEnvironment); KeyNavigatorBehavior keyNav = new KeyNavigatorBehavior(viewXfmGroup); keyNav.setSchedulingBounds(movingBounds); viewBranch.addChild(keyNav); return viewBranch; }
From source file:BouncingBall.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objRoot.addChild(objTrans);/* w w w. ja v a2 s.co m*/ // Create a simple shape leaf node, add it to the scene graph. Sphere sphere = new Sphere(0.25f); objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D pos1 = new Transform3D(); pos1.setTranslation(new Vector3f(0.0f, 0.0f, 0.0f)); objTrans.setTransform(pos1); objTrans.addChild(sphere); objRoot.addChild(objTrans); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); Color3f light1Color = new Color3f(1.0f, 0.0f, 0.2f); Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f); DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction); light1.setInfluencingBounds(bounds); objRoot.addChild(light1); // Set up the ambient light Color3f ambientColor = new Color3f(1.0f, 1.0f, 1.0f); AmbientLight ambientLightNode = new AmbientLight(ambientColor); ambientLightNode.setInfluencingBounds(bounds); objRoot.addChild(ambientLightNode); return objRoot; }
From source file:MouseBehaviorApp.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objTransform = new TransformGroup(); objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objTransform);/*w w w . j a va 2s .co m*/ objTransform.addChild(new ColorCube(0.4)); objRoot.addChild(new Axis()); MouseRotate myMouseRotate = new MouseRotate(); myMouseRotate.setTransformGroup(objTransform); myMouseRotate.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myMouseRotate); MouseTranslate myMouseTranslate = new MouseTranslate(); myMouseTranslate.setTransformGroup(objTransform); myMouseTranslate.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myMouseTranslate); MouseZoom myMouseZoom = new MouseZoom(); myMouseZoom.setTransformGroup(objTransform); myMouseZoom.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(myMouseZoom); // 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 www. java2 s . c om*/ // 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:StereoCube.java
public BranchGroup createSceneGraph(int i) { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objTrans = new TransformGroup(); 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);/*from ww w .j a v a 2s .co m*/ tg.addChild(new ColorCube(0.4)); MouseRotate behavior = new MouseRotate(); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); 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); return objRoot; }
From source file:MouseRotateApp.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); objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); objRoot.addChild(objRotate);/* w w w.j a va 2s .c o m*/ objRotate.addChild(new ColorCube(0.4)); objRoot.addChild(new Axis()); MouseRotate 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:MouseRotate2App.java
public BranchGroup createSceneGraph() { // Create the root of the branch graph BranchGroup objRoot = new BranchGroup(); TransformGroup objRotate = null;//w ww .j a va2s. 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: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. j a va 2s.com*/ 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; }