www.pudn.com > Gimcrack-v0.0051-Source.zip > camera.h


/////////////////////////////////////////////////// 
//												 // 
// Handels the movemnt of the camera. The code	 // 
// is based on gametutorials.com's camera		 // 
// tutorial.									 // 
//												 // 
/////////////////////////////////////////////////// 
 
#ifndef _CAMERA_H_ 
#define _CAMERA_H_ 
 
#include "math/vector.h" 
#include "frustum.h" 
 
 
class GcCamera 
{ 
public: 
 
	// Constructor / Destructor 
	GcCamera(); 
	~GcCamera(); 
 
	void SetScreen( int width, int height ) { m_screenWidth = width; m_screenHeight = height; } 
 
	/* Setting the camera's posiont, point of view, and up vector */ 
 
	// Set the camera 
	void SetCamera(GcVector3 &sPos, GcVector3 &sView, GcVector3 &sUp); 
	void SetCamera(float posX, float posY, float posZ,  
				   float viewX, float viewY, float viewZ, 
				   float upX, float upY, float upZ); 
 
	// Set the position 
	void SetPostion(GcVector3 &pos); 
	void SetPostion(float x, float y, float z); 
 
	// Set the view 
	void SetView(GcVector3 &sView); 
	void SetView(float x, float y, float z); 
 
	// Set the up vector 
	void SetUp(GcVector3 &sUp); 
	void SetUp(float x, float y, float z); 
 
	// Set the right vectro 
	void SetRight(GcVector3 &sRight); 
	void SetRight(float x, float y, float z); 
 
 
	/* Moving the camera */ 
 
	// Move forward / backward (posetive forward, negative backward) 
	void MoveFrwBack(float dist); 
 
	// Move up / down (posetive up, negative backward 
	void MoveUpDown(float dist); 
 
	// Move in direction 
	void MoveDir(GcVector3 dir, float dist); 
 
	// Strafe (posetive right, negative left) 
	void Strafe(float dist); 
 
	// Rotate the camera 
	void Rotate(float angle, float x, float y, float z); 
 
	// Roll the camera arund the view axi 
	void Roll(float angle); 
 
 
	/* Movement used for look over cameras (one not attached to a object) */ 
 
	// Use the move to look 
	void MouseLook(); 
 
	// Check for movement 
	void CheckMovement(float speed); 
 
 
	/* Update the camera */ 
 
	// To be called every frame 
	void Update(); 
 
	/* Accessors */ 
 
	GcVector3 Position() { return position; } 
	GcVector3 View()		{ return view; } 
	GcVector3 Up()		{ return up; } 
	GcVector3 Right()	{ return right; } 
 
 
private: 
 
	GcVector3	position;			// The position of the camera 
	GcVector3	view;				// The view point of the camera 
	GcVector3	up;					// Which way is up? 
	GcVector3	right;				// Which way is right? 
 
	GcFrustum	frustum;			// The frusutm (visible volyme) 
	int m_screenWidth; 
	int m_screenHeight; 
}; 
 
GcCamera * ActiveCamera(); 
 
#endif