Hi

Use the new picking classes in package com.sun.j3d.utils.picking.behaviors
instead of the deprecated ones in com.sun.j3d.utils.behaviors.picking

B.D.

>From: "Mark A. Tapia" <[EMAIL PROTECTED]>
>Reply-To: Discussion list for Java 3D API <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: [JAVA3D] Computing intersections with the PickConeRay in a Scene
>Date: Wed, 29 Aug 2001 17:20:12 -0400
>
>I am finding it rather difficult to compute the intersection of a PickRay
>with
>the closest object in the scene to the pickray. Using a deprecated method I
>can
>determine which face in a cube I have selected. Using the supposed
>replacements, I can determine nothing. (Each cube contains 6 faces, each
>formed
>by flat planes -- rectangular solids with one of the three dimensions
>zero)..
>
>My  public class PickHighlightBehavior extends the deprecated class
>com.sun.j3d.utils.behaviors.picking.PickMouseBehavior. The class is based
>on
>http://primordial.cic.unb.br/lcmm/cursos/pmm99.1/a9/PickHighlightBehavior.html
>which appears to be written at Sun.
>
>Here are two of the fields of PickHighlightBehavior and its constructor,
>the
>canvas is the Canvas3D object  associated with the scene, while root is the
>BranchGroup corresponding to the root of the scene associated with canvas.
>
>   private com.sun.j3d.utils.picking.PickCanvas pickCanvas;
>   private ShapeGrammarWorld shapeGrammarWorld;
>
>   public PickHighlightBehavior(ShapeGrammarWorld shapeGrammarWorld,
>              Canvas3D canvas, BranchGroup root,
>                             Bounds bounds) {
>       super(canvas, root, bounds);
>       this.shapeGrammarWorld = shapeGrammarWorld;
>       this.setSchedulingBounds(bounds);
>       root.addChild(this);
>       pickCanvas = new com.sun.j3d.utils.picking.PickCanvas(canvas, root);
>   }
>
>
>When the class uses deprecated code in updateScene, it works correctly --
>shape3D is not null when a shape in the scene is picked.:
>
>   public void updateScene(int xpos, int ypos) {
>          Shape3D shape3D;
>
>     shape3D = (Shape3D) pickScene.pickNode(pickScene.pickClosest(xpos,
>ypos,
>                                              PickObject.USE_BOUNDS),
>                                              PickObject.SHAPE3D);
>     System.out.println(shape3D);
>     // ommitted code that highlights and dehighlights the shape
>   }
>.
>
>In contrast, the following code does not contain any deprecated code and
>also
>does not work (pickResult is always null, even when I pick one of the faces
>of a
>shape in the scene):
>  public void updateScene(int xPos, int yPos) {
>     com.sun.j3d.utils.picking.PickResult pickResult =
>           pickCanvas.pickClosest();
>     PickShape pickShape = pickCanvas.getPickShape();
>     PickConeRay pickConeRay = (PickConeRay) pickShape;
>     System.out.println("Update a scene " + pickResult);
>     // ommitted code that highlights and dehighlights the shape
>}
>
>The result of running this code is that .
>
>How can I do what I really want to do: find the exact intersection point of
>the
>PickConeRay and the shape (a flat box -- with one dimension 0) and use
>non-deprecated classes or methods.
>
>Any help would be greatly appreciated.
>
>Thanks,
>
>Mark
>
>
>Mark Tapia
>Research Scientist
>Department of Architecture
>Massachusetts Institute of Technology
>Phone: 1.617.253.1721   Fax:    1.617.253.8221
>
>Website: http://architecture.mit.edu/house_n/web/people/principal.htm


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

===========================================================================
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