I figured out why I had issues with other BranchGroups in the scene
even though I did not set their capability:
BranchGroup.ENABLE_PICK_REPORTING
I fixed it by explicitly telling those unwanted BranchGroups to not be
pickable
otherBG.setPickable(false)
Mario
Mariusz Zaczek
NASA - Johnson Space Center
Automated Vehicles and Orbit Analysis / DM35
Flight Design and Dynamics Division
Mission Operations Directorate
Bldg: 30A Room: 3040A
Disclaimer: "The opinions, observations and comments expressed in my email
are strictly my own and do not necessarily reflect those of
NASA."
-----Original Message-----
From: Philip J Colbert [mailto:[EMAIL PROTECTED]
Sent: Monday, March 17, 2003 2:59 AM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] ? Picking inconsistency ?
Hi Mario
I have not done a huge amount of work with picking but I have noticed some
funny things going on. much the same as others on here. I have found that
there are diffrences between:
pickCanvas.setMode(PickTool.BOUNDS);
and
pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
or
pickCanvas.setMode(PickTool.GEOMETRY);
especially when using pickClosest();
have you looked into the diffrences with these three modes of picking?
I am using a pickMouseBehavior to selected imported Vrml shapes and adding
or
deleting them from my scene eventually build a larger shape. and find that
at diffrent times I have to use PickTool.BOUNDS and at other times I have to
use PickTool.GEOMETRY_INTERSECT_INFO!!! I do not undersatnd why this is but
assume it is something to do with the way the closest is calculated!
I hope this helps though I doubt it will! I sure others on this list can
explain better than I.
C YA Phil :)
>===== Original Message From Discussion list for Java 3D API
<[EMAIL PROTECTED]> =====
>I have a canvas with several 3D spheres generated from my own Sphere3d
class
>which itself is a BranchGroup and has a translation TransformGroup attached
>to it and then a Primitive of the Sphere attached to it. I want to select
>the individual spheres and tell my program which sphere it is...using the
>code below I implemented the MousePickBehavior but found that I have a lot
>of inconsistency in picking the objects. Sometimes I click on a sphere and
>I pick it, other times I getting nothing at all...if I rotate the scene
>around
>then sometime I can get the sphere again. It seems like the picking is
>going very well. I tried also using PRIMITIVE instead of SHAPE3D for
>my 'pickResult.getNode(PickResult.SHAPE3D)' but with similar results.
>Additionally I tried using the BRANCH_GROUP but I could not select anything
>at all.
>
>My questions are:
> 1) Have any of you found inconsistency in your picking?
> 2) How can I get the BRANCH_GROUP pickResult to work so that I can
> directly get the node instead of using User defined data attached to
> the Sphere?
> 3) Do you think using a VirtualUniverse, instead of SimpleUniverse
>affects
> the results? I tested this but could not find an issue.
> 4) Does anyone have a better picking system/code or simply can give me
> insight on how to fix the one I have...by the way, the code below is
> entirely from the java3D demos and I only added some print lines.
>
>thanks,
>
>Mario
>
>
>
>
>-------------------------------------------------------------------------
>
>
> PickHighlightBehavior pickBeh = new PickHighlightBehavior(canvas3D,
>objRoot, bounds);
>
>
>
>-------------------------------------------------------------------------
>
>
>
>/*
> * @(#)PickHighlightBehavior.java 1.15 02/04/01 15:03:24
> *
> * Copyright (c) 1996-2002 Sun Microsystems, Inc. All Rights Reserved.
> *
> * Redistribution and use in source and binary forms, with or without
> * modification, are permitted provided that the following conditions
> * are met:
> *
> * - Redistributions of source code must retain the above copyright
> * notice, this list of conditions and the following disclaimer.
> *
> * - Redistribution in binary form must reproduce the above copyright
> * notice, this list of conditions and the following disclaimer in
> * the documentation and/or other materials provided with the
> * distribution.
> *
> * Neither the name of Sun Microsystems, Inc. or the names of
> * contributors may be used to endorse or promote products derived
> * from this software without specific prior written permission.
> *
> * This software is provided "AS IS," without a warranty of any
> * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
> * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
> * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
> * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
> * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
> * DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
> * OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
> * FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
> * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
> * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE,
> * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
> *
> * You acknowledge that Software is not designed,licensed or intended
> * for use in the design, construction, operation or maintenance of
> * any nuclear facility.
> */
>
>import javax.media.j3d.*;
>import com.sun.j3d.utils.picking.PickTool;
>import com.sun.j3d.utils.picking.PickResult;
>import com.sun.j3d.utils.picking.behaviors.PickMouseBehavior;
>import java.util.*;
>import java.awt.*;
>import java.awt.Event;
>import java.awt.AWTEvent;
>import java.awt.event.MouseEvent;
>import javax.vecmath.*;
>import com.sun.j3d.utils.picking.PickIntersection;
>
>
>public class PickHighlightBehavior extends PickMouseBehavior {
> Appearance savedAppearance = null;
> Shape3D oldShape = null;
> Appearance highlightAppearance;
>
> public PickHighlightBehavior(Canvas3D canvas, BranchGroup root, Bounds
>bounds) {
> super(canvas, root, bounds);
> this.setSchedulingBounds(bounds);
> root.addChild(this);
> Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
> Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
> Color3f highlightColor = new Color3f(0.0f, 1.0f, 0.0f);
> Material highlightMaterial = new Material(highlightColor, black,
> highlightColor, white,
> 80.0f);
> highlightAppearance = new Appearance();
> highlightAppearance.setMaterial(new Material(highlightColor, black,
> highlightColor, white,
> 80.0f));
>
> pickCanvas.setMode(PickTool.BOUNDS);
> }
>
> public void updateScene(int xpos, int ypos) {
> PickResult pickResult = null;
> Shape3D shape = null;
>
> pickCanvas.setShapeLocation(xpos, ypos);
>
> Point3d eyePos = pickCanvas.getStartPosition();
> System.out.println("EYE: "+eyePos);
>
>
> pickResult = pickCanvas.pickClosest();
>
>
> if (pickResult != null) {
> shape = (Shape3D) pickResult.getNode(PickResult.SHAPE3D);
> System.out.println(" Shape: "+shape);
> }
>
>
> if (oldShape != null){
> oldShape.setAppearance(savedAppearance);
> }
> try {
> if (shape != null) {
> savedAppearance = shape.getAppearance();
> oldShape = shape;
>
> shape.setAppearance(highlightAppearance);
> }
> } catch ( Exception e ) { System.out.println(" Caught E ");}
>
> }
>}
>
>
>-------------------------------------------------------------------------
>
>
>
>
>
>
>
>
>
>
>
> Mario
>
>Mariusz Zaczek
>NASA - Johnson Space Center
>Automated Vehicles and Orbit Analysis / DM35
>Flight Design and Dynamics Division
>Mission Operations Directorate
>Bldg: 30A Room: 3040A
>
>Disclaimer: "The opinions, observations and comments expressed in my email
> are strictly my own and do not necessarily reflect those of
>NASA."
>
>===========================================================================
>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".
Philip J Colbert
Software Engineer
RCID, Bruce Building
University of Newcastle Upon Tyne
NE1 7RU
Phone 0191-2225306
Fax 0191-2225833
This e-mail, including any attached files, may contain confidential and
privileged information for the sole use of the intended recipient(s). If you
are not the intended recipient, please note that any circulation or copying
of this e-mail is strictly prohibited. If you have received this e-mail in
error please contact the sender by reply e-mail and delete all copies of
this message.
The RCID makes every effort to ensure that this e-mail and any attachments
are sent virus free. However it is the responsibility of the recipient to
perform any checks they deem necessary.
===========================================================================
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".
===========================================================================
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".