www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: Dinin on May 23, 2012, 07:45:20 am

Title: translate child object on global axis
Post by: Dinin on May 23, 2012, 07:45:20 am
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
Title: Re: translate child object on global axis
Post by: EgonOlsen on May 23, 2012, 04:37:01 pm
I don't get the question.... ???
Title: Re: translate child object on global axis
Post by: Dinin on May 23, 2012, 05:32:40 pm
i have a childObject attached to a parentObject.
Now i do a:
Code: [Select]
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:
Code: [Select]
childObject.translate(50,0,0);the childobject is moved depending on the rotation of the parentObject.
So i want to convert the
Code: [Select]
childObject.translate(50,0,0);so that the world position is at 60,0,0
Title: Re: translate child object on global axis
Post by: EgonOlsen on May 23, 2012, 05:37:14 pm
Maybe something like

Code: [Select]
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.
Title: Re: translate child object on global axis
Post by: Dinin on May 23, 2012, 06:44:41 pm
yes ... you're great. Exactly what i was looking for.
mthx.