// Camera.cpp: implementation of the CCamera class.
//
//////////////////////////////////////////////////////////////////////
#include "smartptr.h"
#include "Camera.h"
#include "data.h"
#include "application.h"
extern RefCountPtr<CApplication> pApp;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CCamera::CCamera()
: perspective(45.0)
{
pos.SetData(0.0f, 0.1f, 1.0f);
look.SetData(0.0f, 0.0f, -20.0f);
}
CCamera::~CCamera()
{
OutputDebugString("CCamera destructor\n");
}
void CCamera::SetPosition(GLfloat x, GLfloat y, GLfloat z)
{
pos.SetData(x, y, z);
}
void CCamera::SetPerspective(GLfloat p, bool bChange)
{
perspective = p;
if (bChange)
{
glLoadIdentity();
gluPerspective(p,
(GLfloat)pApp->pData->Window_Width /(GLfloat)pApp->pData->Window_Height,
0.1f,100.0f);
}
}
void CCamera::Draw()
{
gluLookAt(pos.x, pos.y, pos.z,
look.x, look.y, look.z,
0.0, 1.0, .0);
}
void CCamera::Move(GLfloat x, GLfloat y, GLfloat z)
{
pos.x += x;
pos.y += y;
pos.z += z;
}
void CCamera::Look(GLfloat x, GLfloat y, GLfloat z)
{
look.x += x;
look.y += y;
look.z += z;
}
void Point3d::SetData(GLfloat X, GLfloat Y, GLfloat Z)
{
x = X; y = Y; z = Z;
}