If Selman's book doesn't satisify, does Palmer's ?
Picking from Palmer's book "Essential Java 3D Fast" | | public void updateScene(int xpos, int ypos) | { | PickResult pickResult = null; | Primitive pickedShape = null; | | pickCanvas.setShapeLocation(xpos,ypos); | | pickResult = pickCanvas.pickClosest(); | | if ( pickResult != null) | pickedShape = (Primitive) | pickResult.getNode( PickResult.PRIMITIVE); | if (pickedShape != null) | System.out.println( "Picked the " + | pickedShape.getUserData()); | else | System.out.println("Picked nothing"); | } | http://www.eimc.brad.ac.uk/~ijpalmer/Java3Dfast/Source/SimplePickBehaviour.java http://www.eimc.brad.ac.uk/~ijpalmer/Java3Dfast/Source/html/SimplePick.html http://www.eimc.brad.ac.uk/~ijpalmer/Java3Dfast/Source/ http://www.eimc.brad.ac.uk/~ijpalmer/Java3Dfast/Source/Java3Dsource.zip The above is a hard coded examples, ie. it's not reading in VRML, but presumably the two methods could be merged, an exercise left to the reader. | yeah i know about the _Java _ 3D _ Programming _ | but it does not work with my wrl file 'cos | no objects are referenced, only geometries | so i cannot use hashtable!!!! | | do you have another idea? | | Sébastien Chailan | Serlog - Branche Industrie Just the one above, I'm not sure about the new xj3d loaders ( they also read in VRML ). Just an idea: Would adding unique DEF names help by adding a unique node assosiated with each geometry you might be picking ? geofuny wrote: > here is my script:(the question is bottom) > > > > public class PickFleet extends PickMouseBehavior { > > /** cuurent fleet object*/ > private Fleet fleet; > > /** Creates new PickShape > * @param canvas the current canvas > where is drawing the scene graph of fleet object > * @param root the current scene graph of the fleet object > * @param bounds the current bounds of the fleet object > * @param fl the current fleet object > */ > public PickFleet(Canvas3D canvas, BranchGroup root, Bounds bounds, > Fleet fl) { > //constructs a new PickMouseBehavior > super(canvas, root, bounds); > > //get the current fleet object > fleet = fl; > > //limitation picking bound > this.setSchedulingBounds(bounds); > > //PickFleet object added to the scene graph of the fleet > object > root.addChild(this); > > //bounds picking mode with a tolerance of picking > pickCanvas.setMode(PickTool.BOUNDS); > pickCanvas.setTolerance(0.1f); > > } > > /**proceed to get the VRML object picked > * @param xPos the x component of the picking mouse > * @param yPos the y component of the picking mouse > */ > public void updateScene(int xPos, int yPos) { > > PickResult pickResult = null; > BranchGroup bg=null; > //get the coordinates of the picking mouse into the canvas > pickCanvas.setShapeLocation(xPos, yPos); > //get the closest object picked > pickResult = pickCanvas.pickClosest(); > > if (pickResult != null) { > //get the branchgroup object picked > bg = (BranchGroup)pickResult.getNode(PickResult.BRANCH_GROUP); > ... > } > } > } > > when i get the bg variable, his value is null when i pick the VRML > object in the canvas. > > The objects are loading from VRML object and the result is an > branchgroup node. That's the reason why i use a > PickResult.BRANCH_GROUP. > > What's wrong with that? " Games with VRML & Java3d " with simple picking example. --------------------------- http://www.frontiernet.net/~imaging/games_with_java3d.html -- Paul, Java Developer & Web Animator -------------------------------------- "Imaging the Imagined: Modeling with Math & a Keyboard" =========================================================================== 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".