
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Predator_CameraHandler.cpp
// Author : Andy Tate
// Date   : 16-Oct-2006
//
// Copyright (C) 2006 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header...
#include "AVP_Predator_CameraHandler.h"

// Asura independent header-files...
#include "Core/Asura_Timers.h"
#include "Sound/Asura_Audio_System.h"

// Game independent header-files...
#include "Blueprint/AVP_Blueprint_HashIDs.h"
#include "Entity/PhysicalObject/Actor/Vertebrates/Predator/AVP_ClientActor_Predator.h"


////////////////////////////////////////////////////////////////////////////////
// Constant declarations...
////////////////////////////////////////////////////////////////////////////////


AVP_Actor_CameraProperties g_xCameraPropertiesPredator =
{
	0.35f,										// camera radius
	0.02f,										// pull-back speed

	0.55f,										// third person offset distance
	1.5f,										// the distance below which the offset is reduced
	Asura_Maths::DegToRad(85.0f),				// third person FOV
	0.5f,										// duration from third to first
	0.5f,										// duration from first to third
	8.0f,										// character turn speed when changing to first person camera

	3.5f,										// maximum angular velocity of the camera when rotating around the player
	0.1f,										// time taken for the angular velocity to half

	0.27f,										// half player width used for LOS corner tests
	1.001f,										// extra factor to ensure moving camera around corner

	Asura_Vector_3(0.0f, -2.1f, -0.1f),			// offset for the back of the head
	1.2f,										// distance before character starts to fade out

	1.3f,										// distance for camera to follow player inside
	3.2f,										// distance for camera to follow player outside
	1.2f,										// distance for camera to move back from player in open space
	1.3f,										// distance above which the camera looks at the player
	5.0f,										// distance for the grapple LOS tests to determine the camera move direction

	0.5f,										// factor for camera to follow player inside
	0.5f,										// factor for camera to follow player outside
	2.0f,										// factor for smoothing character height
	1.5f,										// factor for smoothing camera height
	8.0f,										// factor for moving the camera around walls
	7.0f,										// factor for moving the camera behind the player when lock is held
	0.2f,										// factor for moving the camera behind the player automatically after inactive period
												
	1.0f,										// duration to change from outside to inside camera
	1.0f,										// duration to change from inside to outside camera
	0.1f,										// duration after which the camera gives up moving behind walls and is placed in front
/*
	{											// outside camera
		0.0f,												// threshold
		Asura_Vector_3(0.0f, -2.0f, -9.0f),					// displacement (x component is to the right of the player)
		Asura_Euler_3(0.0f, 0.0f, 0.0f),					// rotation (y component is clock-wise from above)
		2.0f,												// displacement duration
		2.0f,												// rotation duration
	},
	{											// inside camera
		0.0f,												// ..
		Asura_Vector_3(0.8f, -0.5f, -2.5f),					// ...
		Asura_Euler_3(0.0f, 0.0f, 0.0f),
		2.0f,
		2.0f,
	},
	{											// grapple camera (left side; right is the mirror image of this)
		0.0f,
		Asura_Vector_3(-1.5f, 0.7f, 0.5f),	
		Asura_Euler_3(0.0f, Asura_Maths::Deg90, 0.0f),
		1.7f,
		1.7f,
	},
	{											// two-step grapple camera - step 1
		0.0f,
		Asura_Vector_3(0.0f, -0.5f, -2.5f),
		Asura_Euler_3(0.0f, 0.0f, 0.0f),
		1.0f,
		0.5f,
	},
	{											// two-step grapple camera - step 2
		0.5f,
		Asura_Vector_3(-1.5f, 0.7f, 0.5f),	
		Asura_Euler_3(0.0f, Asura_Maths::Deg90, 0.0f),
		1.7f,
		2.5f,
	},
	{
		0.0f,									// locked camera outside (left side)
		Asura_Vector_3(-10.0f, -1.5f, -0.5f),
		Asura_Euler_3(0.0f, Asura_Maths::DegToRad(50.0f), 0.0f),	// clock-wise from above
		1.0f,
		1.0f,
	},
	{
		0.0f,									// locked camera inside (left side)
		Asura_Vector_3(-5.0f, -0.7f, -1.7f),
		Asura_Euler_3(0.0f, Asura_Maths::DegToRad(50.0f), 0.0f),	// clock-wise from above
		1.0f,
		1.0f,
	},
*/
};


////////////////////////////////////////////////////////////////////////////////
// Static variable declarations...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Private functions...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Protected functions...
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
// Public functions...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Predator_CameraHandler::AVP_Predator_CameraHandler
// Author       : Andy Tate
// Date         : 16-Oct-2006
////////////////////////////////////////////////////////////////////////////////

AVP_Predator_CameraHandler::AVP_Predator_CameraHandler (const Asura_Guid uOwnerGuid)
: PARENT(uOwnerGuid, g_xCameraPropertiesPredator)
{
}

void AVP_Predator_CameraHandler::Update(AVP_ClientEntity_Actor& xOwner)
{
	PARENT::Update(xOwner);

	if ( m_uZoomLevel != 0 && Asura_Camera::GetPosition() && Asura_Camera::GetOrientation() )
	{
		Asura_Vector_3 xListenerPos;
		Asura_AVector3 xLookAtPos;
		xOwner.GetLookAtPosition( xLookAtPos );
		xListenerPos.Lerp( *Asura_Camera::GetPosition(), Asura_Vector_3( xLookAtPos ), static_cast< float >( m_uZoomLevel ) / ( AVP_CAMERA_NUM_ZOOM_LEVELS - 1 ) );
		Asura_Audio_System::SetNumberOfListeners( 2 );
		Asura_Audio_System::SetListenerPosition( xListenerPos, *Asura_Camera::GetOrientation(), 1 );
	}
	else
	{
		Asura_Audio_System::SetNumberOfListeners( 1 );
	}
}
/// End of function 'AVP_Predator_CameraHandler::AVP_Predator_CameraHandler'. ///


/// End of file. ///
