
#pragma once
#ifndef CAMERA_CONTROLLER_H
#define CAMERA_CONTROLLER_H

#include <Stuff\Stuff.hpp>

class EdGUIObject;
class ObjectManager;
class DrawInfo;
using namespace Stuff;
#define VCLIPLIMIT	2.0f;

class CameraController
{
  public:
	bool RBMode;
	bool RevMouse;
	bool TerrainFollow;

	CameraController(ObjectManager& object_manager);
	~CameraController();

	static CameraController* GetInstance();

	Stuff::YawPitchRange GetYawPitchRange() const;
	void SetYawPitchRange(Stuff::YawPitchRange ypr);

	void SetHeight(Stuff::Scalar height);
	Stuff::Scalar GetHeight() const;

	void SetSpeed(Stuff::Scalar speed);
	Stuff::Scalar GetSpeed() const;

	Stuff::Scalar GetCameraYaw() const;
	void SetCameraYaw(Stuff::Scalar yaw);

	void Reset();
	void Update();

	void SetLookAt(const Stuff::Point3D& look_at, bool adjust_to_terrain);
	Stuff::Point3D GetLookAt() const;

	void Draw(DrawInfo& dinf);

	float GetMinYaw() const { return (0); }
	float GetMaxYaw() const { return (Stuff::Two_Pi); }
	float GetMinPitch() const { return (-1.3f); }
	float GetMaxPitch() const { return (1.3f); }
	float GetMinDistance() const { return (0); }
	float GetMaxDistance() const { return (500); }
	float GetMinHeight() const { return VCLIPLIMIT; }
	float GetMaxHeight() const { return (500); }
	
//	LinearMatrix4D &GetCameraMat();
//	void SetCameraMat(LinearMatrix4D &mat);

	void  TranslateForward(float dist);

	void SaveToReg();
	void LoadFromReg();

	float GetDefaultYaw() const { return (0); }
	float GetDefaultPitch() const { return (0.25f); }
	float GetDefaultDistance() const { return (100); }

	bool StaysInsideBounds(const Stuff::Point3D& new_point, const Stuff::YawPitchRange& new_ypr) const;

	void SetLookAtMode(bool lmode);
	bool GetLookAtMode() {return LookAtMode;}
	void UpdateCamera();

	bool ProcessIO();

	void PutPointInsideBounds(Stuff::Point3D& point);
	void PutYPRInsideBounds(Stuff::YawPitchRange& ypr);

  private:
	static CameraController* m_Instance;
	Scalar m_LastCameraAnimateTime;
	Scalar LastTime,OldDistance;
	bool LookAtMode;
	


	ObjectManager& m_ObjectManager;

	Stuff::YawPitchRange m_YawPitchRange;
	Stuff::Point3D m_LookAtPoint;
	Stuff::Scalar m_Height;
	Stuff::Scalar m_Speed;
};



#endif // CAMERA_CONTROLLER_H
