//
// Tools_PhotonMapping_PolygonLightSource_Object.h
//
// Created by RAR - 28/09/2004
//
// Copyright (C) 2004 Rebellion, All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
	#pragma once
#endif

#ifndef __TOOLS_PHOTONMAPPING_POLYGONLIGHTSOURCE_OBJECT_H__
#define __TOOLS_PHOTONMAPPING_POLYGONLIGHTSOURCE_OBJECT_H__

#include "Core/Asura_String.h"
#include "Core/Asura_Handle.h"
#include "Misc/Tools_Colour.h"
#include "Objects/Tools_Object.h"


class Tools_PhotonMapping_PolygonLightSource_Object : public Tools_Object
{
	friend class Tools_Mode_PhotonMapping;	
	public :
		Tools_PhotonMapping_PolygonLightSource_Object(const Asura_Handle iLightSourceHandle);
		~Tools_PhotonMapping_PolygonLightSource_Object();

		void OnSelection();
		void OnDeselection();

		//Creates a new light , together with its tools object
		static Tools_PhotonMapping_PolygonLightSource_Object* CreateLightSource();

		int GetModuleIndex();

		//updates initial values for start of scale operation
		static void UpdateInitialLightValues();
		//applies the current light scale values from Tools_Mode_PhotonMapping to all lights
		static void ApplyLightScaleValues();

		
		virtual bool GetParameter(Asura_Hash_ID uParamID,class Tools_Parameter* pxParam) const;
		virtual bool SetParameter(Asura_Hash_ID uParamID,const class Tools_Parameter* pxParam);

	private:

		void CreateLightPropertiesOverlay(void);

//		void RecalculatePhotons( void );

		Asura_Handle				m_iLightSourceHandle;

		// used to signal if the overlay has changed any values
		bool						m_bChanged;
		bool						m_bChanged_NoRelightNeeded;
		bool						m_bInnerRangeChanged;
		bool						m_bOuterRangeChanged;

		float						m_fPower;
		float						m_fAngle;
		mutable Tools_Colour_Pair	m_xColourPair;
		bool						m_bBleachedSource;
		bool						m_bShortRange;
		
		bool						m_bUseRange;
		float						m_fInnerRange;
		float						m_fOuterRange;

		float						m_fReflectionChance;
		u_int						m_uLightSets;
	
		int							m_iAccuracy;

		Asura_String				m_xName;

		bool						m_bUsesEntityPolygons;

		//initial power/colour values for use with light scale overlay
		float						m_fInitialPower;
		mutable Asura_Vector_3		m_xInitialColour;

		mutable bool				m_bColoursInverted;



		const char* GetName() {return m_xName.GetString();};
		virtual void UpdateWhileSelected();
		const char* GetTypeDescription(){return "Polygon Light";}
		void Destroy();
		void Render();
		bool IsSelectable();
		virtual bool IsHidden();

				
		void UpdateInvertedColourStatus() const;
		void UpdateAsuraLight();
		void UpdateIfChanged();
		void UpdateName();
		void AddSelectedPolygons(bool bTransferUsedPolys,bool bAskAboutTransfer);
		void RemoveSelectedPolygonsMain();

		static void AddSelectedPolygons();
		static void RemoveSelectedPolygons();

		static bool IsEnabled_UsesRange();


		struct Asura_Mesh_PolygonLight* GetLightDataFromMesh();

		// Copy/paste support
		virtual void Copy(const Tools_Object* pxObject);
		virtual bool CanBeCopied() const {return true;}
		virtual Tools_Object* CreateObjectOfThisType() const;

		
		static Tools_PhotonMapping_PolygonLightSource_Object* s_pxThis;

		static List<Tools_PhotonMapping_PolygonLightSource_Object*> s_xObjectList;

		static bool s_bHighlightCurrent;
		static bool s_bHighlightAll;

};


#endif //__TOOLS_PHOTONMAPPING_POLYGONLIGHTSOURCE_OBJECT_H__
