List of usage examples for javax.media.j3d PhysicalEnvironment PhysicalEnvironment
public PhysicalEnvironment()
From source file:SimpleMouse.java
/** * Build the view branch of the scene graph * // w w w . java 2 s. c o 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); ViewPlatform myViewPlatform = new ViewPlatform(); 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); return viewBranch; }
From source file:SimpleIndexedQuadSmooth.java
/** * This function builds the view branch of the scene graph. It creates a * branch group and then creates the necessary view elements to give a * useful view of our content./*from w w w . j a va 2 s.c o m*/ * * @param c * Canvas3D that will display the view * @return BranchGroup that is the root of the view elements */ protected BranchGroup buildViewBranch(Canvas3D c) { BranchGroup viewBranch = new BranchGroup(); Transform3D viewXfm = new Transform3D(); viewXfm.set(new Vector3f(0.0f, 0.0f, 5.0f)); TransformGroup viewXfmGroup = new TransformGroup(viewXfm); ViewPlatform myViewPlatform = new ViewPlatform(); 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); return viewBranch; }
From source file:SimpleCombine.java
/** * This function builds the view branch of the scene graph. It creates a * branch group and then creates the necessary view elements to give a * useful view of our content.// w w w .j av a2 s . c o m * * @param c * Canvas3D that will display the view * @return BranchGroup that is the root of the view elements */ protected BranchGroup buildViewBranch(Canvas3D c) { BranchGroup viewBranch = new BranchGroup(); Transform3D viewXfm = new Transform3D(); viewXfm.set(new Vector3f(0.0f, 0.0f, 7.0f)); TransformGroup viewXfmGroup = new TransformGroup(viewXfm); ViewPlatform myViewPlatform = new ViewPlatform(); 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); return viewBranch; }
From source file:SimpleWorld.java
/** * This function builds the view branch of the scene graph. It creates a * branch group and then creates the necessary view elements to give a * useful view of our content.//from w w w . ja v a 2 s . c o m * * @param c * Canvas3D that will display the view * @return BranchGroup that is the root of the view elements */ protected BranchGroup buildViewBranch(Canvas3D c) { //This is the root of our view branch BranchGroup viewBranch = new BranchGroup(); //The transform that will move our view //back 5 units along the z-axis Transform3D viewXfm = new Transform3D(); viewXfm.set(new Vector3f(0.0f, 0.0f, 5.0f)); //The transform group that will be the parent //of our view platform elements TransformGroup viewXfmGroup = new TransformGroup(viewXfm); ViewPlatform myViewPlatform = new ViewPlatform(); //Next the physical elements are created PhysicalBody myBody = new PhysicalBody(); PhysicalEnvironment myEnvironment = new PhysicalEnvironment(); //Then we put it all together viewXfmGroup.addChild(myViewPlatform); viewBranch.addChild(viewXfmGroup); View myView = new View(); myView.addCanvas3D(c); myView.attachViewPlatform(myViewPlatform); myView.setPhysicalBody(myBody); myView.setPhysicalEnvironment(myEnvironment); return viewBranch; }
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 w ww. jav a2 s. c om * @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:SimpleSounds.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 w ww .j ava 2 s . c o 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, 30.0f)); TransformGroup viewXfmGroup = new TransformGroup(viewXfm); viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); viewXfmGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); ViewPlatform myViewPlatform = new ViewPlatform(); BoundingSphere movingBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); BoundingLeaf boundLeaf = new BoundingLeaf(movingBounds); 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); //Create a sounds mixer to use our sounds with //and initialise it JavaSoundMixer myMixer = new JavaSoundMixer(myEnvironment); myMixer.initialize(); return viewBranch; }
From source file:SimpleGame.java
/** * This builds the view branch of the scene graph. * /* ww w .java2s. com*/ * @return BranchGroup with viewing objects attached. */ protected BranchGroup buildViewBranch(Canvas3D c) { BranchGroup viewBranch = new BranchGroup(); Transform3D viewXfm = new Transform3D(); Matrix3d viewTilt = new Matrix3d(); viewTilt.rotX(Math.PI / -6); viewXfm.set(viewTilt, new Vector3d(0.0, 10.0, 10.0), 1.0); TransformGroup viewXfmGroup = new TransformGroup(viewXfm); ViewPlatform myViewPlatform = new ViewPlatform(); 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); return viewBranch; }
From source file:J3dSwingFrame.java
public Camera() { hud_group = new Group(); hud_group.setCapability(Group.ALLOW_CHILDREN_EXTEND); platform = new ViewPlatform(); location = new Transform3D(); root_tx_grp = new TransformGroup(); root_tx_grp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); root_tx_grp.setTransform(location);/*www. ja v a 2 s . c om*/ root_tx_grp.addChild(platform); root_tx_grp.addChild(hud_group); // now create the headlight headlight = new DirectionalLight(); headlight.setCapability(Light.ALLOW_STATE_WRITE); headlight.setColor(White); headlight.setInfluencingBounds(LIGHT_BOUNDS); root_tx_grp.addChild(headlight); body = new PhysicalBody(); env = new PhysicalEnvironment(); view = new View(); view.setBackClipDistance(BACK_CLIP_DISTANCE); view.setPhysicalBody(body); view.setPhysicalEnvironment(env); view.attachViewPlatform(platform); }
From source file:Demo3D.java
/** * Create the ViewBranch// w w w . j a va2 s . co m * * @return javax.media.j3d.BranchGroup vbBrGr - the root of the ViewBranch */ public BranchGroup myViewBranch() { // Create the minimal PhysicalBody and PhysicalEnvironnement // instances with default parameters. body = new PhysicalBody(); environment = new PhysicalEnvironment(); // Create a View instance and attach the Canvas3D, the PhysicalBody // and the PhysicalEnvironment to it. view = new View(); view.setFrontClipDistance(0.02); // Default value is 0.1 m view.setBackClipDistance(40.0); // Default value is 10 m // Rem.: BackClipDistance / FrontClipDistance = 2000 > 1000 but < 3000 view.addCanvas3D(canvas3D); view.setPhysicalBody(body); view.setPhysicalEnvironment(environment); /* * // Choices of the projection type. They are 2 possibilities, namely: // * PERSPECTIVE_PROJECTION and PARALLEL_PROJECTION. // Note: the default * value is PERSPECTIVE_PROJECTION * view.setProjectionPolicy(View.PARALLEL_PROJECTION); */ // Create a ViewPlatform instance and bind it with the View instance. viewPlat = new ViewPlatform(); viewPlat.setActivationRadius(40.0f); // Default value is 62 m view.attachViewPlatform(viewPlat); // Create the action volume for the camera's navigation. cameraBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); // Create the two necessary TransformGroups for the ViewPlatform's // motion (6 translations and 4 rotations). vpTrGrKeys_Rot_Up_Down = new TransformGroup(); vpTrGrKeys_Transl_Turn = new TransformGroup(); // With the ALLOW_TRANSFORM_READ and ALLOW_TRANSFORM_WRITE // capabilities, we allow the modification of the TransformGroup's // code by the Behavior's code at run time. vpTrGrKeys_Transl_Turn.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); vpTrGrKeys_Transl_Turn.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); vpTrGrKeys_Rot_Up_Down.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); vpTrGrKeys_Rot_Up_Down.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); // Attach the ViewPlatform to the vpTrGrKeys_Rot_Up_Down node. vpTrGrKeys_Rot_Up_Down.addChild(viewPlat); // Create and attach an aimer to the TransformGroup node // vpTrGrKeys_Rot_Up_Down. aimer = new Aimer(1.5f); vpTrGrKeys_Rot_Up_Down.addChild(aimer.myAimer()); // View-platform's motion ==> camera's navigation: 6 translations and 4 // rotations. // Create and attach the camera's rotation on the vpTrGrKeys_Rot_Up_Down // node. camera_Rot_Up_Down = new Camera_Rot_Up_Down(vpTrGrKeys_Rot_Up_Down); camera_Rot_Up_Down.setSchedulingBounds(cameraBounds); vpTrGrKeys_Rot_Up_Down.addChild(camera_Rot_Up_Down); // Create and attach the camera's translation and rotation instances // on the vpTrGrKeys_Transl_Turn node. camera_Transl_Turn = new Camera_Transl_Turn(vpTrGrKeys_Transl_Turn); camera_Transl_Turn.setSchedulingBounds(cameraBounds); vpTrGrKeys_Transl_Turn.addChild(camera_Transl_Turn); // Attach the vpTrGrKeys_Rot_Up_Down node to the vpTrGrKeys_Transl_Turn // node. vpTrGrKeys_Transl_Turn.addChild(vpTrGrKeys_Rot_Up_Down); // Give the starting position of the ViewPlatform. trStart = new Transform3D(); // Identity matrix trStart.set(new Vector3f(0.0f, 0.0f, 10.0f)); // Translation of the // camera (0,0,10) // Create the TransformGroup node for the ViewPlatform's // starting position. vpTrGrStart = new TransformGroup(trStart); // Attach the vpTrGrKeys_Transl_Turn node to the TransformGroup // node vpTrGrStart. vpTrGrStart.addChild(vpTrGrKeys_Transl_Turn); // Add the TransformGroup node vpTrGrStart to the view // BranchGroup node vbBrGr. vbBrGr = new BranchGroup(); vbBrGr.addChild(vpTrGrStart); // Compile the ViewBranch to optimize the performances. vbBrGr.compile(); // Return the final version of the view branch BranchGroup node vbBrGr. return vbBrGr; }
From source file:SwingTest.java
/** * Creates the PhysicalEnvironment for the View */ protected PhysicalEnvironment createPhysicalEnvironment() { return new PhysicalEnvironment(); }