Implementación de gluLookAt: orientación de zAxis

In the gluLookAt function zAxis = target - cameraPosition and then in a view matrix we put -zAxis or we can write that zAxis = cameraPosition - target and then in a view matrix we put zAxis to get the same result. Why we have to negate zAxis in the first case or change order of operation in the second case ?

preguntado el 25 de agosto de 12 a las 10:08

1 Respuestas

In OpenGL, the standard camera space is a right-handed coordinate system. +X goes to the right, and +Y goes up. Because it's right-handed, +Z goes detrás de the viewer. Thus the viewer is looking along the -Z axis. Hence the negation.

Respondido 25 ago 12, 11:08

So, when I don't use the gluLookAt function but I build my own view matrix using a camera position, xAxis, yAxis, zAxis (xAxis.x, xAxis.y, xAxis.z, -dot(xAxis, cameraPos), yAxis.x, yAxis.y, yAxis.z, -dot(yAxis, cameraPos), zAxis.x, zAxis.y, zAxis.z, -dot(zAxis, cameraPos, 0, 0, 0, 1) and then I just rotate those axes in my camera class I should define default xAxis, yAxis and zAxis this way: (1,0,0),(0,1,0),(0,0,1) ? - Irbis

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.