Forum Stats

  • 3,872,464 Users
  • 2,266,426 Discussions


How can mouse behaviors work for new added branchgroup

843799 Member Posts: 49,999
edited Jun 15, 2010 1:49PM in Java 3D
now i manage to add new shape3d to scene at runtime
but i set several mouse behaviours for base simpleuniverse and they dont work with new added branchgroup

i tried to add new branchgroup to base transformgroup,it throws an access exception
any solutions?


  • 843799
    843799 Member Posts: 49,999
    Try that :
    Do not add the behaviours to the universe.
    But add them to the Branchgroup corresponding to a shape3d
    (not the top Branchgroup).
    here is a piece of code which do that.

    pickRotate = new PickRotateBehavior(objRoot, canvas3D, behaveBounds);

    pickTranslate = new PickTranslateBehavior(objRoot, canvas3D, behaveBounds);

    pickZoom = new PickZoomBehavior(objRoot, canvas3D, behaveBounds);

    // Now create the simple picking behavior
    PickHighlight pickBeh = new PickHighlight(canvas3D, objRoot, behaveBounds);
    return objRoot;
  • 843799
    843799 Member Posts: 49,999
    Your access exception could talk about a missing capability, an in this case the problem would be that the node that you try to add the new BG to, does not have the ALLOW_CHILD_WRITE (not sure if exactly that, but you'll get the idea).

    The mouse behaviours, or at least the usual rotation, translation and zoom, apply on every shape new or old under them. I constantly add and remove shapes from my scene and those behaviours allways affect the whole of it, as they are at the top of the tree.

  • 843799
    843799 Member Posts: 49,999
    I have a similiar problem.

    After adding a new BranchGroup with a Shape3D at runtime, I manage to add Java3D base classes Behavior (like PickTranslateBehavior) but cannot add collision avoidance to it.

    What I want to do is to combine PickTranslateBehavior with collision detection like putting forniture in a room.

    Any ideas?

    Best regards.
This discussion has been closed.