/*
//*****************************************************************************
/*
*       @(#) UpgradeTest.java
*
*       Project:                Java 3D Programming
*       Client:         Manning Publications
*
*       Copyright (c) 1999 Daniel Selman 
*       All Rights Reserved.
*
*       @author Daniel Selman: dselman@tornadolabs.com
*/
//*****************************************************************************

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

import javax.media.j3d.*;
import javax.vecmath.*;

import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.image.TextureLoader;
import com.sun.j3d.utils.universe.*;

class UpgradeTest extends Applet
{
        private static int                              m_kWidth = 350;
        private static int                              m_kHeight = 400;
                	
        public UpgradeTest()
        {
                setLayout(new BorderLayout());
                GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

                Canvas3D c = new Canvas3D( config );
                add("Center", c );

                BranchGroup scene = createSceneBranchGroup();
                SimpleUniverse u = new SimpleUniverse( c );
                u.getViewingPlatform().setNominalViewingTransform();

                u.addBranchGraph(scene);
   }
	
        protected BranchGroup createSceneBranchGroup()
        {
                BranchGroup objRoot = new BranchGroup();
        	
                // create an Appearance and Material
                Appearance app = new Appearance();
        	
                TextureLoader tex = new TextureLoader( "earth.jpg", this );
                app.setTexture( tex.getTexture() );
                        	
                Sphere sphere = new Sphere( 0.4f, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, 32, app );
        	
                // connect the scenegraph
                objRoot.addChild( sphere );

                return objRoot;
        }
	
        public static void main(String[] args)
        {
                UpgradeTest upgradeTest = new UpgradeTest();
                new MainFrame( upgradeTest, m_kWidth, m_kHeight );
        }
}