#ifndef LIGHTDTIT_H
#define LIGHTDTIT_H



#include "./../../lib/GLee/GLee.h"	
#include "./math/Mathematics.h"
#include <vector>
#include <cassert>
#include <map>
#include <string>
#include <GL/glu.h>
#include "./illumination/tricol.h"

#include "./illumination/Light.h"

// Required by golem vector3.h
using std::ostream;
using std::istream;
using std::endl;

#include "./illumination/ShaderLight.h"



// Structure implemented by ryZetka according JK's notes.
struct SLigthData 
{
	// Light source type, e.g. spot, omni, rectangle,.
	LightType type;
	// Position
	CVector3D pos3;
	// Direction
	CVector3D dir3;
	// Tangent
	CVector3D sdir3;
	// Bi-tangent
	CVector3D tdir3;
	// Light source size along tangent / bi-tangent
	float size2[2];
	// Intensity
	CTriCol col3;
	// Exponent of the lobe of a emission function
	float directionality;
	// Light attenuation with the distance
	float attenuation;
	// Key light
	bool isKeyLight;

	// Multiply diffuse illumination due to this light by ambient occlusion
	bool multiplyByAmbientOcclusion;	// I ask for parameter renaming to multiplyByAO
	// Cast shadows for the light
	bool castShadowsSM;
	// Multiplicative factor for direct lighting on gather samples.
	/* if fGIintensity equal 0 the global illumination is switch off */
	float indirectFactor;	// I ask for parameter renaming to giIntensityMult

	SLigthData() 
	{ 
		memset(&type, 0, sizeof(SLigthData));
	}
	friend ostream& operator<< (ostream &s, const SLigthData &A);
};




class DTITLight : public Light
{
public:
	unsigned int id;	//light id

	LightType subtype;	// Light source type, e.g. spot, omni, rectangle,.
	Point_3<float> position;	
	Vector_3<float> direction;	
	Vector_3<float> tangent;	
	Vector_3<float> bitangent;

	float intensity;
	float size2[2];		// Light source size along tangent / bi-tangent
	CTriCol color;		// Intensity * color
	float directionalExp;	// Exponent of the lobe of a emission function
	float attenuation;		// Light attenuation with the distance
	bool isKeyLight;	// Key light
	bool multiplyByAmbientOcclusion;	// Multiply diffuse illumination due to this light by ambient occlusion
	bool castShadow;
	float indirectFactor;
	
	virtual LightType getLightType() const { return DTIT_LIGHT; };


	OmniLightPhong convertToOmni(void);
	SpotLightPhong convertToSpot(void);
	RectangleLightPhong convertToRect(void);
	DirectionalLightPhong convertToDir(void);

	DTITLight(void);

	virtual void getData( SLigthData* lightdata );
};

void renderDTITLight( DTITLight* light, const CTriCol *color=NULL, bool wire = false);

#endif