Jme-physics2: working with quaternions, local and global directions

Hey guys, I've got a quick question about the jme-physics 2 and working with forces 'n stuff. Right now I'm trying to make a simple space-ship-flying-around type of game and I'm trying to add thrust to my ship. Unfortunately, I all of the PhysicsNode.addForce() methods I see, seem to only add a vector force "globally" to the ship. What I want is to either add a force "locally", thereby allowing myself to always make the ship move according to the direction it's facing. OR if I could figure out how to convert a Quaternion to a Vector3f I'd be able to take the node's direction (a Quat) and work with that!



Unfortunately, I don't know how to do either of these things. And since there's no methods in jME-Physics2 for adding forces that uses a Quat and a magnitude; and since there's no method for adding a force locally instead of globally, I'm kinda stuck.  :expressionless:



Does anyone have any ideas?

Daedalus said:

how to convert a Quaternion to a Vector3f I'd be able to take the node's direction (a Quat) and work with that!


been there, done that, gave up  hehe :) i couldn't get it to work as i wanted it to.
But to add force into the direction the object is currently heading, do the following.


Vector3f direction = new Vector3f();
physicsNode.getLocalRotation().getRotationColumn(2, direction);
physicNode.addForce(direction.mult(yourModiifier);



Noooo!  :’(

There must be SOME way to do it, surely! If not then isn’t that a flaw in the design?  :?

It does work the way you would expect.

What i meat with "i couldn't get it to work as i wanted it to" was, that it is not easy to make it feel right.

One problem i encountered was, that my spaceship drifted to much, and i couldn't fix it with a frictioncallback etc.

I think if you work with Physics, you will need a lot of fine-tuning till it feels right.

Ah, I see. I was misreading your post.  :oops:



That'll work for what I need. Thanks for the help! :smiley: