Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
E:/Programming/MyProject/K_Game_hg/GameEngine/include/render/Camera.h
Go to the documentation of this file.
00001 // Copyright 2006-2011 by Kat'Oun
00002 
00003 #ifndef _CAMERA_H_
00004 #define _CAMERA_H_
00005 
00006 #include <EngineConfig.h>
00007 #include <core/Types.h>
00008 #include <core/Matrix4.h>
00009 #include <core/Vector3d.h>
00010 #include <scene/Node.h>
00011 
00012 namespace render
00013 {
00014 
00015 class Frustum;
00016 
00018 enum ProjectionType
00019 {
00020         PT_ORTHOGRAPHIC,
00021         PT_PERSPECTIVE
00022 };
00023 
00025 enum SceneDetailLevel
00026 {
00027         SDL_POINTSONLY,
00028         SDL_WIREFRAME,
00029         SDL_FLATSHADE,
00030         SDL_SMOOTHSHADE,
00031         SDL_TEXTURED
00032 };
00033 
00035 
00044 
00051 class ENGINE_PUBLIC_EXPORT Camera: public scene::Node
00052 {
00053 public:
00054 
00055         Camera();
00056         Camera(const std::string& name);
00057 
00058         ~Camera();
00059 
00061         void setProjectionType(ProjectionType pt);
00063         ProjectionType getProjectionType();
00064         
00070         void setDirection(f32 x, f32 y, f32 z);
00072         void setDirection(const core::vector3d& vec);
00073 
00079         void lookAt(const core::vector3d& targetPoint);
00080         
00086         void lookAt(f32 x, f32 y, f32 z);
00087 
00088         void setFixedUpAxis(bool useFixed, const core::vector3d& fixedAxis = core::vector3d::UNIT_Y);
00089         
00090         //Transformations on all coordinates
00091         void rotate(const core::quaternion& q, scene::TransformSpace relativeTo = scene::TS_LOCAL);
00092 
00093         void rotate(const f32& degrees, const core::vector3d& axis, scene::TransformSpace relativeTo = scene::TS_LOCAL);
00094         void rotateX(f32 degrees, scene::TransformSpace relativeTo = scene::TS_LOCAL);
00095         void rotateY(f32 degrees, scene::TransformSpace relativeTo = scene::TS_LOCAL);
00096         void rotateZ(f32 degrees, scene::TransformSpace relativeTo = scene::TS_LOCAL);
00097         
00106         void setFOV(f32 fov);
00108         f32 getFOV();
00109         
00120         void setNearClipDistance(f32 nearDist);
00121 
00123         f32 getNearClipDistance();
00124 
00126 
00138         void setFarClipDistance(f32 farDist);
00139 
00141         f32 getFarClipDistance();
00142 
00149         void setAspectRatio(f32 ratio);
00150 
00152         f32 getAspectRatio();
00153 
00155 
00160         void setDetailLevel(SceneDetailLevel sd);
00162         SceneDetailLevel getDetailLevel();
00163 
00165         const core::matrix4& getProjectionMatrixRS();
00166 
00170         const core::matrix4& getProjectionMatrix();
00171 
00173         const core::matrix4& getViewMatrix();
00174 
00176         Frustum* getFrustum() const;
00177 
00178 protected:
00179 
00180         // Incremented count for next index
00181         static u32 msNextGeneratedCameraIndex;
00182 
00183         void initProperties();
00184 
00185         // Whether to use a fixed Up axis.
00186         bool mFixedUp;
00187         // Fixed Up axis
00188         core::vector3d mFixedUpAxis;
00189 
00190         f32 mFOV;                               // Camera y-direction field-of-view (default 45)
00191         f32 mAspect;                    // x/y viewport ratio - default 1.3333
00192         f32 mNearDist;                  // Near clip distance - default 1
00193         f32 mFarDist;                   // Far clip distance - default 1000     
00194 
00195         Frustum* mFrustum;
00196 
00197         ProjectionType mProjType;               // Orthographic or perspective?
00198         SceneDetailLevel mSceneDetail;  // Rendering type
00199         
00200         void updateImpl(f32 elapsedTime);
00201 
00202         core::matrix4 mProjMatrixRS;    // Pre-calced projection matrix for the specific render system
00203         core::matrix4 mProjMatrix;              // Pre-calced projection matrix
00204         core::matrix4 mViewMatrix;              // Pre-calced view matrix       
00205         
00206         bool mModifiedProjection;       // Something's changed in the projection?
00207         bool mModifiedView;             // Something's changed int the view?
00208 
00209         void updateProjection();
00210         void updateView();
00211         void updateFrustum();
00212 };
00213 
00214 } //namespace render
00215 
00216 #endif

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:04 by Doxygen (1.7.4)