
///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_FacialAnimation_FaceAnimation.h
// Author : Andy Tate
// Date   : 8-May-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __ASURA_FACIALANIMATION_FACEANIMATION_H__
#define __ASURA_FACIALANIMATION_FACEANIMATION_H__

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

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

#include "Core/Asura_HashTree.h"
#include "FacialAnimation/Asura_FacialAnimation_MuscleGroupAnimation.h"


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

class Asura_Chunk_Stream;

class Tools_FacialAnimation_FaceAnimation_FacePose;
class Tools_FacialAnimation_FacePose;
class Tools_FacialAnimation_FaceType;
class Asura_FacialAnimation_EyeParamAnimation;

//enumeration of values animated by in eye animations.
enum
{
	ASURA_FACIALANIMATION_EYE_LEFTRIGHT = 0,
	ASURA_FACIALANIMATION_EYE_UPDOWN = 1,
	ASURA_FACIALANIMATION_EYE_FOCUS = 2,
	ASURA_FACIALANIMATION_EYE_CLOSE = 3,
	ASURA_FACIALANIMATION_EYE_SQUINT = 4,
	ASURA_FACIALANIMATION_EYE_BALANCE = 5,
	ASURA_FACIALANIMATION_EYE_TARGETMIX = 6,//weighting between animation and code controlled eye values. Not certain which end of the scale is which yet.

	ASURA_FACIALANIMATION_EYE_NUMPARAM = 7,
};



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

////////////////////////////////////////////////////////////////////////////////
// Class        : Asura_FacialAnimation_FaceAnimation
// Author       : Andy Tate
// Date         : 8-May-2008
//
// Description  : Class used to store the animation for a particular face
//				  in the facial-animation system.
////////////////////////////////////////////////////////////////////////////////

class Asura_FacialAnimation_FaceAnimation
{
public:
	// Public functions...
	Asura_FacialAnimation_FaceAnimation(void);
	Asura_FacialAnimation_FaceAnimation(const Asura_Hash_ID uHash, Asura_Chunk_Stream& xStream);
	~Asura_FacialAnimation_FaceAnimation();

	// Manipulation functions...
#if defined(ASURA_TOOLS)
	void	Tools_InitialiseFromFaceType(const Asura_String& xFaceTypeName);
	void	Tools_CreateFromMuscleGroupAnimation(const Tools_FacialAnimation_MuscleGroupAnimation& xToolsFacePoseAnimation, const Tools_FacialAnimation_FaceType& xToolsFaceType);
	void	Tools_CopyEyeAnimation(const Asura_FacialAnimation_EyeParamAnimation* pxEyeParamAnimations);
	void	Tools_Rationalise(void);
#endif	//defined(ASURA_TOOLS)

	bool	Update(const float fTime, float* pfWeights, float* pfBalances, float* pfEyeValues) const;

	// Chunk-stream functions...
	void	ReadFromChunkStream(Asura_Chunk_Stream& xStream);
	void	WriteToChunkStream(Asura_Chunk_Stream& xStream) const;

	// Accessor functions...
	Asura_Hash_ID	GetFaceTypeHash(void) const	{ return(m_uFaceTypeHash); }

	float GetDuration( void ) const { return m_fDuration; }


protected:
	// Protected variables...

	// Protected functions...
	Asura_FacialAnimation_MuscleGroupAnimation*	CreateMuscleGroupAnimations(const u_int uNumMuscleGroups);


private:
	// Private variables...
	Asura_Hash_ID								m_uFaceTypeHash;			// The hash-ID of the face-type this animation can be played on.
	float										m_fDuration;				// The duration of this face-animation.
	u_int										m_uNumMuscleGroups;			// The number of muscle-groups used by this face-animation.
	Asura_FacialAnimation_MuscleGroupAnimation*	m_pxMuscleGroupAnimations;	// A pointer to the array of muscle-group animations held by this face-animation.
	Asura_FacialAnimation_EyeParamAnimation*	m_pxEyeParamAnimations;		// Array of animation data for the eye values. NULL if the animation doesn't control the eyes

	static const u_int							s_uChunkVersion;			// Current version used for reading/writing data.

	// Private functions...
	Asura_FacialAnimation_FaceAnimation(const Asura_FacialAnimation_FaceAnimation& xOther);

	Asura_FacialAnimation_FaceAnimation&	operator=(const Asura_FacialAnimation_FaceAnimation& xOther);

};   // End of class 'Asura_FacialAnimation_FaceAnimation'.

#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#endif   // ifndef __ASURA_FACIALANIMATION_FACEANIMATION_H__


/// End of file. ///
