1GLULOOKAT(3G) GLULOOKAT(3G)
2
3
4
6 gluLookAt - define a viewing transformation
7
8
10 void gluLookAt( GLdouble eyeX,
11 GLdouble eyeY,
12 GLdouble eyeZ,
13 GLdouble centerX,
14 GLdouble centerY,
15 GLdouble centerZ,
16 GLdouble upX,
17 GLdouble upY,
18 GLdouble upZ )
19
20
22 eyeX, eyeY, eyeZ
23 Specifies the position of the eye point.
24
25 centerX, centerY, centerZ
26 Specifies the position of the reference point.
27
28 upX, upY, upZ Specifies the direction of the up vector.
29
31 gluLookAt creates a viewing matrix derived from an eye point, a refer‐
32 ence point indicating the center of the scene, and an UP vector.
33
34 The matrix maps the reference point to the negative z axis and the eye
35 point to the origin. When a typical projection matrix is used, the
36 center of the scene therefore maps to the center of the viewport. Sim‐
37 ilarly, the direction described by the UP vector projected onto the
38 viewing plane is mapped to the positive y axis so that it points upward
39 in the viewport. The UP vector must not be parallel to the line of
40 sight from the eye point to the reference point.
41
42 Let
43 centerX − eyeX
44 F=⎛⎝centerY − eyeY⎞⎠
45 centerZ − eyeZ
46
47
48 Let UP be the vector (upX,upY,upZ).
49
50 Then normalize as follows: f=|_|_FF_|_|_
51
52 UP′=|_|_UU_PP_|_|_
53
54
55 Finally, let s=f×UP′, and u=s×f.
56
57 s[0] s[1] s[2] 0
58 M is then constructed as follows: M=⎛⎝u[0] u[1] u[2] 0⎞⎠
59 −f[0] −f[1] −f[2] 0
60 0 0 0 1
61 and gluLookAt is equivalent to glMultMatrixf(M); glTranslated (-eyex,
62 -eyey, -eyez);
63
65 glFrustum(3G), gluPerspective(3G)
66
67
68
69 GLULOOKAT(3G)