>Hi Daniel,

>yes, this seems to be quite tricky.

>"Dvorak, Daniel J." wrote:

>> Do you have an example you could post?

>no, unfortunatly not. I am happy that my application is running now :-)

>Best Regards,

>Andreas

Hi Daniel,
it seems that Andreas isn't in the mood to share code. Here is the
example code from Jon Barrilleaux's book: 3D User Interfaces with Java3D.
By the way it's a nice book!
Hope it helps.
Here we go:

//establish pick root
BranchGroup root;

//build pick ray
Point3d rayOrg = new Point3D();
Vector3d rayDir = new Vector3D();

//Set rayOrg, rayDir to your needs
....

rayDir.normalize();

//build pick ray object form rayOrg & rayDir

PickRay ray = new PickRay(rayOrg,rayDir);

//throw the pick ray into scene and all leaf shapes under the pick root
//don't forget to set capability bits  ;-)

SceneGraphPath paths[] = root.pickAllSorted(ray);

if (paths==null)
{
 System.out.println("no hits");
}
else
{
 //shape target bounds were hit, check for real hits
 for (int hitI=0 ; hitI < paths.length; hitI++)
 {
   // intersect pickray with shape target geometry
   Node shape = paths[hitI].getObject();
   double dist[] = {0.0};
   boolean isRealHit = ((Shape3D) shape).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);
    }
  }
}

Regards and happy hacking
Joerg
--

  http://w5.cs.uni-sb.de/~baus

  Email : [EMAIL PROTECTED]
  Phone : +49-681-302-2016
  Fax   : +49-681-302-4136

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