Camera.cpp

Go to the documentation of this file.
00001 // Copyright (C) 2005 Dave Griffiths
00002 //
00003 // This program is free software; you can redistribute it and/or modify
00004 // it under the terms of the GNU General Public License as published by
00005 // the Free Software Foundation; either version 2 of the License, or
00006 // (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00016 
00017 #include "Camera.h"
00018 
00019 using namespace Fluxus;
00020     
00021 Camera::Camera() :
00022 m_Initialised(false),
00023 m_Ortho(false),
00024 m_CameraAttached(NULL),
00025 m_CameraLag(0),
00026 m_Up(-1),
00027 m_Down(1),
00028 m_Left(-0.75),
00029 m_Right(0.75),
00030 m_Front(1),
00031 m_Back(10000),
00032 m_OrthZoom(1.0f)
00033 {
00034     // default camera position
00035     m_Transform.translate(0,0,-10);
00036 }
00037 
00038 Camera::~Camera()
00039 {
00040 }
00041 
00042 void Camera::DoProjection()
00043 {
00044     if (m_Ortho) glOrtho(m_Down*m_OrthZoom,m_Up*m_OrthZoom,m_Right*m_OrthZoom,m_Left*m_OrthZoom,m_Front,m_Back);
00045     else glFrustum(m_Up,m_Down,m_Left,m_Right,m_Front,m_Back);
00046 }
00047 
00048 void Camera::DoCamera()
00049 {
00050     glMultMatrixf(m_Transform.arr());
00051 
00052     if (m_CameraAttached)
00053     {
00054         if (m_CameraLag!=0)
00055         {
00056             m_LockedMatrix.blend(m_CameraAttached->GetState()->Transform.inverse(),m_CameraLag);
00057         }
00058         else
00059         {
00060             m_LockedMatrix=m_CameraAttached->GetState()->Transform.inverse();
00061         }
00062 
00063         glMultMatrixf(m_LockedMatrix.arr());        
00064     }
00065 }
00066 
00067 void Camera::LockCamera(Primitive *p)
00068 {
00069      m_CameraAttached=p;
00070 }
00071 
00072 dMatrix Camera::GetProjection()
00073 {
00074     dMatrix Projection;
00075     glGetFloatv(GL_PROJECTION_MATRIX,Projection.arr());
00076     return Projection;
00077 }

Generated on Mon Feb 11 06:54:25 2008 for The Fluxus Renderer (libfluxus) by  doxygen 1.5.1