//
// Asura_FacialAniamtion_EyeParamAnimation.h
//
// Created by Richard Rice - 15/10/2008
// 
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//

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

#ifndef __ASURA_FACIALANIMATION_EYEPARAMANIMATION__
#define __ASURA_FACIALANIMATION_EYEPARAMANIMATION__

#if defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#include "Debugging/Asura_Assert.h"

class Asura_Chunk_Stream;

//Single keyframe for one parameter of an eye animation
class Asura_FacialAnimation_EyeParamAnimation_KeyFrame
{
public:
	// Public functions...
	Asura_FacialAnimation_EyeParamAnimation_KeyFrame(void)	{}
	Asura_FacialAnimation_EyeParamAnimation_KeyFrame(const float fTime, const float fValue) : m_fTime(fTime), m_fValue(fValue){}
	Asura_FacialAnimation_EyeParamAnimation_KeyFrame(const Asura_FacialAnimation_EyeParamAnimation_KeyFrame& xOther) : m_fTime(xOther.m_fTime), m_fValue(xOther.m_fValue)	{}
//	~Asura_FacialAnimation_EyeParamAnimation_KeyFrame();

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

	// Accessor functions...
	float	GetTime(void) const		{ return(m_fTime); }
	float	GetValue(void) const	{ return(m_fValue); }

	void	Set(const float fTime, const float fValue)	{ m_fTime = fTime; m_fValue = fValue;}


protected:
	// Protected variables...

	// Protected functions...


private:
	// Private variables...
	float	m_fTime;		// The time at which this value begins.
	float	m_fValue;		// The value for the parameter at this time.

	// Private functions...

};   // End of class 'Asura_FacialAnimation_EyeParamAnimation_KeyFrame'.


//Animation data for a single parameter for the eye animation part of a facial animation
class Asura_FacialAnimation_EyeParamAnimation
{
public:
	// Public functions...
	Asura_FacialAnimation_EyeParamAnimation(void);
	~Asura_FacialAnimation_EyeParamAnimation();

	// Manipulation functions...
#if defined(ASURA_TOOLS)
	void	Tools_AllocateKeyFrames(const u_int uNumKeyFrames);
	void	Tools_SetKeyFrame(const u_int uFrame, const float fTime, const float fValue);
//	void	Tools_RationaliseKeyFrames(void);	// non existing function EP. 2.12.2008
	void	Tools_SetKeyFrames(const class Asura_FacialAnimation_EyeParamAnimation& xAnimation);
	float	Tools_GetLastKeyFrameTime() const;
	void	Tools_CombineBaseFacePose( float fBaseFacePoseValue );
	void	Tools_RemoveRedundantKeyFrames();
#endif	//defined(ASURA_TOOLS)

	bool	CalculateValue(const float fTime, float& fValue) const;

	u_int	GetNumKeyFrames() const {return m_uNumKeyFrames;}
	const Asura_FacialAnimation_EyeParamAnimation_KeyFrame& GetKeyFrame(u_int uFrame) const {Asura_Assert(uFrame<m_uNumKeyFrames,"");return m_pxKeyFrames[uFrame];}
	

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


protected:
	// Protected variables...


private:
	// Private variables...
	u_int													m_uNumKeyFrames;	// The number of key-frames for this animation.
	Asura_FacialAnimation_EyeParamAnimation_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_EyeParamAnimation(const Asura_FacialAnimation_EyeParamAnimation& xOther);

	Asura_FacialAnimation_EyeParamAnimation&	operator=(const Asura_FacialAnimation_EyeParamAnimation& xOther);

};   // End of class 'Asura_FacialAnimation_EyeParamAnimation'.


#endif	//defined(ASURA_USE_FACIAL_ANIMATION_SYSTEM)

#endif //__ASURA_FACIALANIMATION_EYEPARAMANIMATION__