///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZLight Class
///
///		- Light Class
///		- Manage the ligth properties
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




#ifndef __ZOOLIGHT_H__
#define __ZOOLIGHT_H__

#include	"..\Basic\ZooStd.h"
#include	"..\Scene Graph\ZooNodeGraph.h"


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// ZLight Class
///
///		- Classe des lumiéres
///		- Propriétésde couleur des lights (RVB) sur 3 composantes : amibante, diffuse, spéculaire
///		- methode propre de modification des pptés de light (PRS et composantes propres)
///		- texture pour le sprite et méthode d'affichage par display list
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

class ZLight : public ZNodeGraph
{

public:
	
	bool		oldStyle;											// flag which explains if it is an OLD or NEW light SCOL style

	int			LightType;											// Type of the light

	int			alpha, beta, dist;									// SOFTWARE datas (old SCOL style)

	GLfloat		ambient[4], diffuse[4], specular[4];				// components for the light definition
	GLfloat		exponent;
	int			spot_cut_off;
	GLfloat		attenuate_const;
	GLfloat		attenuate_quadr;

	float		distance;											// distance of attenuation

	ZVector3	target;												// direction de la light


	///////////////////////////////////////////////////////////////////////////
	/// Constructor & Destructor		      								///
	///////////////////////////////////////////////////////////////////////////
	ZLight(int s3d);
	~ZLight();


	///////////////////////////////////////////////////////////////////////////
	/// Set the default vals												///
	///////////////////////////////////////////////////////////////////////////
	void SetDefaultVals();
	
	
	///////////////////////////////////////////////////////////////////////////
	/// Set the ambient component											///
	///////////////////////////////////////////////////////////////////////////
	void SetAmbient(float newVals[4]);
	void SetAmbient(float newVal0, float newVal1, float newVal2, float newVal3);


	///////////////////////////////////////////////////////////////////////////
	/// Set the Diffuse component											///
	///////////////////////////////////////////////////////////////////////////
	void SetDiffuse(float newVals[4]);
	void SetDiffuse(float newVal0, float newVal1, float newVal2, float newVal3);


	///////////////////////////////////////////////////////////////////////////
	/// Set the Specular component											///
	///////////////////////////////////////////////////////////////////////////
	void SetSpecular(float newVals[4]);
	void SetSpecular(float newVal0, float newVal1, float newVal2, float newVal3);


	///////////////////////////////////////////////////////////////////////////
	/// Put the GL parameters (specify the light number in opengl)			///
	///////////////////////////////////////////////////////////////////////////
	void PutGLparams(int numberOfThisLight);
};


///////////////////////////////////////////////////////////////////////////
/// Set the ambient component											///
///////////////////////////////////////////////////////////////////////////
inline void ZLight::SetAmbient(float newVals[4])
{
	for(int i=0; i<4; i++)		ambient[i] = newVals[i];
}
inline void ZLight::SetAmbient(float newVal0, float newVal1, float newVal2, float newVal3)
{
	ambient[0] = newVal0;	ambient[1] = newVal1;
	ambient[2] = newVal2;	ambient[3] = newVal3;
}


///////////////////////////////////////////////////////////////////////////
/// Set the Diffuse component											///
///////////////////////////////////////////////////////////////////////////
inline void ZLight::SetDiffuse(float newVals[4])
{
	for(int i=0; i<4; i++)		diffuse[i] = newVals[i];
}
inline void ZLight::SetDiffuse(float newVal0, float newVal1, float newVal2, float newVal3)
{
	diffuse[0] = newVal0;	diffuse[1] = newVal1;
	diffuse[2] = newVal2;	diffuse[3] = newVal3;
}


///////////////////////////////////////////////////////////////////////////
/// Set the Specular component											///
///////////////////////////////////////////////////////////////////////////
inline void ZLight::SetSpecular(float newVals[4])
{
	for(int i=0; i<4; i++)		specular[i] = newVals[i];
}
inline void ZLight::SetSpecular(float newVal0, float newVal1, float newVal2, float newVal3)
{
	specular[0] = newVal0;	specular[1] = newVal1;
	specular[2] = newVal2;	specular[3] = newVal3;
}


///////////////////////////////////////////////////////////////////////////
/// Set the default vals												///
///////////////////////////////////////////////////////////////////////////
inline void ZLight::SetDefaultVals()
{
	ambient[0]  = 0.2f;		ambient[1]  = 0.2f;		ambient[2]  = 0.2f;		ambient[3]  = 1.0f;
	diffuse[0]  = 0.8f;		diffuse[1]  = 0.8f;		diffuse[2]  = 0.8f;		diffuse[3]  = 1.0f;
	specular[0] = 0.0f;		specular[1] = 0.0f;		specular[2] = 0.0f;		specular[3] = 1.0f;
}


#endif