Chu J Tan wrote: > > Collision detectionDoes Java3D has some kind of libraries that allow user to > pick a direction using the mouse visually? > > Say, the user just hold down mouse button on a Canvas3D with the axis and > the 3d image will change according to user's mouse position. Or the user can > just click once on the X frame, and then Y frame and then Z frame and the > component can then sets a direction vector created by the clicks. > > =========================================================================== > 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". Hi Chu, I've done the first thing using the PickTool provided in the sun utilities. Just use it as you where trying to pick geometry by doing PickCanvas pickCanvas = new PickCanvas( canvas, branchGroup ); pickCanvas.setMode( PickTool.GEOMETRY_INTERSECTION_INFO ); pickCanvas.setTolerance( 4 ); like proposed in the documentation. The tolerance setting is not even necessary. You have to note that the PickCanvas creates a PickShape object for computing the intersection. So just read out the direction for a specific (mouse) position pickCanvas.setShapeLocation( x, y ); // the shape is an instance of PickConeRay, i took the superclass PickCone for generality // :NOTE: that sun might change that in the future (perhaps then the PickShape could provide // the getDirection(...) method) PickCone pickCone = (PickCone) pickCanvas.getPickShape(); Vector3d direction = new Vector3d(); pickCone.getDirection( direction ); That's it. Note that the direction is not said to be normalized or something. To get a real point you could simply intersect the ray with the xy plane, where z = 0. Hope this helps, Karsten
begin:vcard n:Fries;Karsten tel;work:+49-6221-4038-384 x-mozilla-html:FALSE org:Lion Bioscience AG adr:;;Waldhoferstrasse 98;Heidelberg;;;Germany version:2.1 email;internet:[EMAIL PROTECTED] title:Software Engineer x-mozilla-cpt:;24864 fn:Karsten Fries end:vcard