translate child object on global axis

Started by Dinin, May 23, 2012, 07:45:20 AM

Previous topic - Next topic

Dinin

Hi !

I want to translate a childobject f.e. 50 units in global x axis.
How can i convert this to the translation of the child object, because translation of child object is done on parents coordinate system.

Thanks and greets
Dinin

EgonOlsen


Dinin

i have a childObject attached to a parentObject.
Now i do a:
parentObject.translate(10,0,0);
parentObject.rotateZ(Math.Pi/4);


Now i want to translate the childObject to the world position 60,0,0.
But when i do a:
childObject.translate(50,0,0);
the childobject is moved depending on the rotation of the parentObject.
So i want to convert the
childObject.translate(50,0,0);
so that the world position is at 60,0,0

EgonOlsen

Maybe something like


Matrix m=parent.getRotationMatrix().invert3x3();
SimpleVector x=m.getXAxis();
x.scalarMul(50);
child.translate(x);


??? I'm not sure if this will work though...it's a just a brain fart of mine. It might as well be complete bogus.

Dinin

yes ... you're great. Exactly what i was looking for.
mthx.