#ifndef __CAMERA_HEADER__
#define __CAMERA_HEADER__

#include "vl/VLd.h"
//#include "mat.h"

//==========[ class Camera ]===================================================

typedef enum { kActionNone, kActionTranslate, kActionRotate, kActionZoom, kActionTwist,} MouseAction_t;

class Camera {

protected:

	double		mElevation;
	double		mAzimuth;
	double		mDolly;
	double		mTwist;

	Vec3d		mLookAt;

	Vec3d		mPosition;
	Vec3d		mUpVector;
	bool		mDirtyTransform;

	void calculateViewingTransformParameters();

	//EADD
	Vec3d			mLastMousePosition;
	MouseAction_t	mCurrentMouseAction;
	

public:

	//---[ Constructors ]----------------------------------

		// defaults to (0,0,0) facing down negative z axis
	Camera();
		// sets up view transform with camera at position looking at lookAt
	Camera( Vec3d position, Vec3d lookAt );

	//---[ Settings ]--------------------------------------

	inline void setElevation( double elevation ) 
		{ mElevation = elevation; mDirtyTransform = true; }
	inline double getElevation() const
		{ return mElevation; }

	inline void setAzimuth( double azimuth )
		{ mAzimuth = azimuth; mDirtyTransform = true; }
	inline double getAzimuth() const
		{ return mAzimuth; }

	inline void setDolly( double dolly )
		{ mDolly = dolly; mDirtyTransform = true; }
	inline double getDolly() const
		{ return mDolly; }

	inline void setTwist( double twist )
		{ mTwist = twist; mDirtyTransform = true; }
	inline double getTwist() const
		{ return mTwist; }

	inline void setLookAt( const Vec3d &lookAt )
		{ mLookAt = lookAt; mDirtyTransform = true; }
	inline Vec3d getLookAt() const
		{ return mLookAt; }

	inline Vec3d getPosition() const { return mPosition; }
	inline Vec3d getUpVector() const { return mUpVector; }
	
	//---[ Interactive Adjustment ]------------------------
	// these should be used from a mouse event handling routine that calls
	// the startX method on a mouse down, updateX on mouse move and finally
	// endX on mouse up.
	//-----------------------------------------------------
	
	void clickMouse( MouseAction_t action, int x, int y );
	void dragMouse( int x, int y );
	void releaseMouse( int x, int y );

	//---[ Viewing Transform ]--------------------------------
	void applyViewingTransform();
};

#endif
