#ifndef CAMERA_H_INCLUDED
#define CAMERA_H_INCLUDED 1

#include "Tuple.h"
#include "Ball.h"

class Camera
{
private:

	// Constants
	static const double MAX_D;
	static const double MIN_D;
	static const double DEF_STEP;

	// Member variables
	double theta_;
	double phi_;
	double d_;
	const Tuple* pTrack_; // a point we're following or NULL
	Tuple lookAt_;  // the point we're looking at otherwise

	bool axes_; // toggles axis drawing

	int currX_, currY_; // for rotate()

public:
	Camera(double theta = 0.1, double phi = 0, double d = 15);
	~Camera(void);

	// Must be called before the camera can be used
	void init();

	// Meant to be called in world's display() function
	void display();

	// Toggle between chase modes
	// Outputs the result of the toggle
	void track(const Tuple* pTrack = NULL);
	bool tracking()	const						{return pTrack_ != NULL;}

	// Axes get/set
	void axesOn()  {axes_ = true;}
	void axesOff() {axes_ = false;}
	void axesToggle() {axes_ = !axes_;}
	bool axes() const {return axes_;}

	// Rotates camera based on given x,y
	void rotate(int x, int y, int width, int height);

	// Move the camera
	void moveForward(double dist = DEF_STEP*2);
	void moveBackward(double dist = DEF_STEP*2);
	void moveLeft(double dist = DEF_STEP);
	void moveRight(double dist = DEF_STEP);
	void moveUp(double dist = DEF_STEP);
	void moveDown(double dist = DEF_STEP);

	// Zooming
	void zoomIn  (double dist = DEF_STEP);
	void zoomOut (double dist = DEF_STEP);

	// Accessors
	const Tuple lookAt() const	{return lookAt_;}
	const double theta() const	{return theta_;}
	const double phi() const	{return phi_;}
	const Tuple direction() const;

	// Prints debug info
	void debug() const;
};


#endif // CAMERA_H_INCLUDED