Hi, 

I was hoping someone may be able to help. 
I have a primitive box vrml file which I have loaded into my Java3d
scene and I would like to click on it to get the x,y,z coords.
The x and y coords provided seem fine but I don't understand why the Z
coordinate seems to vary between -1 & 1 depending on where I click the
shapes front face. Surely it should be 1 all over !.

Here  is my current pick code:

public void updateScene(int xPos, int yPos) {
        
        //System.out.println("updateScene: ypos= "+yPos);
        PickRay pickRay = new PickRay();
        PickCanvas pickCanvas = new PickCanvas(canvas3D,branchGroup);
                
        pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
        pickCanvas.setTolerance(0.001f); // Set accuracy of pick
                
        // P.C
        Point3d eyePos = new Point3d();
        canvas3D.getCenterEyeInImagePlate(eyePos);
        Point3d mousePos = new Point3d();
        canvas3D.getPixelLocationInImagePlate(xPos,yPos,mousePos);
                
        Point3d pickRayOrg = new Point3d();
        pickRayOrg.set(eyePos);
        pickCanvas.setShape(pickRay,eyePos);
                
        //int num = 0;
        pickCanvas.setShapeLocation(xPos, yPos);
        
        
        
        try 
        {
            pickResultArray = pickCanvas.pickAllSorted();
        }
        catch (CapabilityNotSetException cns)
        {
            System.err.println("Attempting to get pickAllSorted error");
            cns.printStackTrace();
            System.exit(1);
        }
        
 
//===================================================================
     //                                 PICKING 
 
//===================================================================
    
        if (pickResultArray != null)
         {
               
                   BranchGroup tempBG =
(BranchGroup)pickResultArray[0].getNode(PickResult.BRANCH_GROUP);
                    
                        //   System.out.println(tempBG.getClass());
                    // Get Object Data to determine part
                    shapeClickedBG = (CustomBranchGroup) tempBG;
                    System.out.println(shapeClickedBG + " "
+shapeClickedBG.id + " type " + shapeClickedBG.type);
                
                    if (shapeClickedBG.type != null)
                        {
 

 
//==================================================
                            //            VRML SHAPE - Pick Routine
 
//=================================================
                                            
                            pickResult = pickResultArray[0];
                            
                            pickInter =
pickResult.getClosestIntersection(eyePos);
                                
                            try 
                            {
                                pickedVec =
pickInter.getPointCoordinates();
 

                            } 
                            catch (Exception e)
                            {
                                //ignore this error, maybe in a demo ;)
                                System.err.println("Interrogating Pick
Result Error!");
                                e.printStackTrace();
                                System.exit(1);
                            }
                            
                            if (addDeleteFn.equals("Add")) {
                                // add shape
 
calculateShapeToAdd(pickedVec.x,pickedVec.y, pickedVec.z);
                                }
                                else if (addDeleteFn.equals("Delete")) {
                                        // delete shape
                                }
                      }
                        
                    
                    
                    else 
                    {
                        System.out.println("Null or Geom Shape");
                    }
                    
              //}
                
           } // if pickResultArray
           System.out.println("\n");
                    
        }
 
//======================================================================
===

Thanks
Paul

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