Would computing the normals be done with:
//mat3 normalMatrix = transpose(inverse(mat3(M)));
//vec3 normal = normalize(normalMatrix * vertexNormal_modelspace);
(ignore comments)?
Doing it this way oblitates the surface detail the normals I think are supposed to provide, so somethings not right for sure there.
I also fixed the issue with VertPos4 but it didn’t really help matters.
e: For some weird reason I’m getting gimbal lock with my rotation code, this didn’t happen in my older opengl code, I’m baffled.
float angleRadians;
//handles mouse motion events
if (arcball) {
// if left button is pressed
cur_mx = mx;
cur_my = my;
if (cur_mx != old_mx || cur_my != old_my)
{
LastRot = ThisRot;
lArcAngle = arcAngle;
last_axis_in_world_coord = axis_in_world_coord;
glm::vec3 va = get_arcball_vector(old_mx, old_my);
glm::vec3 vb = get_arcball_vector(cur_mx, cur_my);
angleRadians = acos(glm::min(1.0f, glm::dot(va, vb)));
arcAngle = ((angleRadians * 180) / 3.14159265);
axis_in_world_coord = glm::cross(va, vb);
old_mx = cur_mx;
old_my = cur_my;
ThisRot = glm::rotate(glm::mat4(1.0), arcAngle, -axis_in_world_coord);
ThisRot = ThisRot * LastRot;
//cout << "Angle: " << arcAngle << endl;
}
Which I then apply to:
// Rotation
glm::vec4 newCamLoc = ThisRot* cameraLoc;
glm::vec4 newCamDir = ThisRot* cameraDir;
ViewMatrix = glm::lookAt(
glm::vec3(newCamLoc.x, newCamLoc.y, newCamLoc.z), // Camera is at (0,0,3), in World Space
glm::vec3(newCamDir.x, newCamDir.y, newCamDir.z), // and looks at the origin
glm::vec3(0, 1, 0) // Head is up (set to 0,-1,0 to look upside-down)
);
Is the “up” portion of lookat screwing me here?