Commit | Line | Data |
---|---|---|
7faf1d71 AW |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd"> |
2 | <!-- saved from url=(0013)about:internet --> | |
3 | <?xml-stylesheet type="text/xsl" href="mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:pref="http://www.w3.org/2002/Math/preference" pref:renderer="mathplayer-dl"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>gluLookAt</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="gluLookAt"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>gluLookAt — define a viewing transformation</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">void <b class="fsfunc">gluLookAt</b>(</code></td><td>GLdouble </td><td><var class="pdparam">eyeX</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">eyeY</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">eyeZ</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">centerX</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">centerY</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">centerZ</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">upX</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">upY</var>, </td></tr><tr><td> </td><td>GLdouble </td><td><var class="pdparam">upZ</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>eyeX</code></em>, </span><span class="term"><em class="parameter"><code>eyeY</code></em>, </span><span class="term"><em class="parameter"><code>eyeZ</code></em></span></dt><dd><p> | |
4 | Specifies the position of the eye point. | |
5 | </p></dd><dt><span class="term"><em class="parameter"><code>centerX</code></em>, </span><span class="term"><em class="parameter"><code>centerY</code></em>, </span><span class="term"><em class="parameter"><code>centerZ</code></em></span></dt><dd><p> | |
6 | Specifies the position of the reference point. | |
7 | </p></dd><dt><span class="term"><em class="parameter"><code>upX</code></em>, </span><span class="term"><em class="parameter"><code>upY</code></em>, </span><span class="term"><em class="parameter"><code>upZ</code></em></span></dt><dd><p> | |
8 | Specifies the direction of the <span class="emphasis"><em>up</em></span> vector. | |
9 | </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p> | |
10 | <code class="function">gluLookAt</code> creates a viewing matrix derived from an eye point, a reference | |
11 | point indicating the center of the scene, and an <span class="emphasis"><em>UP</em></span> vector. | |
12 | </p><p> | |
13 | The matrix | |
14 | maps the reference point to the negative <span class="emphasis"><em>z</em></span> axis and the | |
15 | eye point to the origin. | |
16 | When a typical projection matrix is used, | |
17 | the center of the scene therefore maps to the center of the viewport. | |
18 | Similarly, the direction described by the <span class="emphasis"><em>UP</em></span> | |
19 | vector projected onto the viewing plane is mapped to the positive <span class="emphasis"><em>y</em></span> | |
20 | axis so that it points upward in the viewport. | |
21 | The <span class="emphasis"><em>UP</em></span> vector must not be parallel to the line of sight from the | |
22 | eye point to the reference point. | |
23 | </p><p> | |
24 | Let | |
25 | </p><p> | |
26 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
27 | ||
28 | <mml:mrow> | |
29 | <mml:mi mathvariant="italic">F</mml:mi> | |
30 | <mml:mo>=</mml:mo> | |
31 | <mml:mfenced open="(" close=")"> | |
32 | <mml:mtable> | |
33 | <mml:mtr> | |
34 | <mml:mtd> | |
35 | <mml:mrow> | |
36 | <mml:mi mathvariant="italic">centerX</mml:mi> | |
37 | <mml:mo>-</mml:mo> | |
38 | <mml:mi mathvariant="italic">eyeX</mml:mi> | |
39 | </mml:mrow> | |
40 | </mml:mtd> | |
41 | </mml:mtr> | |
42 | <mml:mtr> | |
43 | <mml:mtd> | |
44 | <mml:mrow> | |
45 | <mml:mi mathvariant="italic">centerY</mml:mi> | |
46 | <mml:mo>-</mml:mo> | |
47 | <mml:mi mathvariant="italic">eyeY</mml:mi> | |
48 | </mml:mrow> | |
49 | </mml:mtd> | |
50 | </mml:mtr> | |
51 | <mml:mtr> | |
52 | <mml:mtd> | |
53 | <mml:mrow> | |
54 | <mml:mi mathvariant="italic">centerZ</mml:mi> | |
55 | <mml:mo>-</mml:mo> | |
56 | <mml:mi mathvariant="italic">eyeZ</mml:mi> | |
57 | </mml:mrow> | |
58 | </mml:mtd> | |
59 | </mml:mtr> | |
60 | </mml:mtable> | |
61 | </mml:mfenced> | |
62 | </mml:mrow> | |
63 | </mml:math></div><p> | |
64 | </p><p> | |
65 | </p><p> | |
66 | Let <span class="emphasis"><em>UP</em></span> be the vector | |
67 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
68 | ||
69 | <mml:mfenced open="(" close=")"> | |
70 | <mml:mi mathvariant="italic">upX</mml:mi> | |
71 | <mml:mi mathvariant="italic">upY</mml:mi> | |
72 | <mml:mi mathvariant="italic">upZ</mml:mi> | |
73 | </mml:mfenced> | |
74 | </mml:math>. | |
75 | </p><p> | |
76 | Then normalize as follows: | |
77 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
78 | ||
79 | <mml:mrow> | |
80 | <mml:mi mathvariant="italic">f</mml:mi> | |
81 | <mml:mo>=</mml:mo> | |
82 | <mml:mfrac> | |
83 | <mml:mi mathvariant="italic">F</mml:mi> | |
84 | <mml:mfenced open="" close=""> | |
85 | <mml:mfenced open="∥" close="∥"> | |
86 | <mml:mi mathvariant="italic">F</mml:mi> | |
87 | </mml:mfenced> | |
88 | </mml:mfenced> | |
89 | </mml:mfrac> | |
90 | </mml:mrow> | |
91 | </mml:math></div><p> | |
92 | </p><p> | |
93 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
94 | ||
95 | <mml:mrow> | |
96 | <mml:msup><mml:mi mathvariant="italic">UP</mml:mi> | |
97 | <mml:mo>″</mml:mo> | |
98 | </mml:msup> | |
99 | <mml:mo>=</mml:mo> | |
100 | <mml:mfrac> | |
101 | <mml:mi mathvariant="italic">UP</mml:mi> | |
102 | <mml:mfenced open="" close=""> | |
103 | <mml:mfenced open="∥" close="∥"> | |
104 | <mml:mi mathvariant="italic">UP</mml:mi> | |
105 | </mml:mfenced> | |
106 | </mml:mfenced> | |
107 | </mml:mfrac> | |
108 | </mml:mrow> | |
109 | </mml:math></div><p> | |
110 | </p><p> | |
111 | </p><p> | |
112 | Finally, let | |
113 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
114 | ||
115 | <mml:mrow> | |
116 | <mml:mi mathvariant="italic">s</mml:mi> | |
117 | <mml:mo>=</mml:mo> | |
118 | <mml:mrow> | |
119 | <mml:mi mathvariant="italic">f</mml:mi> | |
120 | <mml:mo>×</mml:mo> | |
121 | <mml:msup><mml:mi mathvariant="italic">UP</mml:mi> | |
122 | <mml:mo>″</mml:mo> | |
123 | </mml:msup> | |
124 | </mml:mrow> | |
125 | </mml:mrow> | |
126 | </mml:math>, | |
127 | and | |
128 | <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
129 | ||
130 | <mml:mrow> | |
131 | <mml:mi mathvariant="italic">u</mml:mi> | |
132 | <mml:mo>=</mml:mo> | |
133 | <mml:mrow> | |
134 | <mml:mi mathvariant="italic">s</mml:mi> | |
135 | <mml:mo>×</mml:mo> | |
136 | <mml:mi mathvariant="italic">f</mml:mi> | |
137 | </mml:mrow> | |
138 | </mml:mrow> | |
139 | </mml:math>. | |
140 | </p><p> | |
141 | </p><p> | |
142 | M is then constructed as follows: | |
143 | </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"> | |
144 | ||
145 | <mml:mrow> | |
146 | <mml:mi mathvariant="italic">M</mml:mi> | |
147 | <mml:mo>=</mml:mo> | |
148 | <mml:mfenced open="(" close=")"> | |
149 | <mml:mtable> | |
150 | <mml:mtr> | |
151 | <mml:mtd> | |
152 | <mml:mrow> | |
153 | <mml:mi mathvariant="italic">s</mml:mi> | |
154 | <mml:mo></mml:mo> | |
155 | <mml:mfenced open="[" close="]"> | |
156 | <mml:mn>0</mml:mn> | |
157 | </mml:mfenced> | |
158 | </mml:mrow> | |
159 | </mml:mtd> | |
160 | <mml:mtd> | |
161 | <mml:mrow> | |
162 | <mml:mi mathvariant="italic">s</mml:mi> | |
163 | <mml:mo></mml:mo> | |
164 | <mml:mfenced open="[" close="]"> | |
165 | <mml:mn>1</mml:mn> | |
166 | </mml:mfenced> | |
167 | </mml:mrow> | |
168 | </mml:mtd> | |
169 | <mml:mtd> | |
170 | <mml:mrow> | |
171 | <mml:mi mathvariant="italic">s</mml:mi> | |
172 | <mml:mo></mml:mo> | |
173 | <mml:mfenced open="[" close="]"> | |
174 | <mml:mn>2</mml:mn> | |
175 | </mml:mfenced> | |
176 | </mml:mrow> | |
177 | </mml:mtd> | |
178 | <mml:mtd> | |
179 | <mml:mn>0</mml:mn> | |
180 | </mml:mtd> | |
181 | </mml:mtr> | |
182 | <mml:mtr> | |
183 | <mml:mtd> | |
184 | <mml:mrow> | |
185 | <mml:mi mathvariant="italic">u</mml:mi> | |
186 | <mml:mo></mml:mo> | |
187 | <mml:mfenced open="[" close="]"> | |
188 | <mml:mn>0</mml:mn> | |
189 | </mml:mfenced> | |
190 | </mml:mrow> | |
191 | </mml:mtd> | |
192 | <mml:mtd> | |
193 | <mml:mrow> | |
194 | <mml:mi mathvariant="italic">u</mml:mi> | |
195 | <mml:mo></mml:mo> | |
196 | <mml:mfenced open="[" close="]"> | |
197 | <mml:mn>1</mml:mn> | |
198 | </mml:mfenced> | |
199 | </mml:mrow> | |
200 | </mml:mtd> | |
201 | <mml:mtd> | |
202 | <mml:mrow> | |
203 | <mml:mi mathvariant="italic">u</mml:mi> | |
204 | <mml:mo></mml:mo> | |
205 | <mml:mfenced open="[" close="]"> | |
206 | <mml:mn>2</mml:mn> | |
207 | </mml:mfenced> | |
208 | </mml:mrow> | |
209 | </mml:mtd> | |
210 | <mml:mtd> | |
211 | <mml:mn>0</mml:mn> | |
212 | </mml:mtd> | |
213 | </mml:mtr> | |
214 | <mml:mtr> | |
215 | <mml:mtd> | |
216 | <mml:mrow> | |
217 | <mml:mo>-</mml:mo> | |
218 | <mml:mrow> | |
219 | <mml:mi mathvariant="italic">f</mml:mi> | |
220 | <mml:mo></mml:mo> | |
221 | <mml:mfenced open="[" close="]"> | |
222 | <mml:mn>0</mml:mn> | |
223 | </mml:mfenced> | |
224 | </mml:mrow> | |
225 | </mml:mrow> | |
226 | </mml:mtd> | |
227 | <mml:mtd> | |
228 | <mml:mrow> | |
229 | <mml:mo>-</mml:mo> | |
230 | <mml:mrow> | |
231 | <mml:mi mathvariant="italic">f</mml:mi> | |
232 | <mml:mo></mml:mo> | |
233 | <mml:mfenced open="[" close="]"> | |
234 | <mml:mn>1</mml:mn> | |
235 | </mml:mfenced> | |
236 | </mml:mrow> | |
237 | </mml:mrow> | |
238 | </mml:mtd> | |
239 | <mml:mtd> | |
240 | <mml:mrow> | |
241 | <mml:mo>-</mml:mo> | |
242 | <mml:mrow> | |
243 | <mml:mi mathvariant="italic">f</mml:mi> | |
244 | <mml:mo></mml:mo> | |
245 | <mml:mfenced open="[" close="]"> | |
246 | <mml:mn>2</mml:mn> | |
247 | </mml:mfenced> | |
248 | </mml:mrow> | |
249 | </mml:mrow> | |
250 | </mml:mtd> | |
251 | <mml:mtd> | |
252 | <mml:mn>0</mml:mn> | |
253 | </mml:mtd> | |
254 | </mml:mtr> | |
255 | <mml:mtr> | |
256 | <mml:mtd> | |
257 | <mml:mn>0</mml:mn> | |
258 | </mml:mtd> | |
259 | <mml:mtd> | |
260 | <mml:mn>0</mml:mn> | |
261 | </mml:mtd> | |
262 | <mml:mtd> | |
263 | <mml:mn>0</mml:mn> | |
264 | </mml:mtd> | |
265 | <mml:mtd> | |
266 | <mml:mn>1</mml:mn> | |
267 | </mml:mtd> | |
268 | </mml:mtr> | |
269 | </mml:mtable> | |
270 | </mml:mfenced> | |
271 | </mml:mrow> | |
272 | </mml:math></div><p> | |
273 | </p><p> | |
274 | and <code class="function">gluLookAt</code> is equivalent to | |
275 | </p><pre class="programlisting"> | |
276 | glMultMatrixf(M); | |
277 | glTranslated(-eyex, -eyey, -eyez); | |
278 | </pre><p> | |
279 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p> | |
280 | <a class="citerefentry" href="gluPerspective.xml"><span class="citerefentry"><span class="refentrytitle">gluPerspective</span></span></a>, | |
281 | <a class="citerefentry" href="glFrustum.xml"><span class="citerefentry"><span class="refentrytitle">glFrustum</span></span></a> | |
282 | </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p> | |
283 | Copyright <span class="trademark"></span>© 1991-2006 | |
284 | Silicon Graphics, Inc. This document is licensed under the SGI | |
285 | Free Software B License. For details, see | |
286 | <a class="ulink" href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>. | |
287 | </p></div></div></body></html> |