370 lines
17 KiB
XML
370 lines
17 KiB
XML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
|
||
|
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
|
||
|
<refentry id="gluLookAt">
|
||
|
<refmeta>
|
||
|
<refmetainfo>
|
||
|
<copyright>
|
||
|
<year>1991-2006</year>
|
||
|
<holder>Silicon Graphics, Inc.</holder>
|
||
|
</copyright>
|
||
|
</refmetainfo>
|
||
|
<refentrytitle>gluLookAt</refentrytitle>
|
||
|
<manvolnum>3G</manvolnum>
|
||
|
</refmeta>
|
||
|
<refnamediv>
|
||
|
<refname>gluLookAt</refname>
|
||
|
<refpurpose>define a viewing transformation</refpurpose>
|
||
|
</refnamediv>
|
||
|
<refsynopsisdiv><title>C Specification</title>
|
||
|
<funcsynopsis>
|
||
|
<funcprototype>
|
||
|
<funcdef>void <function>gluLookAt</function></funcdef>
|
||
|
<paramdef>GLdouble <parameter>eyeX</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>eyeY</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>eyeZ</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>centerX</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>centerY</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>centerZ</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>upX</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>upY</parameter></paramdef>
|
||
|
<paramdef>GLdouble <parameter>upZ</parameter></paramdef>
|
||
|
</funcprototype>
|
||
|
</funcsynopsis>
|
||
|
</refsynopsisdiv>
|
||
|
<!-- eqn: ignoring delim $$ -->
|
||
|
<refsect1 id="parameters"><title>Parameters</title>
|
||
|
<variablelist>
|
||
|
<varlistentry>
|
||
|
<term><parameter>eyeX</parameter></term>
|
||
|
<term><parameter>eyeY</parameter></term>
|
||
|
<term><parameter>eyeZ</parameter></term>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Specifies the position of the eye point.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</varlistentry>
|
||
|
<varlistentry>
|
||
|
<term><parameter>centerX</parameter></term>
|
||
|
<term><parameter>centerY</parameter></term>
|
||
|
<term><parameter>centerZ</parameter></term>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Specifies the position of the reference point.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</varlistentry>
|
||
|
<varlistentry>
|
||
|
<term><parameter>upX</parameter></term>
|
||
|
<term><parameter>upY</parameter></term>
|
||
|
<term><parameter>upZ</parameter></term>
|
||
|
<listitem>
|
||
|
<para>
|
||
|
Specifies the direction of the <emphasis>up</emphasis> vector.
|
||
|
</para>
|
||
|
</listitem>
|
||
|
</varlistentry>
|
||
|
</variablelist>
|
||
|
</refsect1>
|
||
|
<refsect1 id="description"><title>Description</title>
|
||
|
<para>
|
||
|
<function>gluLookAt</function> creates a viewing matrix derived from an eye point, a reference
|
||
|
point indicating the center of the scene, and an <emphasis>UP</emphasis> vector.
|
||
|
</para>
|
||
|
<para>
|
||
|
The matrix
|
||
|
maps the reference point to the negative <emphasis>z</emphasis> axis and the
|
||
|
eye point to the origin.
|
||
|
When a typical projection matrix is used,
|
||
|
the center of the scene therefore maps to the center of the viewport.
|
||
|
Similarly, the direction described by the <emphasis>UP</emphasis>
|
||
|
vector projected onto the viewing plane is mapped to the positive <emphasis>y</emphasis>
|
||
|
axis so that it points upward in the viewport.
|
||
|
The <emphasis>UP</emphasis> vector must not be parallel to the line of sight from the
|
||
|
eye point to the reference point.
|
||
|
</para>
|
||
|
<para>
|
||
|
Let
|
||
|
</para>
|
||
|
<para>
|
||
|
<informalequation><mml:math>
|
||
|
<!-- eqn: F = left ( matrix { ccol { centerX - eyeX above centerY - eyeY above centerZ - eyeZ } } right ):-->
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">F</mml:mi>
|
||
|
<mml:mo>=</mml:mo>
|
||
|
<mml:mfenced open="(" close=")">
|
||
|
<mml:mtable>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">centerX</mml:mi>
|
||
|
<mml:mo>-</mml:mo>
|
||
|
<mml:mi mathvariant="italic">eyeX</mml:mi>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">centerY</mml:mi>
|
||
|
<mml:mo>-</mml:mo>
|
||
|
<mml:mi mathvariant="italic">eyeY</mml:mi>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">centerZ</mml:mi>
|
||
|
<mml:mo>-</mml:mo>
|
||
|
<mml:mi mathvariant="italic">eyeZ</mml:mi>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
</mml:mtable>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:math></informalequation>
|
||
|
</para>
|
||
|
<para>
|
||
|
</para>
|
||
|
<para>
|
||
|
Let <emphasis>UP</emphasis> be the vector
|
||
|
<inlineequation><mml:math>
|
||
|
<!-- eqn: (upX, upY, upZ):-->
|
||
|
<mml:mfenced open="(" close=")">
|
||
|
<mml:mi mathvariant="italic">upX</mml:mi>
|
||
|
<mml:mi mathvariant="italic">upY</mml:mi>
|
||
|
<mml:mi mathvariant="italic">upZ</mml:mi>
|
||
|
</mml:mfenced>
|
||
|
</mml:math></inlineequation>.
|
||
|
</para>
|
||
|
<para>
|
||
|
Then normalize as follows:
|
||
|
<informalequation><mml:math>
|
||
|
<!-- eqn: f = F over {|| F ||}:-->
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">f</mml:mi>
|
||
|
<mml:mo>=</mml:mo>
|
||
|
<mml:mfrac>
|
||
|
<mml:mi mathvariant="italic">F</mml:mi>
|
||
|
<mml:mfenced open="" close="">
|
||
|
<mml:mfenced open="∥" close="∥">
|
||
|
<mml:mi mathvariant="italic">F</mml:mi>
|
||
|
</mml:mfenced>
|
||
|
</mml:mfenced>
|
||
|
</mml:mfrac>
|
||
|
</mml:mrow>
|
||
|
</mml:math></informalequation>
|
||
|
</para>
|
||
|
<para>
|
||
|
<informalequation><mml:math>
|
||
|
<!-- eqn: UP sup prime = UP over {|| UP ||}:-->
|
||
|
<mml:mrow>
|
||
|
<mml:msup><mml:mi mathvariant="italic">UP</mml:mi>
|
||
|
<mml:mo>″</mml:mo>
|
||
|
</mml:msup>
|
||
|
<mml:mo>=</mml:mo>
|
||
|
<mml:mfrac>
|
||
|
<mml:mi mathvariant="italic">UP</mml:mi>
|
||
|
<mml:mfenced open="" close="">
|
||
|
<mml:mfenced open="∥" close="∥">
|
||
|
<mml:mi mathvariant="italic">UP</mml:mi>
|
||
|
</mml:mfenced>
|
||
|
</mml:mfenced>
|
||
|
</mml:mfrac>
|
||
|
</mml:mrow>
|
||
|
</mml:math></informalequation>
|
||
|
</para>
|
||
|
<para>
|
||
|
</para>
|
||
|
<para>
|
||
|
Finally, let
|
||
|
<inlineequation><mml:math>
|
||
|
<!-- eqn: s = f times UP sup prime:-->
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">s</mml:mi>
|
||
|
<mml:mo>=</mml:mo>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">f</mml:mi>
|
||
|
<mml:mo>×</mml:mo>
|
||
|
<mml:msup><mml:mi mathvariant="italic">UP</mml:mi>
|
||
|
<mml:mo>″</mml:mo>
|
||
|
</mml:msup>
|
||
|
</mml:mrow>
|
||
|
</mml:mrow>
|
||
|
</mml:math></inlineequation>,
|
||
|
and
|
||
|
<inlineequation><mml:math>
|
||
|
<!-- eqn: u = s times f:-->
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">u</mml:mi>
|
||
|
<mml:mo>=</mml:mo>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">s</mml:mi>
|
||
|
<mml:mo>×</mml:mo>
|
||
|
<mml:mi mathvariant="italic">f</mml:mi>
|
||
|
</mml:mrow>
|
||
|
</mml:mrow>
|
||
|
</mml:math></inlineequation>.
|
||
|
</para>
|
||
|
<para>
|
||
|
</para>
|
||
|
<para>
|
||
|
M is then constructed as follows:
|
||
|
<informalequation><mml:math>
|
||
|
<!-- eqn: M = left ( matrix { ccol { s[0] above u[0] above -f[0] above 0 } ccol { s[1] above u[1] above -f[1] above 0 } ccol { s[2] above u[2] above -f[2] above 0 } ccol { 0 above 0 above 0 above 1 } } right ):-->
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">M</mml:mi>
|
||
|
<mml:mo>=</mml:mo>
|
||
|
<mml:mfenced open="(" close=")">
|
||
|
<mml:mtable>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">s</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">s</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>1</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">s</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>2</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">u</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">u</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>1</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">u</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>2</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mo>-</mml:mo>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">f</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mo>-</mml:mo>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">f</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>1</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mrow>
|
||
|
<mml:mo>-</mml:mo>
|
||
|
<mml:mrow>
|
||
|
<mml:mi mathvariant="italic">f</mml:mi>
|
||
|
<mml:mo>⁡</mml:mo>
|
||
|
<mml:mfenced open="[" close="]">
|
||
|
<mml:mn>2</mml:mn>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:mrow>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
<mml:mtr>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>0</mml:mn>
|
||
|
</mml:mtd>
|
||
|
<mml:mtd>
|
||
|
<mml:mn>1</mml:mn>
|
||
|
</mml:mtd>
|
||
|
</mml:mtr>
|
||
|
</mml:mtable>
|
||
|
</mml:mfenced>
|
||
|
</mml:mrow>
|
||
|
</mml:math></informalequation>
|
||
|
</para>
|
||
|
<para>
|
||
|
and <function>gluLookAt</function> is equivalent to
|
||
|
<programlisting>
|
||
|
glMultMatrixf(M);
|
||
|
glTranslated(-eyex, -eyey, -eyez);
|
||
|
</programlisting>
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
<refsect1 id="seealso"><title>See Also</title>
|
||
|
<para>
|
||
|
<citerefentry><refentrytitle>gluPerspective</refentrytitle></citerefentry>,
|
||
|
<citerefentry><refentrytitle>glFrustum</refentrytitle></citerefentry>
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
<refsect1 id="Copyright"><title>Copyright</title>
|
||
|
<para>
|
||
|
Copyright <trademark class="copyright"></trademark> 1991-2006
|
||
|
Silicon Graphics, Inc. This document is licensed under the SGI
|
||
|
Free Software B License. For details, see
|
||
|
<ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>.
|
||
|
</para>
|
||
|
</refsect1>
|
||
|
</refentry>
|