I'm working on a 3D space game with no gravity but multiple engines at the spaceship. My problem is collecting the different rotations and put them together.
If I put force to the upper and lower part (A) the ship will rotate like a screw as shown in the picture. This is working very well... but if I add a second rotation onto the spaceship, like in picture number two:
The ship rotates weird. I want to have it like in this video:
I know, that the problem is, that I multiply the rotation-matrices in the wrong order... but I tried every order and then I figured out, that with the euler-angles I always get the problem with the gimbal lock, because I split the rotation into x/y/z rotations. I don't know an other way, because in space if you make a rotation, it'll rotate infinite long... and I somehow have to save the different rotations and add them together. I also don't need a 100% physical correct rotation, and it also has to be calculated in real-time so 60 frames per second. Does someone have an idea of implementing it? BTW: At the end the ship will have a lot of engines and they are separate controllable.
I usually have some matrices:
1: model-matrix: this matrix is a 4x4 matrix which describes the position rotation and scale of the spaceship. the upper-left 3x3 matrix inside the 4x4 matrix describes the rotation and scale of the ship.
2: Rotation-matrix: this is a 3x3 matrix which describes an axis and an angle for rotating the model-matrix.
to make a rotation, I multiply the rotation-matrix with the model-matrix (upper-left 3x3 matrix). every engine(jet) makes a torque. And I split this rotation into x/y/z rotations. and add them to the rotation-matrix. That means, to stop a rotation (for example x rotation), I add the -x rotation onto the rotation-matrix.
I hope this description helps ;)
also: I don't need a 100% correct rotation. the spaceship should rotate like a sphere... maybe different models would rotate different.