Hello!

I also had the same problem, and I have found out, that the
problem is the following command in the method "updateScene" of
PickTranslateBehavior (At least I think this is the explanation):

--------
tg =(TransformGroup)pickScene.pickNode
  (
   pickScene.pickClosest(xpos,ypos,pickMode),
   PickObject.TRANSFORM_GROUP
  );
--------

"PickScene.pickClosest(xpos,ypos,pickMode)" returns a
ScenePathGraph consisting of all nodes with the
capability "ENABLE_PICK_REPORTING" on the path between
the picked object and the locale.
And "pickNode(...,PickObject.TRANSFORM_GROUP)"
returns the FIRST TransformGroup on this path beginning
from the locale.

That means, that if you pick the sphere in your example code, you always
affect tg1, (and thereby also the cube), because it is the first pickable
TransformGroup in the picked path.

I don�t know, what the best way to solve this problem is, but
my solution was the following:

You create a new behavior by copying "PickTranslateBehavior.java"
in another file, maybe called "SpecialBehavior.java", and changing
all occurencies of "PickTranslateBehavior" into "SpecialBehavior".
Then all you have to do, is to change the above code into the following:

--------
tg =(TransformGroup)pickScene.pickNode
  (
   pickScene.pickClosest(xpos,ypos,pickMode),
   PickObject.TRANSFORM_GROUP, 2
  );
--------

This does always get the SECOND node in the picked path.
That would be tg2, as wanted.
Look in the description of "PickNode" in "PickObject".

I hope this works.

Bye,
Benjamin Nill
[EMAIL PROTECTED]

-------------
Peter Steiger wrote:
> 
> Hello!
> 
> I have a TransformGroup A which has a PickRotateBehavior to rotate
> all the children of this group. This works fine.
> 
> One child is another TransformGroup B, where I added a
> PickTranslateBehavior, to be able to translate all the children
> of B.
> 
> Unfortunately also A is translated, when I pick an object
> of B, instead of translating *only* the objects of B.
> 
> So why does this PickTranslateBehavior change the TransformGroup A
> and not B?
> 
> Any help is very appreciated!
> 
> Thanx in advance
> 
> Peter
> 
> PS: Here's the important part of the code:
> 
> // ----------------------------------------------------------
>      BranchGroup branchGroup = new BranchGroup();
> 
>      TransformGroup tg1 = new TransformGroup();
>       tg1.setCapability(Node.ENABLE_PICK_REPORTING);
>       tg1.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
>       tg1.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
>      branchGroup.addChild(tg1);
> 
>      // a 1x1x1 cube (only edges are drawn)
>      tg1.addChild((new CoordinateBox()).getChild());
> 
>      BranchGroup bg1 = new BranchGroup();
>      tg1.addChild(bg1);
> 
>      TransformGroup tg2 = new TransformGroup();
>       tg2.setCapability(Node.ENABLE_PICK_REPORTING);
>       tg2.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
>       tg2.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
>      bg1.addChild(tg2);
> 
>      tg2.addChild((new Sphere(0.1f, app)));
> 
>      PickTranslateBehavior mt =
>          new PickTranslateBehavior(bg1,
>              canvas,
>              new BoundingSphere(new Point3d(1.0, 1.0, 1.0), 0,1),
>              PickObject.USE_BOUNDS);
> 
>      bg1.addChild(mt);
> 
>      PickRotateBehavior br =
>          new PickRotateBehavior(branchGroup,
>              canvas,
>              new BoundingSphere(new Point3d(0.5, 0.5, 0.5), 0.7),
>              PickObject.USE_BOUNDS);
> 
>      branchGroup.addChild(br);
> 
>      branchGroup.compile();
> // ----------------------------------------------------------
> 
> =====================================================================
> To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
> Java 3D Home Page: http://java.sun.com/products/java-media/3D/


�����������������������
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to