00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00066 setFrustum(UCamera::DefLx, UCamera::DefLy, UCamera::DefLzNear, UCamera::DefLzFar);
00067 }
00068 virtual ~CCameraUser()
00069 {
00070 NL3D_MEM_CAMERA
00071
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 }
00136
00137
00138 #endif // NL_CAMERA_USER_H
00139
00140