#include "StdAfx.h"
#include "Camera.h"

CCamera::CCamera(void)
{
	this->Position = D3DXVECTOR3(0,0,-1);
	this->Target = D3DXVECTOR3(0,0,0);
	D3DXMatrixIdentity(&ProjMatrix);
}

CCamera::~CCamera(void)
{
}

void CCamera::TrackObject(CDirect3D *d3d, ObjectModel *obj)
{    
	this->Target = obj->ObjectCenter();
	this->Position = this->Target + D3DXVECTOR3(0.0f, 1.5f - obj->ObjectSpeed(), -2.5f + 1.5*obj->ObjectSpeed());
	D3DXVECTOR3 up(0.0f, 1.0f, 0.0f);
	D3DXMatrixLookAtLH(&ProjMatrix, &Position, &Target, &up);
	d3d->g_pd3dDevice->SetTransform(D3DTS_VIEW, &ProjMatrix);
}

D3DXVECTOR3 CCamera::GetPosition()
{
	return this->Position;
}

D3DXVECTOR3 CCamera::GetTarget()
{
	return this->Target;
}

D3DXMATRIX  CCamera::GetProjMatrix()
{
	return this->ProjMatrix;
}
