///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZPRS Class
///
///		- Class for the management of the position, rotation and scale of an object 
///		
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


#ifndef __ZOOPRS_H__
#define __ZOOPRS_H__


#include	"..\Basic\zoostd.h"


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZPRS Class
///
///		- Classe de : Position, Rotation, Scale (et aussi vitesse et accélération)
///		- Méthodes pour modifier les params et updater ceux-ci en fonction de 'time'
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class ZPRS
{
protected:

	ZVector3	pos;							  // position variable of object
	ZVector3	angle;							// rotation variable of object
	float			scale;							// scale variable of object

	bool			modified;						// flag of modification of the PRS

public:

	ZMatrix		mat;								// Matrix of the PRS, in the local space

	float		coeffM3D;							// the factor of division to make the M3D visible in a good way
	
	///////////////////////////////////////////////////////////////////////////
	/// Constructor					 										///
	///////////////////////////////////////////////////////////////////////////
	ZPRS();
	~ZPRS();


	///////////////////////////////////////////////////////////////////////////
	///		Get						 										///
	///////////////////////////////////////////////////////////////////////////
	ZVector3	GetPos();
	ZVector3	GetAng();
	float		GetScale();


	///////////////////////////////////////////////////////////////////////////
	///		Set						 										///
	///////////////////////////////////////////////////////////////////////////
	void SetPos(float nx, float ny, float nz);
	void SetPos(ZVector3 newPos);
	void SetAng(float nx, float ny, float nz);
	void SetAng(ZVector3 newAngle);
	void SetScale(float nscale);


	///////////////////////////////////////////////////////////////////////////
	///		Add						 										///
	///////////////////////////////////////////////////////////////////////////
	void AddPos(float nx, float ny, float nz);
	void AddPos(ZVector3 newPos);
	void AddAng(float nx, float ny, float nz);
	void AddAng(ZVector3 newAngle);
	void AddScale(float nscale);


	///////////////////////////////////////////////////////////////////////////
	/// Create the matrix of the PRS										///
	///////////////////////////////////////////////////////////////////////////
	void CreateMatrix();
};


///////////////////////////////////////////////////////////
/// Set the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline ZVector3 ZPRS::GetPos()
{
    return pos;
}


///////////////////////////////////////////////////////////
/// Set the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline ZVector3 ZPRS::GetAng()
{
    return angle;
}


///////////////////////////////////////////////////////////
/// Set the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline float ZPRS::GetScale()
{
    return scale;
}


///////////////////////////////////////////////////////////
/// Set the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline void ZPRS::SetPos(ZVector3 newPos)
{
    pos = newPos;
	modified = true;
}
inline void ZPRS::SetPos(float nx, float ny, float nz)
{
    pos.x = nx;
    pos.y = ny;
    pos.z = nz;
	modified = true;
}

   
///////////////////////////////////////////////////////////
/// Set the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline void ZPRS::SetAng(ZVector3 newAngle)
{
    angle = newAngle;
	modified = true;
}
inline void ZPRS::SetAng(float nx, float ny, float nz)
{
    angle.x = nx;
    angle.y = ny;
    angle.z = nz;
	modified = true;
}


///////////////////////////////////////////////////////////
/// Set scale					 						///
///////////////////////////////////////////////////////////
inline void ZPRS::SetScale(float nscale)
{
    scale = nscale;
	modified = true;
}


///////////////////////////////////////////////////////////
/// Add the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline void ZPRS::AddPos(ZVector3 newPos)
{
    pos += newPos;
	modified = true;
}
inline void ZPRS::AddPos(float nx, float ny, float nz)
{
    pos.x += nx;
    pos.y += ny;
    pos.z += nz;
	modified = true;
}
 

///////////////////////////////////////////////////////////
/// Add the rotation coordinates 						///
///////////////////////////////////////////////////////////
inline void ZPRS::AddAng(ZVector3 newAngle)
{
    angle += newAngle;
	modified = true;
}
inline void ZPRS::AddAng(float nx, float ny, float nz)
{
    angle.x += nx;
    angle.y += ny;
    angle.z += nz;
	modified = true;
}


///////////////////////////////////////////////////////////
/// Add scale					 						///
///////////////////////////////////////////////////////////
inline void ZPRS::AddScale(float nscale)
{
    scale += nscale;
	modified = true;
}


///////////////////////////////////////////////////////////////////////////
/// Create the matrix with the PRS datas								///
///////////////////////////////////////////////////////////////////////////
inline void ZPRS::CreateMatrix()
{
	if(modified)
	{
		mat.RotateYXZMatrix(0.0174532925f * angle);
		mat *= ScaleMatrix(scale);

		mat.SetTrans(pos.x, pos.y, pos.z);

		modified = false;
	}
}


#endif