I am trying to do a free flying box. The rotation and movement in global coordinates works fine. However flying forward accordingly to local box coordinates/direction does not seem to be easy to crack.

This works as expected in global coordinates moving box forward

if(Kb.b(KB_U)) box.kinematicMoveTo( box.pos()+Vec(0, 0, 0.02));

if(Kb.b(KB_J)) box.kinematicMoveTo( box.pos()+Vec(0, 0, -0.02));

Trying to convert local coordinates to global coordinates with matrix arithmetic does not work at all(random movement). (I can;t fly the box forward accordingly to it's rotation).

m=box.matrix();

if(Kb.b(KB_U)) box.kinematicMoveTo( box.pos()+Vec(0, 0, 0.02)*m);

if(Kb.b(KB_J)) box.kinematicMoveTo( box.pos()+Vec(0, 0, -0.02)*m);

Please let me know if you have some hints.

Edit:

This is what i found so far about subject - converting local global coordinates/directions:

http://www.esenthel.com/community/printt...p?tid=6285
I hope there is a solution without sin/cos/atan etc, just with matrix.

Second edit:

This is the solution, i could find and works:

m=box.matrix().orn();

if(Kb.b(KB_U)) box.kinematicMoveTo( box.pos()+Vec(0, 0, 0.02)*m);

if(Kb.b(KB_J)) box.kinematicMoveTo( box.pos()+Vec(0, 0, -0.02)*m);