#ifndef LIGHT_H
#define LIGHT_H

#include "object.h"

namespace CBK
{
	template<int NumberLightStages = 4>
	class _Light : public Object
	{
	public:
		_Light(IDirect3DDevice9* device = 0);
		~_Light(void);

		_Light& setColor(const D3DCOLORVALUE& ambient, const D3DCOLORVALUE& diffuse, const D3DCOLORVALUE& specular);
		_Light& setColorAmbient(const D3DCOLORVALUE& color);
		_Light& setColorDiffuse(const D3DCOLORVALUE& color);
		_Light& setColorSpecular(const D3DCOLORVALUE& color);

		_Light& setType(const D3DLIGHTTYPE& type);
		D3DLIGHTTYPE& getType(void);

		virtual void apply(const DWORD& index);
		virtual void apply(void);

		static void disable(IDirect3DDevice9* device, const DWORD& index = 0);

		_Light& setCones(const float& Theta, const float& Phi, const float& Falloff);

		_Light& setAttenuation(const float& constant, const float& linear, const float& quadratic);
		_Light& setFalloff(const float& falloff);
		_Light& setPosition(const D3DVECTOR& position);

		_Light& setDirection(const D3DVECTOR& direction);

		const D3DCOLORVALUE& getColorAmbient(void);
		const D3DCOLORVALUE& getColorDiffuse(void);
		const D3DCOLORVALUE& getColorSpecular(void);

		const float& getConeTheta(void);
		const float& getConePhi(void);
		const float& getConeFalloff(void);

		const float& getAttenuationConstant(void);
		const float& getAttenuationLinear(void);
		const float& getAttenuationQuadratic(void);

		const float& getFalloff(void);
		const D3DVECTOR& getPosition(void);

		const D3DVECTOR& getDirection(void);

		virtual Object& reset(void);

		static unsigned long numLightChanges;
	protected:
		D3DLIGHT9 _light;

	private:
		static _Light* _CurrentLight[NumberLightStages];
		virtual Object& load(const std::string& name);
	};

	typedef _Light<> Light;
}

#include "light.inl"

#endif //LIGHT_H