Hello!
I am really sorry if this question is stupid.
So, I am developing a 3D game engine and I need to calculate the projection matrix for the camera. Currently, I am doing it this way:
viewMatrix.identity()
.rotateX(transform.getRotation().x)
.rotateY(transform.getRotation().y)
.rotateZ(transform.getRotation().z)
.translate(new Vector3f(transform.getPosition()).mul(-1));
where "transform" is a data container for the position and rotation of the camera. And it works. But, as I am calling this every frame, I think there should be a faster solution.
I know that the view matrix should be the inverse of the camera world matrix. So I tried this:
transform.getWorldMatrix().invert(viewMatrix);
, where getWorldMatrix() looks like this:
worldMatrix.translation(position).rotateX(rotation.x).rotateY(rotation.y).rotateZ(rotation.z).scale(scale);
which should write the inverse of the world matrix in the view matrix, but the result of that is some quite confusing. It looks like all objects are rotating around the world (0,0,0), but I am not sure if exactly this is the case.