import java.awt.*;
import java.awt.event.*;

import javax.media.j3d.*;
import com.sun.j3d.utils.geometry.ColorCube;
import javax.media.j3d.Background;import javax.vecmath.Vector3f;
public class Shape2 extends Frame {
                public static void main(String argv[]){
                new Shape2();
                }
                public Shape2(){                super("Java 3D
Experiment");           setSize(600,400);               Canvas3D
myCanvas=new Canvas3D(null);            add("Center",myCanvas);
setVisible(true);               addWindowListener(new WindowAdapter()
      {public void windowClosing(WindowEvent e)
         {dispose(); System.exit(0);}
      }
    );
                View myView = constructView(myCanvas);

                Locale myLocale = constructViewBranch(myView);

                constructContentBranch(myLocale);

                show(); }       private View constructView(Canvas3D
myCanvas3D) {

    View myView = new View();

    myView.addCanvas3D(myCanvas3D);

    myView.setPhysicalBody(new PhysicalBody());

    myView.setPhysicalEnvironment(new PhysicalEnvironment());

    return(myView);

  }
 private Locale constructViewBranch(View myView) {

    VirtualUniverse myUniverse = new VirtualUniverse();

    Locale myLocale = new Locale(myUniverse);

    BranchGroup myBranchGroup = new BranchGroup();

    TransformGroup myTransformGroup = new TransformGroup();

    ViewPlatform myViewPlatform = new ViewPlatform();

    myTransformGroup.addChild(myViewPlatform);

    myBranchGroup.addChild(myTransformGroup);

    myLocale.addBranchGraph(myBranchGroup);

    myView.attachViewPlatform(myViewPlatform);

    return(myLocale);

  }
  private void constructContentBranch(Locale myLocale) {
           Transform3D t=new Transform3D();

   t.set (new Vector3f(0.0f,0.0f,0.0f));

   t.setScale(0.10);
      TransformGroup myGroup=new TransformGroup(t);
          BoundingBox bounds = new BoundingBox();

   BoundingLeaf boundingLeaf = new BoundingLeaf(bounds);

   boundingLeaf.setCapability(BoundingLeaf.ALLOW_REGION_READ);

   boundingLeaf.setCapability(BoundingLeaf.ALLOW_REGION_WRITE);

   myGroup.addChild(boundingLeaf);

   myGroup.setBoundsAutoCompute(true);

   ColorCube myCube=new ColorCube();

   myGroup.addChild(myCube);

   Background backGround=new Background();

   backGround.setColor(1.0f,0.8f,1.0f);
           BranchGroup myBranch=new BranchGroup();
   myBranch.addChild(myGroup);      myBranch.addChild(backGround);

   myBranch.compile( );
   myLocale.addBranchGraph(myBranch);      }


}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to