Mercurial > hg > jslab
view examples/java3d/hello6.java @ 7:243687520bcc
Meh
author | samer |
---|---|
date | Fri, 05 Apr 2019 21:52:03 +0100 |
parents | 5df24c91468d |
children |
line wrap: on
line source
/* hello6.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? */ import samer.core.*; import java.awt.event.*; import javax.media.j3d.*; import javax.vecmath.*; public class hello6 extends util implements Agent { // create universe LocalUniverse U=new LocalUniverse(); BranchGroup root=new BranchGroup(); public static void main(String[] arse) { init(); new hello6(); } public hello6() { // create scene root.addChild(createSceneGraph()); // addBackground(root,new Background(0.1f,0.2f,0.15f)); // addLights(root); root.addChild(new FPS(200)); root.addChild(new Viewer("view")); root.setCapability(Group.ALLOW_CHILDREN_EXTEND); root.setCapability(Group.ALLOW_CHILDREN_WRITE); 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); TransformGroup t2=new TransformGroup(r); t2.addChild(yoyoGroup()); TransformGroup tg = new TransformGroup(); addRotator(tg); tg.addChild(t2); return tg; } }