Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_SCENE_CAMERA_H__
00009 #define __SP_SCENE_CAMERA_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spDimension.hpp"
00014 #include "Base/spViewFrustum.hpp"
00015 #include "Base/spProjection.hpp"
00016 #include "SceneGraph/spSceneNode.hpp"
00017 #include "SceneGraph/spSceneMesh.hpp"
00018
00019 #include <vector>
00020
00021
00022 namespace sp
00023 {
00024 namespace scene
00025 {
00026
00027
00029 static const f32 DEF_PICKING_LENGTH = -1.0f;
00030
00031 #ifdef SP_COMPILE_WITH_SCENEGRAPH_PORTAL_BASED
00032 class SceneGraphPortalBased;
00033 #endif
00034
00035
00042 class SP_EXPORT Camera : public SceneNode
00043 {
00044
00045 public:
00046
00047 Camera();
00048 Camera(const dim::rect2di &Viewport, f32 NearPlane, f32 FarPlane, f32 FieldOfView = DEF_PERSPECTIVE_FOV);
00049 virtual ~Camera();
00050
00051
00052
00057 virtual void updateControl();
00058
00065 virtual void drawMenu();
00066
00073 void setRange(f32 NearRange, f32 FarRange);
00074
00076 void setRangeNear(f32 NearRange);
00078 void setRangeFar(f32 FarRange);
00079
00084 void setFOV(f32 FieldOfView);
00085
00087 void setZoom(f32 Zoom);
00089 f32 getZoom() const;
00090
00092 void setOrtho(bool isOrtho);
00093
00099 void setViewport(const dim::rect2di &Viewport);
00100
00109 void setPerspective(const dim::rect2di &Viewport, f32 NearRange, f32 FarRange, f32 FieldOfView = DEF_PERSPECTIVE_FOV);
00111 void getPerspective(dim::rect2di &Viewport, f32 &NearRange, f32 &FarRange, f32 &FieldOfView);
00112
00118 dim::point2di getProjection(dim::vector3df Position) const;
00119
00128 dim::line3df getPickingLine(const dim::point2di &Position, f32 Length = DEF_PICKING_LENGTH) const;
00129
00130 void lookAt(dim::vector3df Position, bool isGlobal = false);
00131
00136 inline void setupRenderView()
00137 {
00138 setupCameraView();
00139 updateTransformation();
00140 }
00141
00143 virtual void setupCameraView();
00144 virtual void updateTransformation();
00145
00146 Camera* copy() const;
00147
00155 const dim::matrix4f& getProjectionMatrix() const;
00156
00157
00158
00160 inline void setProjection(const Projection &Proj)
00161 {
00162 Projection_ = Proj;
00163 }
00165 inline const Projection& getProjection() const
00166 {
00167 return Projection_;
00168 }
00170 inline Projection& getProjection()
00171 {
00172 return Projection_;
00173 }
00174
00180 inline const ViewFrustum& getViewFrustum() const
00181 {
00182 return ViewFrustum_;
00183 }
00184
00186 inline f32 getRangeNear() const
00187 {
00188 return Projection_.getNearPlane();
00189 }
00191 inline f32 getRangeFar() const
00192 {
00193 return Projection_.getFarPlane();
00194 }
00195
00197 inline f32 getFOV() const
00198 {
00199 return Projection_.getFOV();
00200 }
00201
00203 inline bool getOrtho() const
00204 {
00205 return Projection_.getOrtho();
00206 }
00207
00209 inline const dim::rect2di& getViewport() const
00210 {
00211 return Projection_.getViewport();
00212 }
00213
00219 inline void setMirrorMatrix(const dim::matrix4f &Matrix)
00220 {
00221 MirrorMatrix_ = Matrix;
00222 }
00227 inline const dim::matrix4f& getMirrorMatrix() const
00228 {
00229 return MirrorMatrix_;
00230 }
00231
00241 inline void setMirror(bool isMirror)
00242 {
00243 isMirror_ = isMirror;
00244 }
00246 inline bool getMirror() const
00247 {
00248 return isMirror_;
00249 }
00250
00251 protected:
00252
00253 #ifdef SP_COMPILE_WITH_SCENEGRAPH_PORTAL_BASED
00254 friend class SceneGraphPortalBased;
00255 #endif
00256
00257
00258
00259 Projection Projection_;
00260 ViewFrustum ViewFrustum_;
00261
00262 dim::matrix4f MirrorMatrix_;
00263 bool isMirror_;
00264
00265 };
00266
00267
00268 }
00269
00270 }
00271
00272
00273 #endif
00274
00275
00276
00277