diff examples/java3d/hello10.java @ 1:5df24c91468d

Oh my what a mess.
author samer
date Fri, 05 Apr 2019 16:26:00 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/java3d/hello10.java	Fri Apr 05 16:26:00 2019 +0100
@@ -0,0 +1,85 @@
+/*
+		hello10.java
+
+		Construct universe without using SimpleUniverse 
+		utility class - this puts together the view
+		group explicitly.
+
+		Now has dynamically creatable views.
+		Have to construct views on BranchGroups so they
+		can be added while universe is live?	
+
+		picking
+ */
+
+import samer.core.*;
+import java.awt.event.*;
+import javax.media.j3d.*;
+import javax.vecmath.*;
+
+public class hello10 extends util implements Agent
+{
+	// create universe
+	LocalUniverse	U=new LocalUniverse();
+	BranchGroup		root=new BranchGroup();
+	
+	public static void main(String[] arse) { init(); new hello10(); }
+
+	public hello10()
+	{		
+		Viewer v=new Viewer("view");
+
+		// v.lookFrom(new Point3d(0,0,8),new Vector3d(0,1,0));
+
+		// create scene
+		root.addChild(createSceneGraph());
+		root.addChild(v);
+		root.setCapability(Group.ALLOW_CHILDREN_EXTEND);
+		root.setCapability(Group.ALLOW_CHILDREN_WRITE);
+
+/*
+        tg.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
+        PickRotateBehavior pr=new PickRotateBehavior(objroot, canvas, bounds);
+        objroot.addChild(pickRotate);
+ */
+
+		root.compile();
+		
+		U.addGroup(root);
+
+		Shell.registerAgent(this);
+		Shell.exposeCommands(this);
+	}
+
+	public void getCommands(Agent.Registry r) { 
+		r.add("view");
+		r.setTarget(null); r.add("start").add("stop"); 
+	}
+
+	public void execute(String cmd, Environment env) throws Exception
+	{
+		if (cmd.equals("view")) { 
+			root.addChild(new Viewer(X.string(env.datum("name"),"view")));
+		}
+	}
+
+	private static TransformGroup createSceneGraph()
+	{
+		Transform3D		r=new Transform3D();
+		//r.rotX(Math.PI/2);
+		r.setScale(0.5);
+		TransformGroup  t2=new TransformGroup(r);
+		t2.addChild( yoyoGroup(
+			yoyoGeometryInfo(12).getGeometryArray(),
+			wireframe2(),
+			pointy()));
+
+		TransformGroup	tg = new TransformGroup();
+		// addRotator(tg);
+		mouseRotate(tg);
+		mouseTranslate(tg);
+		mouseZoom(tg);
+		tg.addChild(t2);
+		return tg;
+	}
+}
\ No newline at end of file