# 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_user.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 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_USER_H
00027 #define NL_CAMERA_USER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "nel/misc/debug.h"
00031 #include "nel/3d/u_camera.h"
00032 #include "3d/transform_user.h"
00033 #include "3d/camera.h"
00034 
00035 #define NL3D_MEM_CAMERA                                 NL_ALLOC_CONTEXT( 3dCam )
00036 
00037 namespace NL3D
00038 {
00039 
00040 
00041 // ***************************************************************************
00048 class CCameraUser : virtual public UCamera, public CTransformUser
00049 {
00050 protected:
00052         CCamera                 *_Camera;
00053 
00054 
00055 public:
00056 
00058         // @{
00059         CCameraUser(CScene *scene) : 
00060           CTransformUser(scene, scene->createModel(CameraId) )
00061         {
00062                   NL3D_MEM_CAMERA
00063                 _Camera= NLMISC::safe_cast<CCamera*>(_Transform);
00064 
00065                 // Default perspective.
00066                 setFrustum(UCamera::DefLx, UCamera::DefLy, UCamera::DefLzNear, UCamera::DefLzFar);
00067         }
00068         virtual ~CCameraUser()
00069         {
00070                 NL3D_MEM_CAMERA
00071                 // deleted in CTransformUser.
00072                 _Camera= NULL;
00073         }
00074         // @}
00075 
00076 
00078         // @{
00079         virtual void            setFrustum(const CFrustum &f)
00080         {
00081                 NL3D_MEM_CAMERA
00082                 _Camera->setFrustum(f);
00083         }
00084         virtual const CFrustum& getFrustum() const 
00085         {
00086                 NL3D_MEM_CAMERA
00087                 return _Camera->getFrustum();
00088         }
00089         virtual void            setFrustum(float left, float right, float bottom, float top, float znear, float zfar, bool perspective= true)
00090         {
00091                 NL3D_MEM_CAMERA
00092                 _Camera->setFrustum(left, right, bottom, top, znear, zfar, perspective);
00093         }
00094         virtual void            setFrustum(float width, float height, float znear, float zfar, bool perspective= true)
00095         {
00096                 NL3D_MEM_CAMERA
00097                 _Camera->setFrustum(width, height, znear, zfar, perspective);
00098         }
00099         virtual void            getFrustum(float &left, float &right, float &bottom, float &top, float &znear, float &zfar) const 
00100         {
00101                 NL3D_MEM_CAMERA
00102                 _Camera->getFrustum(left, right, bottom, top, znear, zfar);
00103         }
00104         virtual bool            isOrtho() const 
00105         {
00106                 NL3D_MEM_CAMERA
00107                 return _Camera->isOrtho();
00108         }
00109         virtual bool            isPerspective() const 
00110         {
00111                 NL3D_MEM_CAMERA
00112                 return _Camera->isPerspective();
00113         }
00114         virtual void            setPerspective(float fov, float aspectRatio, float znear, float zfar) 
00115         {
00116                 NL3D_MEM_CAMERA
00117                 _Camera->setPerspective(fov, aspectRatio, znear, zfar);
00118         }
00119         // @}
00120 
00121 
00122 public:
00124         // @{
00125         CCamera         *getCamera()
00126         {
00127                 NL3D_MEM_CAMERA
00128                 return _Camera;
00129         }
00130         // @}
00131 
00132 };
00133 
00134 
00135 } // NL3D
00136 
00137 
00138 #endif // NL_CAMERA_USER_H
00139 
00140 /* End of camera_user.h */