I implemented rotation model for earth. It orbits around me instead it rotates on its center. Some tutorial explains ordering for model is: rotation * translation.
I am figuring out but can't find solution yet. It did not work with code because it orbits around me (surface always face me around) instead of rotating its center.
prm.dmProj = glm::perspective(cam->getFOV(), double(gl.getWidth()) / double(gl.getHeight()), DIST_NEAR, DIST_FAR);
prm.dmView = glm::transpose(glm::toMat4(prm.crot));
// prm.obj.orot = glm::toMat4(body.getRotation(prm.now));
prm.obj.orot = glm::rotate(mat4d_t(1.0), glm::radians(90.0), vec3d_t(0.0, 1.0, 0.0));
prm.dmWorld = prm.dmView * glm::translate(glm::transpose(prm.obj.orot), prm.obj.cpos);
prm.mvp = mat4f_t(prm.dmProj * prm.dmWorld);
I tried to split dmWorld into dmView and dmModel but it still results the same but earth looks smaller.
prm.dmProj = glm::perspective(cam->getFOV(), double(gl.getWidth()) / double(gl.getHeight()), DIST_NEAR, DIST_FAR);
prm.dmView = glm::transpose(glm::toMat4(prm.crot));
// prm.obj.orot = glm::toMat4(body.getRotation(prm.now));
prm.obj.orot = glm::rotate(mat4d_t(1.0), glm::radians(90.0), vec3d_t(0.0, 1.0, 0.0));
prm.dmModel = glm::translate(glm::transpose(prm.obj.orot), prm.obj.cpos);
prm.mvp = mat4f_t(prm.dmProj * prm.dmView * prm.dmModel);
When I tried to rotate full 360 degrees (on Y axis) several times for flat spinning test but... Everything gradually became flat line when rotates away from earth. More spinning = more distorted like flat line effect. After more several times, it became completely horizontal flat line. I tried to rotate on its X axis and it became vertical flat line against earth on right side. I tried barrel roll several times and everything became vertical flat circle (line) on my side of me. Does anyone know any similar problem?
// Free travel mode
// Update current position and orientation (local reference frame)
// Applying angular velocity to rotation quaternion in local space.
//
// dq/dt = q * w * t/2
// w = (0, x, y, z)
//
lqrot += lqrot * wv * (dt / 2.0f);
lpos -= lqrot * tv * dt;
That is my controls from keyboard for angular and travel velocity where prm.crot = lqrot and prm.cpos = lpos, wv = angular velocity and tv = travel velocity (6 DoF controls)