# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

camera.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_CAMERA_H
00027 #define NL_CAMERA_H
00028 
00029 #include "nel/3d/frustum.h"
00030 #include "3d/transform.h"
00031 
00032 
00033 namespace       NL3D
00034 {
00035 
00036 
00037 // ***************************************************************************
00038 // ClassIds.
00039 const NLMISC::CClassId          CameraId=NLMISC::CClassId(0x5752634c, 0x6abe76f5);
00040 
00041 
00042 // ***************************************************************************
00056 class CCamera : public CTransform
00057 {
00058 public:
00060         static  void    registerBasic();
00061 
00062 
00063 public:
00064 
00066         void            setFrustum(const CFrustum &f) {_Frustum= f;}
00068         const CFrustum& getFrustum() const {return _Frustum;}
00070         void            setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective= true);
00072         void            setFrustum(float width, float height, float znear, float zfar, bool perspective= true);
00074         void            getFrustum(float &left, float &right, float &bottom, float &top, float &znear, float &zfar) const;
00076         bool            isOrtho() const;
00078         bool            isPerspective() const;
00085         void            setPerspective(float fov, float aspectRatio, float znear, float zfar);
00086 
00087 
00091         bool            enableFovAnimation(bool en, float aspectRatio= 4.0f / 3.0f)
00092         {
00093                 _FovAnimationEnabled= en;
00094                 if(en)
00095                         _FovAnimationAspectRatio= aspectRatio;
00096                 return true;
00097         }
00101         bool            enableTargetAnimation(bool en)
00102         {
00103                 setTransformMode(ITransformable::RotQuat);
00104                 _TargetAnimationEnabled= en;
00105                 _Roll.Value= 0;
00106                 return true;
00107         }
00108 
00109 
00111         // @{
00115         static const char *getFovValueName() {return "fov";}
00117         static const char *getTargetValueName() {return "target";}
00119         static const char *getRollValueName() {return "roll";}
00120         // @}
00121 
00122 
00124         // @{
00125         enum    TAnimValues
00126         {
00127                 OwnerBit= CTransform::AnimValueLast,
00128                 FovValue ,
00129                 TargetValue,
00130                 RollValue,                      // Roll is the roll angle in radians.
00131 
00132                 AnimValueLast,
00133         };
00134 
00136         virtual IAnimatedValue* getValue (uint valueId);
00138         virtual const char *getValueName (uint valueId) const;
00140         virtual ITrack* getDefaultTrack (uint valueId);
00142         virtual void    registerToChannelMixer(CChannelMixer *chanMixer, const std::string &prefix);
00143 
00144         // @}
00145 
00146 
00147 protected:
00149         CCamera();
00151         virtual ~CCamera() {}
00152 
00153         // NB: znear and zfar are be >0 (if perspective).
00154         CFrustum        _Frustum;
00155 
00156 
00158         virtual void    update();
00159 
00160 
00161 private:
00162         static IModel   *creator() {return new CCamera;}
00163 
00164 
00165 private:
00166         bool                                    _FovAnimationEnabled;
00167         bool                                    _TargetAnimationEnabled;
00168         float                                   _FovAnimationAspectRatio;
00169 
00170         // AnimValues.
00171         CAnimatedValueFloat             _Fov;
00172         CAnimatedValueVector    _Target;
00173         CAnimatedValueFloat             _Roll;
00174 
00175 
00176         // Default tracks.
00177         static CTrackDefaultFloat               DefaultFov;             //( NLMISC::Pi/2 );
00178         static CTrackDefaultVector              DefaultTarget;  //( CVector::NULL );
00179         static CTrackDefaultFloat               DefaultRoll;    //( 0 );
00180 
00181 
00182 };
00183 
00184 
00185 
00186 }
00187 
00188 
00189 #endif // NL_CAMERA_H
00190 
00191 /* End of camera.h */