AaronCameron.net
There have to be easier ways to commit suicide.
Not a Member? - Login or Create an Account...MC Offline
Thursday the 23rd of May 2013 @ 03:38am
Front Page Journal Projects Your Profile About
[]

LibN2L-4 Library Code Reference

Classes
Compounds
Files
Members
Method Index
Full Reference

cRFreeCamera.h

Go to the documentation of this file.
00001 /************************************************************************
00002 Nova-2 Library (libN2L, or simply n2l) Game development C++ Library
00003 Copyright (C) 2003  Aaron Cameron
00004 
00005 This library is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU Lesser General Public
00007 License as published by the Free Software Foundation; either
00008 version 2.1 of the License, or (at your option) any later version.
00009 
00010 This library is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 Lesser General Public License for more details.
00014 
00015 You should have received a copy of the GNU Lesser General Public
00016 License along with this library; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00018 
00019 A copy of the GNU Lesser General Public License has been provided with
00020 this library in the file 'COPYING'.
00021 
00022 Contact information for the author of this library has been provided
00023 with this library in the file 'AUTHOR'.
00024 ************************************************************************/
00025 #ifndef _n2l4_cRFreeCamera_H
00026 #define _n2l4_cRFreeCamera_H
00027 
00028 #include "n2l/n2l.h"
00029 #include "n2l/geometry.h"
00030 
00031 /******************************************************************************/
00032 namespace n2l
00033 {
00034     class cDynVar;
00035     class cVfsNodeInterface;
00036 
00040     class cRFreeCamera
00041     {
00042     public:
00043         cRFreeCamera();
00044         cRFreeCamera( const tVector3f &iPosition,
00045             const tVector3f &iDirection, const tVector3f &iNormal );
00046 
00047         cRFreeCamera( const cVfsNodeInterface &iNode );
00048         cRFreeCamera( const cDynVar &iDef );
00049 
00050         virtual ~cRFreeCamera();
00051 
00052         void load( const cVfsNodeInterface &iNode );
00053         void load( const cDynVar &iDef );
00054 
00055         virtual void render() const;
00056 
00057         void set( const tVector3f &iPosition, const tVector3f &iDirection,
00058             const tVector3f &iNormal );
00059 
00060         inline const tVector3f &position() const { return mPos; }
00061         inline const tVector3f &pos() const { return mPos; }
00062 
00063         inline const tVector3f &direction() const { return mDir; }
00064         inline const tVector3f &dir() const { return mDir; }
00065 
00066         inline const tVector3f &normal() const { return mNormal; }
00067         inline const tVector3f &up() const { return mNormal; }
00068 
00069         inline const tUint version() const { return mVersion; }
00070 
00076         inline void pitchD( const tFloat &iAngle ) {
00077             pitchR( degToRad(iAngle) );
00078         }
00079 
00080         inline void yawD( const tFloat &iAngle ) {
00081             yawR( degToRad(iAngle) );
00082         }
00083 
00084         inline void rollD( const tFloat &iAngle ) {
00085             rollR( degToRad(iAngle) );
00086         }
00087 
00088         void pitchR( const tFloat &iAngle );
00089         void yawR( const tFloat &iAngle );
00090         void rollR( const tFloat &iAngle );
00091 
00092         inline void rotateD( const tFloat &iAngle, const tVector3f &iAxis ) {
00093             rotateR( degToRad(iAngle), iAxis ); }
00094         void rotateR( const tFloat &iAngle, const tVector3f &iAxis );
00095 
00099         void move( const tFloat &iForward, const tFloat &iLeft,
00100             const tFloat &iUp );
00101 
00106         void moveBaseBy( const tVector3f &iDelta );
00107 
00112         void moveBaseTo( const tVector3f &iPos );
00113 
00114     private:
00115         tVector3f mPos;
00116         tVector3f mDir;
00117         tVector3f mNormal;
00118 
00119         // An arbitrary number reflecting the state of the camera.
00120         // Any change to position, direction or normal will result in 
00121         // the version changing.
00122         // Note that the version has no real meaning of any kind.
00123         tUint mVersion;
00124 
00125         void init();
00126 
00127     }; // class
00128 
00129 } // namespace n2l
00130 
00131 #endif
©2013 Aaron Cameron