1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created by texi2html 1.64 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
-->
<HTML>
<HEAD>
<TITLE>Crystal Space: HOWTO Camera Movement</TITLE>
<META NAME="description" CONTENT="Crystal Space: HOWTO Camera Movement">
<META NAME="keywords" CONTENT="Crystal Space: HOWTO Camera Movement">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">
</HEAD>
<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">
<A NAME="SEC244"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_119.html#SEC237"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_121.html#SEC247"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_108.html#SEC209"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_116.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_128.html#SEC290"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<HR SIZE=1>
<H3> 5.8.4 Camera Movement </H3>
<!--docid::SEC244::-->
<P>
This section describes how to move the camera.
</P><P>
<A NAME="SEC245"></A>
<H4> The Camera is a Transform </H4>
<!--docid::SEC245::-->
<P>
Internally in the engine the `<SAMP>csCamera</SAMP>' class inherits
directly from `<SAMP>csOrthoTransform</SAMP>' which inherits from
`<SAMP>csReversibleTransform</SAMP>'. If you work with `<SAMP>iCamera</SAMP>' then you
can get the reference to this transform with <CODE>camera->GetTransform()</CODE>.
In addition the transformation a camera also holds a pointer to the
current sector.
</P><P>
This means that all operations you have in `<SAMP>csOrthoTransform</SAMP>' can
be used on the camera. One of the most useful functions there is
<CODE>LookAt()</CODE> with which you can make the camera point to some spot.
Using <CODE>LookAt()</CODE> it is very easy to make a 3rd person view.
</P><P>
In addition to the standard functions from `<SAMP>csOrthoTransform</SAMP>' there
are a number of other functions that you can use. The most interesting
are <CODE>MoveWorld()</CODE> and <CODE>Move()</CODE>. These functions will move
the camera and make sure that it cannot walk through a wall and also make
sure that walking through portals will work. Both functions move the
camera a relative amount. The difference between <CODE>MoveWorld()</CODE> and
<CODE>Move()</CODE> is that the latter will move the camera in camera space.
For example, take the following code:
</P><P>
<TABLE><tr><td> </td><td class=example><pre> iCamera* camera;
camera->GetTransform ().Move (csVector3 (0, 0, 1));
</pre></td></tr></table></P><P>
This will move the camera forward in camera space. This means that the
camera will walk 'forward' :-) On the other hand:
</P><P>
<TABLE><tr><td> </td><td class=example><pre> iCamera* camera;
camera->GetTransform ().MoveWorld (csVector3 (0, 0, 1));
</pre></td></tr></table></P><P>
This will move the camera in the world so that it goes one unit in
the positive Z direction. This will happen independently of the orientation
of the camera.
</P><P>
<A NAME="SEC246"></A>
<H4> Include Files </H4>
<!--docid::SEC246::-->
<P>
The include files useful for this section are:
</P><P>
<TABLE><tr><td> </td><td class=example><pre> #include "iengine/camera.h"
#include "csgeom/transfrm.h"
</pre></td></tr></table></P><P>
<A NAME="HOWTO Pseudo DynLight"></A>
<HR SIZE=1>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_119.html#SEC237"> < </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_121.html#SEC247"> > </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_108.html#SEC209"> << </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_116.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_128.html#SEC290"> >> </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT"> <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<BR>
<FONT SIZE="-1">
This document was generated
using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>
</BODY>
</HTML>
|