package hEvil;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;

import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.DirectionalLight;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;
import javax.vecmath.Vector3f;

import com.sun.j3d.loaders.Scene;
import com.sun.j3d.loaders.objectfile.ObjectFile;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.universe.ViewingPlatform;

public class ObjectLoader extends Frame {

	private static final long serialVersionUID = -6838195075088188544L;

	public ObjectLoader() {

		setLayout(new BorderLayout());
		GraphicsConfiguration graphicsConfig = SimpleUniverse
				.getPreferredConfiguration();

		Canvas3D canvas3D = new Canvas3D(graphicsConfig);
		add(canvas3D);
		canvas3D.setSize(1200, 800);
		canvas3D.setVisible(true);

		BranchGroup scene = new BranchGroup();

		ObjectFile loader = new ObjectFile(ObjectFile.LOAD_ALL);
		loader.setFlags(ObjectFile.RESIZE);

		Color3f light1Color = new Color3f(1.8f, 0.1f, 0.1f);

		BoundingSphere bounds =

		new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

		Vector3f light1Direction = new Vector3f(2.0f, 12.0f, -12.0f);

		DirectionalLight light1

		= new DirectionalLight(light1Color, light1Direction);

		light1.setInfluencingBounds(bounds);

		scene.addChild(light1);

		Scene modelScene = null;

		try {
			modelScene = loader.load("Images/gargoyle.obj");

		} catch (Exception e) {

		}

		scene.addChild(modelScene.getSceneGroup());

		SimpleUniverse universe = new SimpleUniverse(canvas3D);
		universe.getViewingPlatform().setNominalViewingTransform();

		universe.addBranchGraph(scene);
		
		ViewingPlatform viewPlatform = universe.getViewingPlatform();
	    TransformGroup viewTransform = viewPlatform.getViewPlatformTransform();
	    Transform3D t3d = new Transform3D();
	    viewTransform.getTransform(t3d);
	    t3d.lookAt(new Point3d(0, 0, 4), new Point3d(0, 0, 0), new Vector3d(0, 1, 0));
	    t3d.invert();
	    viewTransform.setTransform(t3d);

	}

	public static void main(String[] args) {

		ObjectLoader frame = new ObjectLoader();
		frame.setSize(1200, 800);
		frame.setVisible(true);

	}

}
@@ -533,16 +533,69 @@
 ctFile;%0A
+import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;%0A
 import c
@@ -1079,16 +1079,19 @@
 e(true);
+%0A%09%09
 %0A%0A%09%09Bran
@@ -1579,16 +1579,173 @@
 light1);
+%0A%09%09%0A%09%09Transform3D transform = new Transform3D();%0A%09%09transform.lookAt(new Point3d(0, 0, 4), new Point3d(0, 0, 0), new Vector3d(0, 1, 0));%0A%09%09transform.invert();
 %0A%0A%09%09Scen
@@ -1814,16 +1814,16 @@
 ges/
-gargoy
+untit
 le
+d
 .obj
@@ -1904,16 +1904,194 @@
 roup());
+%0A%09%09%0A%09%09OrbitBehavior orbit = new OrbitBehavior(canvas3D, OrbitBehavior.REVERSE_ALL);%0A%09%09orbit.setSchedulingBounds(bounds);%0A%09%09orbit.setRotateEnable(true);%0A%09%09orbit.setRotXFactor(5d);
 %0A%0A%09%09Simp
@@ -2311,43 +2311,9 @@
 );%0A%09
-    TransformGroup viewTransform = 
+%09
 view
@@ -2321,17 +2321,17 @@
 latform.
-g
+s
 etViewPl
@@ -2340,48 +2340,47 @@
 form
-Transform();%0A%09    Transform3D t3d = n
+Behavior(orbit);%0A%0A%09%09TransformGroup vi
 ew
- 
 Tran
@@ -2388,160 +2388,55 @@
 form
-3D();%0A%09    viewTransform.getTransform(t3d);%0A%09    t3d.lookAt(new Point3d(0, 0, 4), new Point3d(0, 0, 0), new Vector3d(0, 1, 0));%0A%09    t3d.invert();%0A%09    
+ = viewPlatform.getViewPlatformTransform();%0A%0A%09%09
 view
@@ -2463,12 +2463,21 @@
 rm(t
-3d);
+ransform);%0A%09%09
 %0A%0A%09%7D
@@ -2624,8 +2624,9 @@
 ;%0A%0A%09%7D%0A%0A%7D
+%0A

Update ObjectLoader.java