00001 /*************************************************************************** 00002 * Copyright (C) 2004-2005 by Reality Rift Studios * 00003 * http://www.realityrift.com - mattias@realityrift.com * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 ***************************************************************************/ 00020 00021 #ifndef neo_scene_camera_h 00022 #define neo_scene_camera_h 00023 00029 #include "../core/platform.h" 00030 00031 #if NEO_ENABLE_SCENE 00032 00033 #include "../collision/frustum.h" 00034 #include "../math/matrix.h" 00035 #include "object.h" 00036 00037 namespace neo { 00038 namespace scene { 00039 00041 00043 class Camera : public Object 00044 { 00045 public: 00046 00048 enum Projection 00049 { 00051 PERSPECTIVE = 0, 00052 00054 ORTHOGRAPHIC = 1 00055 }; 00056 00058 00060 Camera( const std::string& name ); 00061 00063 virtual ~Camera(); 00064 00066 00072 virtual void setPerspective( float near, float far, float fov ); 00073 00075 00081 virtual void setOrthographic( float near, float far, float height ); 00082 00084 00087 virtual void setProjectionMode( Projection mode ); 00088 00090 00092 inline Projection getProjectionMode() const; 00093 00095 00096 inline float getZNear() const; 00097 00099 00100 inline float getZFar() const; 00101 00103 00104 inline float getFOV() const; 00105 00107 00108 inline float getHeight() const; 00109 00111 00112 virtual void render(); 00113 00115 00118 virtual void lookAt( const math::Vector3& at, const math::Vector3& up = math::Vector3::AXIS[ math::Y ] ); 00119 00121 00122 inline const collision::Frustum& getFrustum(); 00123 00125 00126 inline const math::Matrix4& getProjectionMatrix() const; 00127 00129 00130 inline const math::Matrix4& getViewMatrix(); 00131 00133 00136 virtual void set( const core::HashString& name, const core::Any& data ); 00137 00139 00142 virtual const core::Any& get( const core::HashString& name ); 00143 00145 00146 inline static Camera* getActiveCamera(); 00147 00149 00151 virtual Camera* clone() const; 00152 00153 protected: 00154 00156 static Camera* _p_active; 00157 00159 Projection _mode; 00160 00162 float _near; 00163 00165 float _far; 00166 00168 float _fov; 00169 00171 float _height; 00172 00174 math::Matrix4 _projection; 00175 00177 collision::Frustum _frustum; 00178 00181 void copyFrom( const Camera& obj ); 00182 00184 virtual void calcTransforms(); 00185 }; 00186 00187 #include "camera.inl" 00188 00189 } 00190 } 00191 00192 #endif 00193 00194 #endif
1.5.1