I’ve been trying to move a space ship around using various control classes (vehicle, hover, rigid body). I’m a bit new to this, although not to Java, so I’m definitely not understanding a few things.

Basically, I can turn the ship around with the steer method, but when I try to accelerate, the model disappears. This is happening because I’m setting gravity to 0,0,0 on the bullet app state.

My scene doesn’t have any floor, so I’d like to leave it like that with zero gravity.

Now, I’ve been thinking of calculating the force application myself, but I have no idea how to get the rotation in the form of a quaternion and create a force vector from that.

If anyone could explain this to me or at least throw me towards a good example, I’d greatly appreciate it!!

TIA,

Scott

You dont. rotational forces are applied as vectors, each component representing the force momentum for one axis. How much the object rotates depends on many things like mass, friction etc.

I mean, I understand that the quaternion represents rotation of the spatial, but how do I take the quaternion’s value for the axis of rotation and translate that into the, say, x and z vector values so I know the direction to apply the force?

You rotate a z-direction vector using the rotation quaternion:

quat.mult(Vector3f.UNIT_Z);

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

normen said:

You dont. rotational forces are applied as vectors, each component representing the force momentum for one axis. How much the object rotates depends on many things like mass, friction etc.

So it's not just a matter of spatial.getPhysicalRotation().getY() and somehow calculating the x and z components of the force?

Can you give me a gentle shove in the right direction?

I dont know what I can do more than write down the code to get the vector you are asking for?

normen said:

I dont know what I can do more than write down the code to get the vector you are asking for?

I'm sorry, I don't understand the quaternion. I can rotate the spatial fine using applyTorque(). But of course this isn't working:

Quaternion q = this.getPhysicsRotation();

applyCentralForce(new Vector3f(0, q.getY() * 1000, 0));

Please read the link and the code I posted

This works:

Quaternion q = this.getPhysicsRotation();

applyCentralForce(q.mult(Vector3f.UNIT_Z).mult(accelerationValue));