apologies if this has been asked before, but I couldn't find any suitable answers for my case. I'm trying to rotate an object (collection of faces) but it rotates around the world's origin rather than the object's origin. This is my view() method for the calculation:
public static Matrix view(Vector position, Vector rotator) {
Matrix translation = Matrix.translate(new Vector(-position.getX(), -position.getY(), -position.getZ()));
Matrix rotX = Matrix.rotate(rotator.getX(), new Vector(1, 0, 0));
Matrix rotY = Matrix.rotate(rotator.getY(), new Vector(0, 1, 0));
Matrix rotZ = Matrix.rotate(rotator.getZ(), new Vector(0, 0, 1));
Matrix rotation = Matrix.multiply(rotZ, Matrix.multiply(rotY, rotX));
return Matrix.multiply(translation, rotation);
}
I have already tried swapping the translation and rotating parameters in the multiply() method but things got a bit weird upon doing so.
Also, this is my vertex shader is case anyone needs it:
gl_Position = projection * view * model * vec4(position.x , position.y, position.z, 1.0);
Anyone know the fix for this?