
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Human_AnimationHandler.h
// Author : Chris Wallace
// Date   : 25-Apr-2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef __AVP_HUMAN_ANIMATIONHANDLER_H__
#define __AVP_HUMAN_ANIMATIONHANDLER_H__

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

#include "Animation/IK/Asura_Animation_IK_Chain_LOS.h"
#include "Animation/IK/Asura_Animation_IK_Chain_MarkerPoint.h"

#include "Animation/AVP_Animation_BodyRig.h"
#include "Actor/Vertebrates/AVP_Vertebrate_AnimationHandler.h"

////////////////////////////////////////////////////////////////////////////////
// Forward class declarations...
////////////////////////////////////////////////////////////////////////////////

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)
class Asura_FacialAnimation_AnimationHandler;
#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

class AVP_ClientActor_Human;


////////////////////////////////////////////////////////////////////////////////
// Class declaration...
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Class        : AVP_Human_AnimationHandler
// Author       : Andy Tate
// Date         : 18-Oct-2006
//
// Description  : Class to handle the animations needed by the Human.
////////////////////////////////////////////////////////////////////////////////

class AVP_Human_AnimationHandler : public AVP_Vertebrate_AnimationHandler
{
public:

	// Public functions...
	AVP_Human_AnimationHandler          (AVP_ClientActor_Human& xOwner);
	virtual ~AVP_Human_AnimationHandler ();

	// Overridden functions...
	virtual void Initialise( void );
	virtual void Shutdown( void );

	virtual	void	UpdateSkin(void);

	virtual	void	Reset (void) { PARENT::Reset(); }

	virtual void	HandleAnimationRequest( const AVP_Message_Actor_RequestAnimation& xAnimRequestData );
	virtual void	Update();

	virtual const Asura_Animation_IK_Chain_LOS* GetLimbIKChainLOS( u_int uLimbItr ) const;

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)
	// Facial-animation functions...
	void	EnableFacialAnimation(void);
	void	DisableFacialAnimation(void);
#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

protected:
	// Protected variables...
	AVP_ClientActor_Human&	m_xOwnerHuman;
	int						m_iRightHandMarkerPointIndex;	// The index of the Human's right-hand marker-point.

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)
	Asura_FacialAnimation_AnimationHandler*	m_pxFacialAnimationHandler;
#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

	Asura_Animation_IK_Chain_MarkerPoint	m_xLeftArmIKChain;
	Asura_Animation_IK_Chain_LOS			m_xLeftLegIKChain;
	Asura_Animation_IK_Chain_LOS			m_xRightLegIKChain;

	// Targeting functions...
	bool	CalculateMarkerPointToCrosshairData (const Asura_Hash_ID uSourceMarkerPointHash, const float fInitialSpeed, Asura_AVector3& xPosition, Asura_AMatrix3x3& xOrientation, Asura_AVector3& xVelocity) const;

	void CreateRequestedAnimation( const Asura_Hash_ID uAnimHashID, const u_int uAnimFlags, float fTweenIn, float fTweenOut );


private:
	// Private typedefs...
	typedef AVP_Vertebrate_AnimationHandler PARENT;

	// Private functions...
	void	InitialiseIKSolver();

	AVP_Human_AnimationHandler  (void);
	AVP_Human_AnimationHandler  (const AVP_Human_AnimationHandler& xOther);
	AVP_Human_AnimationHandler&	operator=	(const AVP_Human_AnimationHandler& xOther);
};   // End of class 'AVP_Human_AnimationHandler'.


#endif   // ifndef __AVP_HUMAN_ANIMATIONHANDLER_H__


/// End of file. ///
