
///////////////////////////////////////////////////////////////////////////////
//
// File   : Tools_FacialAnimation_FaceAnimation_FacePose.h
// Author : Andy Tate
// Date   : 5-Aug-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

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

#ifndef __TOOLS_FACIALANIMATION_FACEANIMATION_FACEPOSE_H__
#define __TOOLS_FACIALANIMATION_FACEANIMATION_FACEPOSE_H__

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

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

#include "Core/Asura_LinkList.h"


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

class Asura_Chunk_Stream;


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

////////////////////////////////////////////////////////////////////////////////
// Class        : Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame
// Author       : Andy Tate
// Date         : 5-Aug-2008
//
// Description  : Class used to store the individual key-frames when animating 
//				  a particular face-pose.
////////////////////////////////////////////////////////////////////////////////

class Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame
{
public:
	// Public functions...
	Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame(void)	{}
	Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame(const u_int uMS, const float fWeight)	: m_fTime(static_cast<float>(uMS) * 0.001f), m_fWeight(fWeight) {}
	Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame(const float fTime, const float fWeight)	: m_fTime(fTime), m_fWeight(fWeight) {}
	Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame(const Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame& xOther)	: m_fTime(xOther.m_fTime), m_fWeight(xOther.m_fWeight)	{}
	//~Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame();

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

	bool operator<(const Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame& xOther) const
	{
		return(m_fTime < xOther.m_fTime);
	}

	bool operator>(const Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame& xOther) const
	{
		return(m_fTime > xOther.m_fTime);
	}

	// Accessor functions...
	void	Set(const u_int uMS, const float fWeight)	{ m_fTime = static_cast<float>(uMS) * 0.001f; m_fWeight = fWeight; }
	void	Set(const float fTime, const float fWeight)	{ m_fTime = fTime; m_fWeight = fWeight; }

	float	GetTime(void) const		{ return(m_fTime); }
	float	GetWeight(void) const	{ return(m_fWeight); }


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private variables...
	float	m_fTime;		// The time at which this key-frame begins.
	float	m_fWeight;		// The weight of this key-frame.

	// Private functions...

};   // End of class 'Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame'.



////////////////////////////////////////////////////////////////////////////////
// Class        : Tools_FacialAnimation_FaceAnimation_FacePose
// Author       : Andy Tate
// Date         : 5-Aug-2008
//
// Description  : Class used to hold the animation data for a particular 
//				  face-pose (during facial-animation).
////////////////////////////////////////////////////////////////////////////////

class Tools_FacialAnimation_FaceAnimation_FacePose
{
public:
	// Public typedefs...
	typedef Asura_LinkList<Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame> KeyFrameContainer;
	typedef Asura_LinkList_It<Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame> KeyFrameIterator;
	typedef Asura_LinkList_ConstIt<Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame> KeyFrameConstIterator;

	// Public functions...
	Tools_FacialAnimation_FaceAnimation_FacePose(void);
	Tools_FacialAnimation_FaceAnimation_FacePose(const Asura_Hash_ID uHash, Asura_Chunk_Stream& xStream);
	//~Tools_FacialAnimation_FaceAnimation_FacePose();

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

	// Manipulation functions...
	void	AddKeyFrame(const u_int uMS, const float fWeight);
	void	AddWindow(const u_int uStartMS, const u_int uEndMS, const float fWeight);

	// Accessor functions...
	u_int	GetNumKeyFrames(void) const	{ return(m_xKeyFrameContainer.Size()); }

	void				SetFacePoseName(const char* szName)			{ m_xFacePoseName = szName; }
	void				SetFacePoseName(const Asura_String& xName)	{ m_xFacePoseName = xName; }
	const Asura_String&	GetFacePoseName(void) const					{ return(m_xFacePoseName); }

	KeyFrameContainer&			GetKeyFrameContainer(void)			{ return(m_xKeyFrameContainer); }
	const KeyFrameContainer&	GetKeyFrameContainer(void) const	{ return(m_xKeyFrameContainer); }


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private typedefs...
	typedef Asura_ListElt<Tools_FacialAnimation_FaceAnimation_FacePose_KeyFrame> KeyFrameItem;

	// Private variables...
	Asura_String		m_xFacePoseName;		// The name of this face-pose.
	KeyFrameContainer	m_xKeyFrameContainer;	// Container class for the key-frames we're going to use.

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

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

	Tools_FacialAnimation_FaceAnimation_FacePose&	operator=(const Tools_FacialAnimation_FaceAnimation_FacePose& xOther);

};   // End of class 'Tools_FacialAnimation_FaceAnimation_FacePose'.

#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#endif   // ifndef __TOOLS_FACIALANIMATION_FACEANIMATION_FACEPOSE_H__


/// End of file. ///
