//------------------------------------------------------------
// Tony Hyun Kim
// Spring 2007
// 18.354 Project: Lattice gas
// D3D CAMERA IMPLEMENTATION
//------------------------------------------------------------

#include "Camera.h"

Camera myCamera(100.0f);

Camera::Camera()
{
	pos   = D3DXVECTOR3(0.0f, 0.0f, -10.0f);

	up	  = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	look  = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
}

Camera::Camera(float height)
{
	pos   = D3DXVECTOR3(0.0f, 0.0f, -height);

	up	  = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
	look  = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
}

Camera::~Camera() {}

void Camera::Strafe(float units) { pos.x  += abs(pos.z)/50.0f*units; }
void Camera::Scroll(float units) { pos.y  += abs(pos.z)/50.0f*units; }
void Camera::Zoom  (float units) { pos.z  += abs(pos.z)/10.0f*units; }

void Camera::GetViewMatrix(D3DXMATRIX* V)
{
	D3DXMatrixLookAtLH(V,&pos,&(pos+look),&up);
}

const D3DXVECTOR3& Camera::GetPos()
{
	return pos;
}