
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.*;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import java.net.URL;
import java.util.Enumeration;




public class pit extends Applet {

        gsTimer gt;     


        

   public BranchGroup createSceneGraph() {

                // Put a cube in the world
        BranchGroup objRoot = new BranchGroup();
        Transform3D tt = new Transform3D();
        Vector3d vv = new Vector3d(0.01, 0.2 ,0.01);
        TransformGroup objTrans = new TransformGroup();
        objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRoot.addChild(objTrans);
        objTrans.addChild(new ColorCube(0.5));
        tt.setTranslation(vv);
        objTrans.setTransform(tt);

        // Create a new gsTimer & pass it some data, i.e. the object we want to move
        gt = new gsTimer(objTrans);

        // A bounding sphere to set the behaviour running
        BoundingSphere myBounds =
            new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
        gt.setSchedulingBounds(myBounds);

        // add the timer to the tree
        objTrans.addChild(gt);

        return objRoot;
   }


// ---------------------------------------------------
//      IGNORE THE CODE BELOW THIS LINE
// ---------------------------------------------------


    public pit() {

        setLayout(new FlowLayout());            // of AWT panel
        GraphicsConfiguration config =        // For H/W drawing
        SimpleUniverse.getPreferredConfiguration();


        BranchGroup scene = createSceneGraph();       // Build up the sceneGraph

        
        Canvas3D c1 = new Canvas3D(config);
        TransformGroup ot1 = new TransformGroup();
        ViewPlatform gbsvp1 = new ViewPlatform();
        ot1.addChild(gbsvp1);
        Transform3D loc1 = new Transform3D();
        
        loc1.setTranslation( new Vector3d( 0.0, 0.0, 2.0 ) );
        ot1.setTransform(loc1);
        scene.addChild(ot1);

        View gbsv1 = new View();
        gbsv1.attachViewPlatform(gbsvp1);
        gbsv1.setPhysicalBody(new PhysicalBody());
        gbsv1.setPhysicalEnvironment(new PhysicalEnvironment());



   scene.compile();     // optimise the scenegraph


   VirtualUniverse u = new VirtualUniverse();
   Locale l = new Locale (u);
   l.addBranchGraph(scene);

   gbsv1.addCanvas3D(c1);

   c1.setSize(400, 400);
   add (c1);

   

    }

    public static void main(String[] args) {
      
                new MainFrame(new pit(), 556, 556);
    }
}


