• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KGLLib

camera.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008 Rivo Laks <rivolaks@hot.ee>
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Lesser General Public
00006  * License as published by the Free Software Foundation; either 
00007  * version 2.1 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Lesser General Public 
00015  * License along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 #ifndef KGLLIB_CAMERA_H
00019 #define KGLLIB_CAMERA_H
00020 
00021 
00022 #include "kgllib.h"
00023 
00024 #include <Eigen/Geometry>
00025 
00026 namespace KGLLib
00027 {
00028 
00060 class KGLLIB_EXPORT Camera
00061 {
00062 public:
00063     Camera();
00064     virtual ~Camera();
00065 
00071     virtual void applyPerspective();
00078     virtual void applyView(bool reset = true);
00079 
00084     virtual void applyViewport();
00085 
00089     void setViewport(int x, int y, int width, int height);
00090 
00094     void setFoV(float fov);
00099     void setAspect(float aspect);
00111     void setDepthRange(float near, float far);
00112 
00116     void setPosition(const Eigen::Vector3f& pos);
00117     void setPosition(float x, float y, float z)  { setPosition(Eigen::Vector3f(x, y, z)); }
00122     void setLookAt(const Eigen::Vector3f& lookat);
00123     void setLookAt(float x, float y, float z)  { setLookAt(Eigen::Vector3f(x, y, z)); }
00128     void setUp(const Eigen::Vector3f& up);
00129     void setUp(float x, float y, float z)  { setUp(Eigen::Vector3f(x, y, z)); }
00135     void setDirection(const Eigen::Vector3f& dir);
00136     void setDirection(float x, float y, float z)  { setDirection(Eigen::Vector3f(x, y, z)); }
00137 
00138     Eigen::Vector3f position() const  { return mPosition; }
00139     Eigen::Vector3f lookAt() const  { return mLookAt; }
00140     Eigen::Vector3f up() const  { return mUp; }
00141 
00154     void setModelviewMatrix(const Eigen::Transform3f& modelview);
00167     void setProjectionMatrix(const Eigen::Transform3f& projection);
00168 
00174     Eigen::Transform3f modelviewMatrix() const;
00181     Eigen::Transform3f projectionMatrix() const;
00182 
00189     Eigen::Vector3f project(const Eigen::Vector3f& v, bool* ok = 0) const;
00196     Eigen::Vector3f unProject(const Eigen::Vector3f& v, bool* ok = 0) const;
00197 
00198 protected:
00199     void recalculateModelviewMatrix();
00200     void recalculateProjectionMatrix();
00201 
00202 protected:
00203     Eigen::Vector3f mPosition;
00204     Eigen::Vector3f mLookAt;
00205     Eigen::Vector3f mUp;
00206     float mFoV, mAspect, mDepthNear, mDepthFar;
00207 
00208     Eigen::Transform3f mModelviewMatrix;
00209     bool mModelviewMatrixDirty;
00210     Eigen::Transform3f mProjectionMatrix;
00211     bool mProjectionMatrixDirty;
00212     int mViewport[4];
00213 };
00214 
00215 }
00216 
00217 #endif

KGLLib

Skip menu "KGLLib"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • KGLLib
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal