import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

import javax.media.j3d.*;
import javax.vecmath.*;

import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.image.*;

/**
Solution to Lab 10 by Rod Harris
*/

public class Lab10a
{
	private MyVirtualUniverse vu = new MyVirtualUniverse();


	public static void main(String[] args)
	{
		new Lab10a();
	}


	public Lab10a()
	{
		ApplicationFrame appFrame = new ApplicationFrame("Lab 10", 800, 600);
		appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		JPanel mainPanel = new JPanel(new BorderLayout());

		mainPanel.add(vu.getBoard(), BorderLayout.CENTER);

		appFrame.getContentPane().add(mainPanel);

		addContent();

		appFrame.setVisible(true);
	}


	public void addContent()
	{
		BranchGroup bg = new BranchGroup();
		TransformGroup tg = new TransformGroup();
		Transform3D t3d = new Transform3D();

		Appearance app = new Appearance();

		app.setTexture(loadTexture("./Earth.jpg"));

		Sphere sphere = new Sphere(1.0f, Sphere.GENERATE_TEXTURE_COORDS, app);

		t3d.set(new Vector3d(0, 0, -5));
		tg.setTransform(t3d);
		tg.addChild(sphere);
		bg.addChild(tg);

		vu.addBranchGraph(bg);
	}

	private Texture loadTexture(String s)
	{
		TextureLoader loader = new TextureLoader(s, null);
		Texture t = loader.getTexture();
		return t;
	}

}

