Rotation is the rotation Quaternion of your geometry, mult is a method the Quaternion has, VectorWithMovementData is the movement Vector (probably (0,0,10.0f * tpf) or something like that) and VectorToStoreResult is the Vector you can use to translate your geometry afterwards (Geometry.move(VectorToStoreResult)).
Hi guys, I know this is an old post, but I have been struggling with the same problem for a while now. I tried to use trigonometry to solve it and other complicated methods which didn’t work The answer is actualy SOOOOO simple! To get the forward direction vector, i.e. the vector pointing in the direction the geometry is facing, you just use
@Salomon said:
Hi guys, I know this is an old post, but I have been struggling with the same problem for a while now. I tried to use trigonometry to solve it and other complicated methods which didn't work :/ The answer is actualy SOOOOO simple! To get the forward direction vector, i.e. the vector pointing in the direction the geometry is facing, you just use
And there you have it. Now all you do is spatial.move(forward.mult(tpf).mult(speed)) and you have it!
It’s clearer, better, and more logical to use:
Vector3f forward = spatial.getLocalRotation().mult(Vector3f.UNIT_Z);
…as it says exactly what it’s doing and doesn’t require the construction of a matrix.
Actually, reading yours again, it’s abnormal so maybe your model is oriented poorly and not pointing down Z. In which case, replace Vector3f.UNIT_Z with Vector3f.UNIT_X… but consider fixing your model because other things will be happier later. As it stands now, every advice you will ever see about yaw, pitch, and roll will be incorrect because for your model pitch is roll and roll is pitch.