I need to implement a quaternion for rotating a camera. Before implementing quaternion, I use LookAt(&eye, &at, &up) for expressing a camera coordinate (vpn, vup, ...).
vec3 eye = vec3(0.0,0.0,-10.0);
vec3 to = vec3(0.0,0.0,0.0); // initial
vec3 up = vec3(0.0,1.0,0.0);
vec3 d = to - eye;
and at display callback.
m = LookAt(eye,to,up);
glUniformMatrix4fv(ModelView,1,GL_TRUE,m);
and Add an rotation (it is still euclidean rotation, and keyboard interation)
case 'a':
temp = RotateX(1.0) * vec4(d,0);
temp1 = RotateX(1.0) * vec4(up,0);
d = vec3(temp.x, temp.y, temp.z);
up = vec3(temp1.x, temp1.y, temp1.z);
eye = to - d;
break;
case 'd':
temp = RotateY(1.0) * vec4(d,0);
temp1 = RotateY(1.0) * vec4(up,0);
d = vec3(temp.x, temp.y, temp.z);
up = vec3(temp1.x, temp1.y, temp1.z);
eye = to - d;
break;
So my question is, LookAt function is only making camera coordinate? Is there any rotation matrix to make camera coordinate? As you see I make rotate my camera by using some rotation not in LookAt, I will this rotation by using quaternion. However LookAt() uses some rotation, I will implement quaternion version of LookAt to avoid gimbal lock