Local to Local transforms

Does anyone know how to get from one transform coordinate system to another ? Like, if you have a box in one transformgroup and move it to another, it shouldn’t move in world space, but it’s local coordinates will be altered. How do you perform that calculation ?

Thsi what youa re lookign for??
getLocalToVworld

public void getLocalToVworld(Transform3D t)

Retrieves the local coordinates to virtual world coordinates transform for this node in the scene graph. This is the composite of all transforms in the scene graph from the root down to this node. It is only valid for nodes that are part of a live scene graph.

Parameters:
    t - the object that will receive the local coordinates to Vworld coordinates transform. 
Throws:
    RestrictedAccessException - if the node is not part of a live scene graph 
    CapabilityNotSetException - if appropriate capability is not set and this node is part of live scene graph 
    IllegalSharingException - if the node is a descendant of a SharedGroup node.

Its a method available on any child of the Node superclass.

Docs are an amazing thing :wink:

Yes thanks to my knowledge I’ve read all known documentation to solve this but didn’t find anything. I’m aware of the getLocalToVworld. But it doesnt solve the problem.
My problem is :
A box changes parent, from transformgroup t1 to t2. It shouldnt change it’s posistion on screen (world coordinates) but it should change owner (from t1 to t2). If you change the owner without changing it’s local coordinates it will most likely change it’s position (on screen) in an unpredictable way, especially if both t1 and t2 are under a some sort of hierachy of nested transformgroups. So how do you do that ? I can’t imagine this is not a very common problem in a scenegraph bases IPI. and there should be a simple solution to it.
A setLocalToVWorld() would take care of the problem though :slight_smile:

You first need to get the world transform and then traverse down the down the branch where you want to place your box and multiply the transform with the inverse matrix of each transform group you encounter.

[quote]You first need to get the world transform and then traverse down the down the branch where you want to place your box and multiply the transform with the inverse matrix of each transform group you encounter.
[/quote]
That sounds comlicated and expensive. But thanks going to give it a try.

This did it ::slight_smile:
Transform3D worldTransform; //from transform
worldTransform.invert();
Vector3f v = new Vector3f();
localTransform.get(v); //to transform
worldTransform.transform(v);

//v has the right coordinates