#include "EPSG/Camera.h"

/* EPSG Includes */
#include "EPSG/Viewport.h"

/* System Includes */
#ifdef WIN32
	#include <Windows.h>
#endif

/* OpenGL Includes */
#include <GL/GL.h>
#include <GL/GLU.h>

EPSG::Camera::Camera()
{
	_fovY = 50.0;
	_up.x = _up.z = 0.0;
	_up.y = 1.0;
	_zNear = 1;
	_zFar = 100;
}

bool EPSG::Camera::setupCamera()
{	
	EPSG::Viewport* vp = EPSG::Viewport::getActiveViewport();
	glMatrixMode( GL_PROJECTION );
	glLoadIdentity();
	gluPerspective( _fovY, (float)( vp->width / vp->height ), _zNear, _zFar );
	glMatrixMode( GL_MODELVIEW );
	glLoadIdentity();
	gluLookAt( _eye.x, _eye.y, _eye.z, 
			   _center.x, _center.y, _center.z,
			   _up.x, _up.y, _up.z );

	return true;
}

void EPSG::Camera::setFovY( float fovY )
{
	_fovY = fovY;
}

void EPSG::Camera::setZPlanes( float zNear, float zFar )
{
	_zNear = zNear;
	_zFar = _zFar;
}

void EPSG::Camera::setEye( float x, float y, float z )
{
	_eye.x = x;
	_eye.y = y;
	_eye.z = z;
}

void EPSG::Camera::setEye( Vec3<float> eye )
{
	_eye = eye;
}

void EPSG::Camera::setCenter( float x, float y, float z )
{
	_center.x = x;
	_center.y = y;
	_center.z = z;
}

void EPSG::Camera::setCenter( Vec3<float> center )
{
	_center = center;
}

void EPSG::Camera::setUp( float x, float y, float z )
{
	_up.x = x;
	_up.y = y;
	_up.z = z;
}

void EPSG::Camera::setUp( Vec3<float> up )
{
	_up = up;
}

float EPSG::Camera::getZNear()
{
	return _zNear;
}

float EPSG::Camera::getZFar()
{
	return _zFar;
}