rtsCameraController.h 2.26 KB
#include "rtsLinearAlgebra.h"

#ifndef _RTSMATH_H
#define _RTSMATH_H

#define	CAMERA_UP		-1
#define CAMERA_DOWN		 1
#define CAMERA_LEFT		-1
#define CAMERA_RIGHT	 1

struct rtsCameraState
{
	point3D<float> position;
	point3D<float> lookat;
	vector3D<float> up;
	float pers_view_angle;
	float ortho_width;
	float ortho_height;
	float near_plane;
	float far_plane;
};

class rtsCamera
{
	//members
	rtsCameraState m_camera_state;

public:

	//methods
	void RotateUpDown(double degrees);		
	void RotateLeftRight(double degrees);	
	void Pan(double x, double y);
	void Yaw(double degrees);
	void Pitch(double degrees);
	void Forward(double distance);
	void ScaleForward(double factor, double min = 0, double max = 999999);
	void DollyLeftRight(double distance);
	void DollyUpDown(double distance);
	void Zoom(double angle);
	void LookAt(point3D<float> point);
	void Position(point3D<float> point);
	void Up(vector3D<float> up);
	void DollyPosition(point3D<float> point);		//moves the camera but keeps the current orientation

	//get methods
	rtsCameraState getState();
	vector3D<float> getViewVector();
	vector3D<float> getUpVector();
	point3D<float> getPosition();
	point3D<float> getLookAtPoint();
	double getViewAngle(){return m_camera_state.pers_view_angle;}
	double getNearPlane(){return m_camera_state.near_plane;}
	double getFarPlane(){return m_camera_state.far_plane;}
	double getOrthoWidth(){return m_camera_state.ortho_width;}
	double getOrthoHeight(){return m_camera_state.ortho_height;}

	//set methods
	void setState(rtsCameraState camera_state);

	//initialization methods
	//int SetPosition(double x, double y, double z);
	//int OrthogonalCamera(double width, double height, double near, double far);
	//int LookAt(double x, double y, double z);		//looks at a point in space
	//int SetUpVector(double x, double y, double z);
	/*int InitializePerspectiveCamera(double position_x, double position_y, double position_z,
						 double lookat_x, double lookat_y, double lookat_z,
						 double up_x, double up_y, double up_z, 
						 double angle, double near_dist, double far_dist);*/
	//int InitializeCamera();							//initializes a camera to defaults

	rtsCamera();
	rtsCamera(rtsCameraState initial_state);
	~rtsCamera();
};

#endif