#pragma once

//	Reference: This file is originally from gametutorials.com

#include "math.h"
#include "engine.h"

extern long curFrame;

class CCamera
{

public:

	CCamera();	

	vector3 Position() {	return position;		}
	vector3 View()		{	return view;			}
	vector3 UpVector() {	return upVector;		}	


	void SetCameraRadius(float radius) {	radius = radius;	};



	void PositionCamera(float positionX, float positionY, float positionZ,
			 		    float viewX,     float viewY,     float viewZ,
						float upVectorX, float upVectorY, float upVectorZ);

	void RotateView(float angle, float X, float Y, float Z);

	void SetViewByMouse(); 

	void RotateAroundPoint(vector3 vCenter, float X, float Y, float Z);

	void StrafeCamera(float speed);

	void MoveCamera(float speed);

	void CheckForMovement();

	void Update();

	void Look();

	void SetInteractive(bool interactive) {m_bInteractive = interactive;}


#if _DEBUG
	int a;
	int b;
	char buf[100];
	ofstream ifs;
	void DumpPath()
	{
		a++;
		if(a<100)return;
		a = 0;

		sprintf(buf, "%.1f %.1f %.1f %.1f %.1f %.1f\n", position.x, position.y, position.z,
			view.x, view.y, view.z);
		ifs<<buf;
		ifs.flush();
	}

		
	void OpenFile()
	{
		a = 0;
		b = 0;
		ifs.open("dump.txt");
	}
#endif

private:
	friend class engine;
	vector3* PositionRef() {	return &position;		}

	vector3* ViewRef() {	return &view;		}

	vector3* ColorRef() {	return &color;		}
	// Move the camera to the new location
	void MoveTo( vector3 NewPosition );

	vector3 position;					
	vector3 view;						
	vector3 upVector;

	float radius;
	vector3 color;
	vector3 m_vWantedMove;
	vector3 m_vStrafe;
	bool	m_bInteractive;

};



