Construct the View Branch (2)
/**
* 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.
* @param c Canvas3D that will display the view
* @return BranchGroup that is the root of the view elements
*/
protected BranchGroup myCreateViewBranch(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);
viewTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// Deafult View and ViewPlateform
ViewPlatform myViewPlatform = new ViewPlatform();
View myView = new View();
//Next the physical elements are created
PhysicalBody myBody = new PhysicalBody();
PhysicalEnvironment myEnvironment = new PhysicalEnvironment();
//Then we put it all together
myView.addCanvas3D(c);
myView.setPhysicalBody(myBody);
myView.setPhysicalEnvironment(myEnvironment);
myView.attachViewPlatform(myViewPlatform);
viewXfmGroup.addChild(myViewPlatform);
viewBranch.addChild(viewXfmGroup);
return viewBranch;
}