Hi Tom,

> How can I effectively construct SceneGraphPath for a particular
> Node ( for example a leaf of the tree ). ?
> The only idea I can come up with is to traverse the tree from
> top(Locale) looking for a given node. However it could take a
> long time to traverse big graphs. Are there any other ways ?

As long as your graph isn't live or compiled you could use
Node.getParent() to work your way up from the target Leaf/Group
to the topmost BranchGroup attached to the Locale.

On live/compiled graphs getParent() is invalid (and there is no
capability to allow access), so only Group.getAllChildren() or
group.getChild(int index) may be used traversing the graph from
top down.

To speed up, I would get the Bounds from the target Leaf/Group
and all intermediate Group nodes and do an intersection test
between them (i.e. via Bounds.intersect(Bounds bo)) to sort out
nonintersecting branches early on the way down.

Instead of Bounds.intersect(Bounds bo) you may consider
Bounds.intersect(Point3d point), if you have a center point of
your target, this has the potential of sorting out more Groups
in each step. An approximate center point might be gotten by:

  Point3d p = new Point3d();
  Bounds b = target.getBounds();
  if (b instanceof BoundingSphere) {
    ((BoundingSphere)b).getCenter(p);
  }
  else {
    new BoundingSphere(b).getCenter(p);
  }

This would require Node.ALLOW_BOUNDS_READ and Group.ALLOW_CHILDREN_READ
capabilities be set on all scene Leafs/Groups potentially traversed.

Hope this helps

Georg
 ___   ___
| + | |__    Georg Rehfeld      Woltmanstr. 12     20097 Hamburg
|_|_\ |___   [EMAIL PROTECTED]           +49 (40) 23 53 27 10

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