00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
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 }