I'm trying to find out whether and where a line segment and a Shape3D intersect using PickTool. However, i get null back instead of a PickResult every time. I've tried just about every capability i can think of on both the Shape3D and any Group nodes and have also tried the PickTool.setCapabilities(node, PickTool.INTERSECT_FULL) and setPickable (true). I've been messing around with this for 3 days now - any help would be very appreciated. I've listed my code below. Thanks, Jurg
import com.sun.j3d.utils.applet.MainFrame; import com.sun.j3d.utils.universe.*; import com.sun.j3d.utils.geometry.*; import javax.media.j3d.*; import javax.vecmath.*; import java.awt.GraphicsConfiguration; import com.sun.j3d.utils.picking.*; import javax.swing.*; import java.awt.*; class DrawPanel extends JPanel { BranchGroup scene; DrawPanel() { setBackground(Color.WHITE); setLayout(new BorderLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D canvas3D = new Canvas3D(config); add("Center", canvas3D); scene = createSceneGraph(); SimpleUniverse simpleU = new SimpleUniverse(canvas3D); simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); } public BranchGroup createSceneGraph() { BranchGroup objRoot = new BranchGroup(); Appearance a = new Appearance(); a.setColoringAttributes(new ColoringAttributes (0.7f,0.9f,0.9f,ColoringAttributes.FASTEST)); Cylinder c = new Cylinder(0.1f,0.8f, Cylinder.GENERATE_NORMALS | Cylinder.ENABLE_GEOMETRY_PICKING,a); //I only want a tube, but can't be bothered to write my own class Shape3D sh = new Shape3D(c.getShape(Cylinder.BODY).getGeometry(),a); sh.setBoundsAutoCompute(true); PickTool.setCapabilities(sh,PickTool.INTERSECT_FULL); objRoot.addChild(sh); objRoot.setCapability(Node.ENABLE_PICK_REPORTING); return objRoot; } //Call this after the scene has been made visible (i don't know if this is actually necessary) public void intersects() { PickTool pt = new PickTool(scene); pt.setMode(PickTool.GEOMETRY); pt.setShapeSegment(new Point3d(0,0.04,0.3),new Point3d(0,0.04,-0.3)); PickResult pr = pt.pickAny(); if (pr == null) System.out.println("Nothing intersects "+pr); else System.out.println("Found an intersection "+pr); } } public class L3D extends JApplet { public static void main(String[] args) { JFrame f = new JFrame("Intersect Test"); DrawPanel dp = new DrawPanel(); f.getContentPane().add(dp); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setSize(600,400); f.setVisible(true); //Check if the line segment intersects the tube dp.intersects(); } } =========================================================================== 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".