Try adding your behaviors as children of the TranformGroup instead of the

BranchGroup.

Brad


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