List of usage examples for javax.media.j3d Transform3D set
public final void set(Matrix3d m1, Vector3d t1, double s)
From source file:SimpleGame.java
/** * This builds the view branch of the scene graph. * /* ww w. j a v a2 s . co m*/ * @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:SimpleGame.java
/** * Creates the duck. This loads the two duck geometries from the files * 'duck.obj' and 'deadduck.obj' and loads these into a switch. The access * rights to the switch are then set so we can write to this switch to swap * between the two duck models. It also creates a transform group and an * interpolator to move the duck.// w w w. ja v a 2s. c o m * * @return BranchGroup with content attached. */ protected BranchGroup buildDuck() { BranchGroup theDuck = new BranchGroup(); duckSwitch = new Switch(0); duckSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE); ObjectFile f1 = new ObjectFile(); ObjectFile f2 = new ObjectFile(); Scene s1 = null; Scene s2 = null; try { s1 = f1.load("duck.obj"); s2 = f2.load("deadduck.obj"); } catch (Exception e) { System.exit(1); } TransformGroup duckRotXfmGrp = new TransformGroup(); Transform3D duckRotXfm = new Transform3D(); Matrix3d duckRotMat = new Matrix3d(); duckRotMat.rotY(Math.PI / 2); duckRotXfm.set(duckRotMat, new Vector3d(0.0, 0.0, -30.0), 1.0); duckRotXfmGrp.setTransform(duckRotXfm); duckRotXfmGrp.addChild(duckSwitch); duckSwitch.addChild(s1.getSceneGroup()); duckSwitch.addChild(s2.getSceneGroup()); TransformGroup duckMovXfmGrp = new TransformGroup(); duckMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); duckMovXfmGrp.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); duckMovXfmGrp.addChild(duckRotXfmGrp); duckAlpha = new Alpha(-1, 0, 0, 3000, 0, 0); Transform3D axis = new Transform3D(); PositionInterpolator moveDuck = new PositionInterpolator(duckAlpha, duckMovXfmGrp, axis, -30.0f, 30.0f); moveDuck.setSchedulingBounds(bounds); theDuck.addChild(moveDuck); theDuck.addChild(duckMovXfmGrp); return theDuck; }