0

I have learned from reading many sources and by re-implementing the function and studying the matrices myself, that gluLookAt() is equivalent to a rotation followed by a translation to the inverse eye coordinate. The implementation is similar in OpenGL, MESA, Cogl etc... and a good summary is here: http://pic.dhe.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.opengl/doc/openglrf/gluLookAt.htm

However, consider the case where the look-at target is at the origin i.e. (0, 0, 0), and the virtual camera is slightly offset from the Z-axis e.g. (2, 2, 10). The outcome of gluLookAt() should have the origin in the center of the field of view. The initial rotation step is of no consequence, but the later translation step moves the origin away from the center!

Can you explain my gluLookAt() misconception?

genpfault
  • 51,148
  • 11
  • 85
  • 139

2 Answers2

1

The documentation you linked to is wrong indeed.

If we have a look at another documentation, we see that the view matrix is constructed from a rotation matrix and a translation matrix as follows:

V = R * T

To transform a vertex v, we calculate

v' = V * v = R * T * v = R * (T * v)

So we first apply the translation and then the rotation. And because there is a translation, the rotation part affects also the origin. That's why it is possible to map the origin to the screen center.

Nico Schertler
  • 32,049
  • 4
  • 39
  • 70
0

Please can you explain my gluLookAt() misconception?

Your mistake lies in thinking about it as a sequence of steps. That's not how it works. gluLookAt calculates a transformation matrix that directly maps the coordinates in the desired way. There's no "intermediate" rotation step.

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
datenwolf
  • 159,371
  • 13
  • 185
  • 298