Page 156 - Computer Graphics Handout
P. 156

4.3.3 The Look-At Function
          The use of the VRP, VPN, and VUP is but one way to provide an API for specifying the position of a camera. In many situations, a
          more direct method is appropriate. Consider the situation illustrated in Figure 4.18. Here a camera is located at a point e called the
          eye point, specified in the object frame, and it is pointed at a second point a, called the at point. These points determine a VPN and


























          a VRP. The VPN is given by  the vector formed by point subtraction between the eyepoint and the at point, vpn = a – e,
          and normalizing it,



                       .
          The view-reference point is the eye point. Hence, we need only to add the desired up direction for the camera, and a function to
                                                        28
          construct the desired matrix LookAt could be of the form
          mat4 LookAt(point4 eye, point4 at, vec4 up)
          or the equivalent form
          mat4 LookAt(Glfloat eyex, Glfloat eyey, Glfloat eyez,
          Glfloat atx, Glfloat aty, Glfloat atz,
          Glfloat upx, Glfloat upy, Glfloat upz);
          Note that once we have computed the vector vpn, we can proceed as we did with forming the transformation in the previous
          section. A slightly simpler computation would be to form a vector perpendicular to n and vup by taking their cross product and
          normalizing it,























          28  Because we are working in homogeneous coordinates, vup can be a vec4 type if the fourth component is a zero.

                                                             156
   151   152   153   154   155   156   157   158   159   160   161