//
// Asura_GUIMenu_Element_Animation.h
//
// Created by RDM - 16 April 2007
//
// Copyright (C) 2007 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __ASURA_GUIMENU_ELEMENT_ANIMATION_H__
#define __ASURA_GUIMENU_ELEMENT_ANIMATION_H__

/************/
/* Includes */
/************/

#ifdef ASURA_USE_GUI_MENU_SYSTEM

// asura
#include "Core/Asura_Maths.h"
#include "GUIMenu/Asura_GUIMenu_Element_Base.h"

//0-3 ??
// Version 4 - CLF(27.01.2009) - Integrated branched fix (KOR - added vertical FOV and stretch flags)
//5 NY added camera orientation and skin position data
#define ASURA_CHUNK_ELEMENT_ANIMATION_VERSION 5

/***********/
/* Classes */
/***********/

// forward declarations
class Asura_Animation;

/*************************************************************
 *
 * Class Name    : Asura_GUIMenu_Element_Animation
 *
 * Author        : Richard May
 *
 * Description   : 3D anim element for the GUI system
 *
 *************************************************************/
class Asura_GUIMenu_Element_Animation : public Asura_GUIMenu_Element_Base
{
	friend class Tools_GUIMenu_Element_Animation;

private:
	typedef Asura_GUIMenu_Element_Base PARENT;

public:
	/* Constructors/destructor. */
	Asura_GUIMenu_Element_Animation();
	virtual ~Asura_GUIMenu_Element_Animation();

	/* Public interface functions. */
	virtual void Update( float fElapsedTime );
	virtual void Render( u_int uState )						{ PARENT::Render( uState ); }
	virtual void Render( u_int uState, const Asura_Bounding_Rectangle& xBounds);
	virtual void Copy( const Asura_GUIMenu_Root* pxSource );

	void DeleteAnimation();
	void SetupAnimation();

#ifdef ASURA_TOOLS
	void LoadSkinAndAnimFiles() const;
	virtual void UpdateLocalDataFromStyle();
	virtual	void AddFilesToExportList();	
	virtual void WriteToChunkStream( Asura_Chunk_Stream& xStream) const;
	virtual void ExportToXML(Tools_GUIMenu_XMLExporter* pxExporter) const;
#endif // ASURA_TOOLS

	virtual void ReadFromChunkStream( Asura_Chunk_Stream& xStream, Asura_GUIMenu_Root* pxParentObject, u_int uChunkVersion );

	// accessors
	u_int GetAnimFlags() const						{ return m_uAnimFlags; }
	Asura_Hash_ID GetSkinID() const					{ return m_uSkinID; }
	Asura_Hash_ID GetAnimID() const					{ return m_uAnimID; }
	Asura_Animation* GetAnim() const					{ return m_pxAnimation; }
	const Asura_Vector_3& GetCameraOffset() const		{ return m_xCameraOffset; }
	const Asura_Euler_3& GetRotationSpeed() const		{ return m_xRotationSpeed; }
	const Asura_Euler_3& GetRenderOrient() const		{ return m_xRenderOrient; }
	const Asura_Vector_3& GetSkinOffset() const			{ return m_xSkinOffset; }
	const Asura_Euler_3& GetCameraOrient() const		{ return m_xCameraOrient; }

	void SetRotationSpeed( const Asura_Euler_3& xSpeed )	{ m_xRotationSpeed = xSpeed; }
	void SetCameraOffset( const Asura_Vector_3& xOffset )	{ m_xCameraOffset = xOffset; }
	void SetRenderOrient( const Asura_Euler_3& xOrient )	{ m_xRenderOrient = xOrient; }
	void SetSkinOffset( const Asura_Vector_3& xSkinOffset )	{ m_xSkinOffset = xSkinOffset; }
	void SetCameraOrient( const Asura_Euler_3& xCameraOrient )	{ m_xCameraOrient = xCameraOrient; }
	void SetAmbient( const Asura_RGBA& xColour );	
	void SetSkin( Asura_Hash_ID uSkinID );
	void SetAnim( Asura_Hash_ID uAnimID, u_int uAnimFlags );

protected:
	/* Helper functions. */
	void PlayAnim( Asura_Hash_ID uAnimID, u_int uAnimFlags );

	/* Data. */
	Asura_Animation* m_pxAnimation;
	Asura_Hash_ID m_uSkinID;
	Asura_Hash_ID m_uAnimID;	
	u_int m_uAnimFlags;
	float m_fFOVAngle;
	float m_fZoomLevel;
	Asura_Vector_3 m_xCameraOffset;
	Asura_Euler_3 m_xRenderOrient;
	Asura_Vector_3 m_xSkinOffset;
	Asura_Euler_3 m_xCameraOrient;
	Asura_Euler_3 m_xRotationSpeed;
	bool m_bUseVerticalFOV;
	bool m_bStretch;
#ifdef ASURA_TOOLS
	bool m_bExportSkinAndAnim;
#endif
};
/* end of class Asura_GUIMenu_Element_Animation */

/***************/
/* End of File */
/***************/
#endif // ASURA_USE_GUI_MENU_SYSTEM

#endif//__ASURA_GUIMENU_ELEMENT_ANIMATION_H__
