#ifndef __TRANSFORMMATRIXMANAGER__
#define __TRANSFORMMATRIXMANAGER__

#include "Singleton.h"

// Forward declarations
class CModelViewerCamera;


//------------------------------------------------------------------------------------------
// TransformMatrixesManager is a singleton-type class
// Managing all the transformation matrixes needed during the application runtime
//------------------------------------------------------------------------------------------
class TransformMatrixesManager : public Singleton<TransformMatrixesManager>
{

	// Another single in the place!
	friend class Singleton<TransformMatrixesManager>;


	private:

		// Construction / Destruction
		TransformMatrixesManager();
		~TransformMatrixesManager();

		void SetAllMatrixToIdentity();			// Nuff says


	public:

		// classic matrixes
		D3DXMATRIXA16 m_matWorld;						// World matrix
		D3DXMATRIXA16 m_matView;						// View matrix
		D3DXMATRIXA16 m_matProj;						// Projection matrix

		D3DXMATRIXA16 m_matCurrentFrameWVP;				// The current frame WVP matrix
		D3DXMATRIXA16 m_matPreviousFrameWVP;			// The previous frame WVP matrix (for velocity buffers for example)

		// Special matrixes
		D3DXMATRIXA16 m_matMeshWorldCenter;				// Mesh World Centering Matrix

		D3DXMATRIXA16 m_matCurrentFrameSkyboxWV;		// The current skybox WorldView matrix
		D3DXMATRIXA16 m_matPreviousFrameSkyboxWV;		// The previous frame skybox WorldView matrix

		// Functions
		void ComputeWVPMatrix();								// Compute the m_matWVPCurrentFrame using the known matrix
		void BackupCurrentMatrixes();							// Backup the "CurrentFrame" matrixes to their "PreviousFrame" equivalent
		void UpdateMatrixes(const CModelViewerCamera * pCam);	// Update world view and proj matrixes using the camera parameter
};

#endif