
///////////////////////////////////////////////////////////////////////////////
//
// File   : Asura_FacialAnimation_MuscleGroupAnimation.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_MUSCLEGROUPANIMATION_H__
#define __ASURA_FACIALANIMATION_MUSCLEGROUPANIMATION_H__

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

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


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

class Asura_Chunk_Stream;


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

////////////////////////////////////////////////////////////////////////////////
// Class        : Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame
// Author       : Andy Tate
// Date         : 8-May-2008
//
// Description  : Class used for the individual key-frames stored as part of the
//				  muscle-group in the facial-animation system.
////////////////////////////////////////////////////////////////////////////////

class Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame
{
public:
	// Public functions...
	Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame(void)	{}
	Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame(const float fTime, const float fWeight, const float fBalance)	{Set(fTime, fWeight, fBalance);}
	Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame(const Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame& xOther) : m_fTime(xOther.m_fTime), m_fWeight(xOther.m_fWeight), m_fBalance(xOther.m_fBalance)	{}
//	~Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame();

	// Operators...
	Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame& operator=(const Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame& xOther)
	{
		m_fTime		= xOther.m_fTime;
		m_fWeight	= xOther.m_fWeight;
		m_fBalance	= xOther.m_fBalance;
		return(*this);
	}

	// Accessor functions...
	float	GetTime(void) const		{ return(m_fTime); }
	float	GetWeight(void) const	{ return(m_fWeight); }
	float	GetBalance(void) const	{ return(m_fBalance); }

	void	Set(const float fTime, const float fWeight, const float fBalance)	{ m_fTime = fTime; m_fWeight = fWeight; m_fBalance = fBalance; }


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private variables...
	float	m_fTime;		// The time at which this weight begins.
	float	m_fWeight;		// The weight of this muscle-group at this point in time.
	float	m_fBalance;		// The balance of this muscle-group at this point in time.

	// Private functions...

};   // End of class 'Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame'.



////////////////////////////////////////////////////////////////////////////////
// Class        : Asura_FacialAnimation_MuscleGroupAnimation
// Author       : Andy Tate
// Date         : 8-May-2008
//
// Description  : Class used to animated a particular muscle-group as part of the
//				  facial-animation system.
////////////////////////////////////////////////////////////////////////////////

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

	// Manipulation functions...
#if defined(ASURA_TOOLS)
	bool	Tools_AddKeyFrame(const float fTime, const float fWeight, const float fBalance);
	void	Tools_RationaliseKeyFrames(void);
	void	Tools_SetKeyFrames(const class Tools_FacialAnimation_MuscleGroupAnimation& xToolsAnimation);
	float	Tools_GetLastKeyFrameTime() const;
#endif	//defined(ASURA_TOOLS)

	bool	CalculateWeightAndBalance(const float fTime, float& fWeight, float& fBalance) const;

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


protected:
	// Protected variables...

	// Protected functions...
#if defined(ASURA_TOOLS)
	u_int	Tools_MergeSameTimeKeyFrames(const u_int uNumInitialKeyFrames);
#endif	//defined(ASURA_TOOLS)


private:
	// Private variables...
	u_int													m_uNumKeyFrames;	// The number of key-frames for this animation.
	Asura_FacialAnimation_MuscleGroupAnimation_KeyFrame*	m_pxKeyFrames;		// A pointer to an array of key-frames for this animation.

	static const u_int										s_uChunkVersion;	// The version used when reading/writing.

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

	Asura_FacialAnimation_MuscleGroupAnimation&	operator=(const Asura_FacialAnimation_MuscleGroupAnimation& xOther);

};   // End of class 'Asura_FacialAnimation_MuscleGroupAnimation'.

#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#endif   // ifndef __ASURA_FACIALANIMATION_MUSCLEGROUPANIMATION_H__


/// End of file. ///
