Thank you Dave, its working now.
I wrote                                
shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
shape.getGeometry().setCapability(Geometry.ALLOW_INTERSECT);
for each object loaded in my BG.
Olivier.

----- Original Message -----
Sent: Wednesday, January 30, 2002 5:39 PM
Subject: Re: [JAVA3D] exception while picking

You need to set all the relevent capabilities before adding the nodes to the scene graph.  This includes the ALLOW_GEOMETRY_READ and ALLOW_INTERSECT capabilities.  You can't set them on live nodes.
 
Dave Yazel
-----Original Message-----
From: Olivier Tassy [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 30, 2002 11:37 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] exception while picking

Hi,
I use the following code to perform a pick, but it returns "RestrictedAccessException: Cannot modify capability bits on a live scene or compiled object"
What kind of setting do I need to avoid this?
 
many thanks in advance
OLivier.
 
                   scene.setCapability(Node.ENABLE_PICK_REPORTING);
                    (...)
                    // build pick ray object from ray origin and direction        
                    PickRay ray = new PickRay(rayOrg, rayDir);
 
                    // throw the pick ray into the scene at all the leaf shape
                    // nodes under the pick root
                    SceneGraphPath paths[] = scene.pickAllSorted(ray);
 
                    if( paths != null) {
 
                            // shape target bounds were hit, check for real hits
                            for( int hitI= 0; hitI< paths.length; hitI++) {
                                System.out.println(" hit [" + hitI+ "]=" + paths[ hitI]);
 
                                // intersect pick ray with shape target geometry
                                Node shape = paths[ hitI].getObject();
                                double dist[] = {0.0};
                                Shape3D obj=( Shape3D) shape;
                               
                                obj.setCapability(Shape3D.ALLOW_GEOMETRY_READ);                //same problem when the capabilities are set directly in the BG scene
                                obj.getGeometry().setCapability(Geometry.ALLOW_INTERSECT);
                                
                                boolean isRealHit = obj.intersect(paths[ hitI], ray, dist);
 
                                if( isRealHit) {
                                    // compute hit point from hit distance and pick ray
                                    Point3d point = new Point3d();
                                    point.scaleAdd( dist[ 0], rayDir, rayOrg);
 
                                    System. out. println("real hit at " + point);
                                }
 
                            }
                    }
(most of this code comes from the java boutique web site)

Reply via email to