关于gluLookAt的构造方法

It's pretty simple to build your own look-at matrix.

First, calculate forward, right, and up vectors. The forward vector should be a unit vector pointing in the direction that your camera is looking. The right and up vectors must be unit vectors, and perpendicular to each other and the forward vector. How to come up with these vectors is a matter of how your camera works, so I won't go into more detail (unless you ask).

Now, make a 3x3 matrix that has as its first row, the right vector; as its second row, the up vector; and as its third row, the NEGATIVE of the forward vector (this is so the forward vector maps onto the negative Z axis, which is the usual behavior for gluLookAt).

Finally, expand this matrix into a 4x4 (by adding a 1 in the lower-right corner and zeros elsewhere), and multiply it by a translation matrix that takes your camera location to the origin (i.e. the translation is by the negative of the camera location). And you've got a look-at matrix.
 
But the reason how to do like this is unknow,I will explain it later if i acquire it.

你可能感兴趣的:(构造方法)