Keeping a constant orientation - Are Quaternions right for me?

I have a box which is being moved by surface motion, however, one problem I  have is that if it bumps into anything, its rotation changes and it no longer is moving in the same way as before.

One way I thought I could solve this would be to store the orientation of my box at the beginning of the game, and then every update frame set that box to the same rotation. Only problem is, I have absolutely no idea how to do that. How can I save the orientation of my box, does it have something to do with a Quaternion?


A quaternion is the way you would normally store a rotation in jME.

You would just do:

Quaternion original = box.getLocalRotation();

then to reset it:


That's assuming the box doesn't have some parent node that can also rotate, in which case it's a bit more complicated.

However, if you're using physics, which it sounds like you are, then this may not be the best solution. This is because you usually want to use physics functions rather than hard setting position and rotation - which might cause weirdness in some systems.

ah i see… this sounds like it might be getting complicated.

how can i keep a rotation utilizing physics functions?

i would need to be able to acquire each force as it hits my player, and then counter it? How would I go about doing that?

on second thought, I believe a way this could be done would be to essentially "lock" all rotational axises for my DynamicPhysicsNode.

However… I cannot seem to find a way to do this.

Does anyone have any ideas?

Override the intertia, set it to a nullvector and you are fine.

hmm, how would nullifying the inertia solve my problem?

what happens is if the player pushes up against an object, the player will rotate because of the surface motion force. wouldnt the inertia be that surface motion which is moving the player?

the nullvector actually nullifies every rotation calculation (in my tests a box was standing on one corner, and other boxes crahed into it, it never changed rotation.

well this sounds promising!

thanks for this information, one last thing however,

how do i access the intertia vector to set it null??


Good question^^ I'm not absolutly sure with the JMEPhysic implementation, in jbullet you either need to add a function the the dynamicsphysics node allowing you to override it, or you need to get access to the rigidbody wich might have functions for it, (actualy im not quite sure, since i use my own implementation)