/*
*	CameraMovement.cpp
*	----------------------------------------
*	A part of "Intelligent AI"
*	© 2001 SCC Team 064
*	----------------------------------------
*
*	This file:
*		€ Directs the manipulation of the camera as directed by the input devices.
*/


#include "MacInput.h"

Boolean		movingForward = false;
Boolean		movingBackward = false;
Boolean		movingLeft = false;
Boolean		movingRight = false;
Boolean		cRotate = false;
Boolean		sideways = true;

float		cameraY, cameraX, cameraZ = 0; 
float 		Azimuth = 0;
float 		cSpeed= 0.3;


/*										Camera Manipulation									*/
/*------------------------------------------------------------------------------------------*/
/*									Move and Rotate the Camera								*/

void CameraManip()
{
	if ((Azimuth) >= 2 * M_PI)
		Azimuth -= (2 * M_PI);
	if ((Azimuth) <= - 2 * M_PI)
		Azimuth += (2 * M_PI);

/* 	Camera Movement
//------------------------------------------------------------------------------------------

	/* Simple, mouse-driven flight model */
	if (movingForward)
	{
		cameraY += (cos(Azimuth) * cSpeed);
		cameraX += (sin(Azimuth) * cSpeed);
		movingForward = false;
	}

	if (movingBackward)
	{
		cameraY -= (cos(Azimuth) * cSpeed);
		cameraX -= (sin(Azimuth) * cSpeed);
		movingBackward = false;
	}

	if (sideways)
	{
		if (movingLeft)
		{
			cameraY += (sin(Azimuth) * cSpeed);
			cameraX -= (cos(Azimuth) * cSpeed);
		}

		if (movingRight)
		{
			cameraY -= (sin(Azimuth) * cSpeed);
			cameraX += (cos(Azimuth) * cSpeed);
		}
	}

	if (cRotate)
	{
		if ( movingLeft )
		{
			Azimuth -= (1. * DEG_TO_RAD);			// Update The Y Rotation
		}
		else if ( movingRight )
		{
			Azimuth += (1 * DEG_TO_RAD);			// Update The Y Rotation
		}
	}
}
