IvfCamera.h

00001 //
00002 // Copyright 1999-2006 by Structural Mechanics, Lund University.
00003 //
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Library General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2 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 Library General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00017 // USA.
00018 //
00019 // Please report all bugs and problems to "ivf@byggmek.lth.se".
00020 //
00021 //
00022 // Written by Jonas Lindemann
00023 //
00024 
00025 #ifndef _CIvfCamera_h_
00026 #define _CIvfCamera_h_
00027 
00028 #include <ivf/IvfView.h>
00029 #include <ivf/IvfObject.h>
00030 
00031 #include <ivfmath/IvfViewFrustum.h>
00032 #include <ivfmath/IvfPoint3d.h> 
00033 #include <ivfmath/IvfVec3d.h>
00034 
00035 IvfSmartPointer(CIvfCamera);
00036 
00086 class IVF_API CIvfCamera : public CIvfView {
00087 public:
00088         enum TStereoEye {
00089                 SE_LEFT,
00090                 SE_RIGHT
00091         };
00092         enum TCameraType {
00093                 CT_NORMAL,
00094                 CT_FLY,
00095                 CT_FREE_ORIENTATION
00096         };
00097 private:
00098         double m_zFar;
00099         double m_zNear;
00100         double m_fov;
00101 
00102         TCameraType m_cameraType;
00103 
00104         bool m_freeOrientation;
00105 
00106         bool m_stereo;
00107         TStereoEye m_stereoEye;
00108         double m_eyeSeparation;
00109 
00110         CIvfVec3d m_up;
00111         CIvfVec3d m_sideways;
00112         CIvfVec3d m_forward;
00113         CIvfVec3d m_position;
00114         CIvfVec3d m_target;
00115 
00116 public:
00117         CIvfVec3d& getForwardVector();
00118         CIvfVec3d& getTarget();
00120         CIvfCamera();
00121 
00123         virtual ~CIvfCamera ();
00124 
00125         IvfClassInfo("CIvfCamera",CIvfView);
00126 
00135         void setPosition(GLdouble x, GLdouble y, GLdouble z);
00136 
00138         void getPosition(GLdouble &x, GLdouble &y, GLdouble &z);
00139         
00141         CIvfVec3d& getPosition();
00142 
00152         void setTarget(GLdouble x, GLdouble y, GLdouble z);
00153 
00155         void getTarget(GLdouble &x, GLdouble &y, GLdouble &z);
00156 
00158         void getUpVector(double* v);
00159 
00170         void setPerspective(double fov, double zNear, double zFar);
00171 
00173         void getPerspective(double &fov, double &zNear, double &zFar);
00174 
00182         void getViewFrustum(CIvfViewFrustum* frustum);
00183 
00195         void pickVector(int sx, int sy, double & vx, double & vy, double & vz);
00196         CIvfVec3d& pickVector(int x, int y);
00197 
00206         void getForwardVector(double &vx, double &vy, double &vz);
00207 
00214         void rotateTargetY(double angle);
00215 
00222         void rotateTargetX(double angle);
00223 
00230         void rotatePositionY(double angle);
00231 
00238         void rotatePositionX(double angle);
00239         
00246         void moveDepth(double d);
00247 
00254         void moveVertical(double d);
00255 
00262         void moveSideways(double d);
00263 
00271         void setForwardVector(CIvfVec3d& vec);
00272 
00273         void moveForward(double d);
00274         void turn(double dx, double dy, double dz);
00275 
00276         void setEyeSeparation(double separation);
00277         double getEyeSeparation();
00278         void setStereoEye(TStereoEye eye);
00279 
00280         void setStereo(bool flag);
00281         bool getStereo();
00282         
00283         void setType(TCameraType type);
00284         TCameraType getType();
00285 
00286         // Unsupported
00287 
00288         void getAbsoluteRotation(double &alfa, double &beta);
00289         void rotateAbsolute(double alfa, double beta);
00290         void moveAbsoluteDepth(double d);
00291 
00292 protected:
00293         void calcOrientation();
00294         void projectionTransform();
00295         void viewTransform();
00296 
00297         void stereoTransform();
00298 };
00299 #endif

Generated on Fri Sep 1 15:36:45 2006 for Interactive Visualisation Framework - Ivf++ by  doxygen 1.4.6-NO