Are there other setters I should be using to allow picking to work in an ortho view 
that I have not done below?  The following code is from the Java3D API Tutorial Ch. 4 
Interaction MousePickApp.  Normally this app would display two color cubes that can be 
individually picked and then rotated but when you change the view from perspective to 
ortho all picks and rotations only affect the color cube on the right.  The left 
colorcube will not rotate when you pick it.

Thanks in advance.


import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.behaviors.picking.*;
import javax.media.j3d.*;
import javax.vecmath.*;

import java.awt.event.*;
import java.util.Enumeration;

//   MousePickApp renders two interactively rotatable cubes.

public class MousePickApp extends Applet {

    public BranchGroup createSceneGraph(Canvas3D canvas) {
 // Create the root of the branch graph
 BranchGroup objRoot = new BranchGroup();

        TransformGroup objRotate = null;
        PickRotateBehavior pickRotate = null;
        Transform3D transform = new Transform3D();
        BoundingSphere behaveBounds = new BoundingSphere();

        // create ColorCube and PickRotateBehavior objects
        transform.setTranslation(new Vector3f(-0.6f, 0.0f, -0.6f));
        objRotate = new TransformGroup(transform);
        objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING);

        objRoot.addChild(objRotate);
        objRotate.addChild(new ColorCube(0.4));

        pickRotate = new PickRotateBehavior(objRoot, canvas, behaveBounds);
        objRoot.addChild(pickRotate);

        // add a second ColorCube object to the scene graph
        transform.setTranslation(new Vector3f( 0.6f, 0.0f, -0.6f));
        objRotate = new TransformGroup(transform);
        objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
        objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
        objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING);

        objRoot.addChild(objRotate);
        objRotate.addChild(new ColorCube(0.4));

 // Let Java 3D perform optimizations on this scene graph.
        objRoot.compile();

 return objRoot;
    } // end of CreateSceneGraph method of MousePickApp

    // Create a simple scene and attach it to the virtual universe

    public MousePickApp() {
        setLayout(new BorderLayout());
        GraphicsConfiguration config =
           SimpleUniverse.getPreferredConfiguration();

        Canvas3D canvas3D = new Canvas3D(config);
        add("Center", canvas3D);

        // SimpleUniverse is a Convenience Utility class
        SimpleUniverse simpleU = new SimpleUniverse(canvas3D);

/****Added this code to get a ortho view*******/
 Transform3D t3d = new Transform3D();
 t3d.ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
 View view = simpleU.getViewer().getView();
 view.setCompatibilityMode(true);
 view.setLeftProjection(t3d);
 view.setRightProjection(t3d);
 view.setProjectionPolicy(View.PARALLEL_PROJECTION);

        BranchGroup scene = createSceneGraph(canvas3D);

        // This will move the ViewPlatform back a bit
/*******Comment this line out for ortho view*****/
        //simpleU.getViewingPlatform().setNominalViewingTransform();

        simpleU.addBranchGraph(scene);
    } // end of MousePickApp (constructor)

    //  The following allows this to be run as an application or as an applet

    public static void main(String[] args) {
        System.out.print("MousePickApp.java \n- a demonstration of using the 
PickRotateBehavior ");
        System.out.println("utility class to provide interaction in a Java 3D scene.");
        System.out.println("Hold the mouse button over a cube then move the mouse to 
make that cube rotate.");
        System.out.println("This is a simple example progam from The Java 3D API 
Tutorial.");
        System.out.println("The Java 3D Tutorial is available on the web at:");
        System.out.println("http://java.sun.com/products/java-media/3D/collateral";);
        Frame frame = new MainFrame(new MousePickApp(), 256, 256);
    } // end of main (method of MousePickApp)

} // end of class MousePickApp

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to