After much reading, trial and error, I managed to get the following code:
void Game::Draw()
{
mat4 mProjection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
mat4 mView = glm::lookAt(cameraPosition, cameraTarget, headsUp);
mat4 mModel = mat4(1.0f);
quat qModelRotation = quat(vec3(object.rotationX, object.rotationY, object.rotationZ)); //values are in degrees 0~360 already
mat4 mModelRotation = mat4_cast(qModelRotation); //quat to mat4
mModel = mModel * mModelRotation; //applying the rotation to my model
//mModel = mModel * mModelTranslation * mModelRotation; //this if I put translation as well
mat4 MVP = mProjection * mView * mModel;
//send MVP to the shader, where gl_Position = vertex * MVP;
}
The object's rotating fine on the Z-axis, around it's center, but in the X and Y axis it's rotating around one of it's edges, why?
My object's a cube with values from -1 to 1 only.
I've been suggested to translate to the origin, rotating, and then translating, but I'm multiplying the rotation with the model without any translation and it's center is still off.