import java.applet.Applet; import java.awt.*; import com.sun.j3d.utils.geometry.ColorCube; import com.sun.j3d.utils.universe.SimpleUniverse; //import com.sun.j3d.utils.behaviors.mouse.*; import com.sun.j3d.utils.picking.behaviors.*; import com.sun.j3d.utils.picking.*; import java.util.Enumeration; import javax.media.j3d.*; import javax.vecmath.*; public class Reageering4 extends Applet { public Reageering4() { setLayout(new BorderLayout()); Canvas3D c = new Canvas3D(SimpleUniverse.getPreferredConfiguration()); add(c, BorderLayout.CENTER); BranchGroup juur = new BranchGroup(); TransformGroup tg1=new TransformGroup(); Transform3D t1=new Transform3D(); tg1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg1.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg1.setCapability(TransformGroup.ENABLE_PICK_REPORTING); juur.addChild(tg1); Shape3D s1=new ColorCube(0.3); tg1.addChild(s1); PickTool.setCapabilities(s1, PickTool.INTERSECT_FULL); //lubab tolerantsi sättida PickRotateBehavior pck=new PickRotateBehavior(juur, c, new BoundingSphere(new Point3d(), 100)); pck.setMode(PickCanvas.GEOMETRY); pck.setTolerance(13.0f); juur.addChild(pck); Transform3D t2=new Transform3D(); t2.setTranslation(new Vector3f(0, 0.8f, 0)); TransformGroup tg2=new TransformGroup(t2); tg2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); tg2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); tg2.setCapability(TransformGroup.ENABLE_PICK_REPORTING); juur.addChild(tg2); Shape3D s2=new ColorCube(0.2); tg2.addChild(s2); PickTool.setCapabilities(s2, PickTool.INTERSECT_FULL); juur.compile(); SimpleUniverse u = new SimpleUniverse(c); u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(juur); } public static void main(String[] args) { Frame f=new Frame("Reageering"); f.add(new Reageering4()); f.setSize(300, 300); f.setVisible(true); } }