getting the location of a transform group

Hi. Sorry to bother this messageboard again with more newbie questions, but I find that it has been a great resource (and pretty active) too.

  1. I have a couple of objects that are in the same TransformGroup, and I’ve
    given the TransformGroup pick behaviors so that I can drag it around.
    My question is, how do I get the x/y/z position of the TransformGroup’s
    current position? For instance, if I drag it somewhere and want to print
    out it’s new position. I’ve looked at TransformGroup and Transform3D and I
    haven’t found anything useful…any help would be greatly appreciated.

2)I was wondering if there is a quick and easy way to switch the buttons
assigned to the default MouseBehaviors. The default is left-button rotate,
right-button translate, third-button zoom. Is there an easy way to just
swap these around without having to rewrite a whole set of mouse behaviors?

  1. Instead of dragging objects around, I was thinking maybe I could make it such that I could click it once and it’ll follow my mouse around. Then when I click it again, I set it down to its new position. Should I be writing a new PickBehavior for this or a new MouseBehavior to get this sort of functionality? Or should I be manually extracting the mouse’s position and tracking it somehow?

Thanks again,
DAT

No bother :slight_smile:

  1. TransformGroups contain Transform3D, which the Java3D way of storing a 3D Matrix. If the Transform in in the scene graph and has not Transforms above it (sometimes easy to know sometimes not so easy) then you can use Transforms3D’s:

void get(Vector3d trans)
Retrieves the translational components of this transform.
void get(Vector3f trans)
Retrieves the translational components of this transform.

If however, in many case, the Transform3D is in a hierarchy of other TransformsGroups, then you have to use the the node classes “getLocalToVworld”
this will get a Transform3D that is the “flatten” or absolute transformation for the given node. Then in Transform3D loaded from “getLocalToVworld”, you can do the “get(Vector3d/f)” from above.
Does that make since? Transform hierarchies can be very confusing when you just start out. A good 3D math book would help.

  1. The mouse behavior code is open source, so you can change it how you want. However, I suggest getting the “imporved” mouse behaviors available at www.j3d.org and using those.

  2. I think you could hack out this behavior with the new mouse behavior source.

Good Luck!