Gestion de la souris au moyen
de Behaviors

</COMMENT> alt="Your browser understands the &lt;APPLET&gt; tag but isn't running the applet, for some reason." Your browser is completely ignoring the &lt;APPLET&gt; tag!

RETOUR

SimpleMouse.java

/* Auteur: Nicolas JANEY         */
/* nicolas.janey@univ-fcomte.fr  */
/* Novembre 2001                 */

import java.applet.Applet;
import java.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.mouse.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class SimpleMouse extends Applet {

  public BranchGroup createSceneGraph(SimpleUniverse u) {
    BranchGroup objRoot = new BranchGroup();
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_READ );
    objTrans.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
    objRoot.addChild(objTrans);
    Transform3D t = new Transform3D();
    t.setRotation(new AxisAngle4d(1.0,1.0,0.0,
                                  Math.PI/5.0)) ;
    objTrans.setTransform(t);
    objTrans.addChild(new ColorCube(0.4));
    BoundingSphere bounds;
    bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0),100.0);
    MouseRotate behavior = new MouseRotate(objTrans);
    objTrans.addChild(behavior);
    behavior.setSchedulingBounds(bounds);
    MouseZoom behavior2 = new MouseZoom(objTrans);
    objTrans.addChild(behavior2);
    behavior2.setSchedulingBounds(bounds);
    objRoot.compile();
    return objRoot;
    }

  public SimpleMouse() {
    setLayout(new BorderLayout());
    GraphicsConfiguration config;
    config = SimpleUniverse.getPreferredConfiguration();
    Canvas3D c = new Canvas3D(config);
    add("Center",c);
    SimpleUniverse u = new SimpleUniverse(c);
    BranchGroup scene = createSceneGraph(u);
    u.getViewingPlatform().setNominalViewingTransform();
    u.addBranchGraph(scene);
    }

  public static void main(String[] args) {
    new MainFrame(new SimpleMouse(),300,250);
    }
  }

RETOUR

Remarques,erreurs
nicolas.janey@univ-fcomte.fr