/*
///////////////////////////////////////////////////////////////////////////////////////////////////
// Description : WPObj.hpp
//
// Definition of the Light editors objects
//
///////////////////////////////////////////////////////////////////////////////////////////////////
// inherit from  :	CPA_Object
//					CPA_EdMot<ACP_tdxHandleOfLink>
///////////////////////////////////////////////////////////////////////////////////////////////////
// Creation date: 11 feb 1997                        Author: J Thénoz
///////////////////////////////////////////////////////////////////////////////////////////////////
// Modification date:			                      Author:
//
//
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
*/

#ifndef __WPOBJECT_HPP__
#define __WPOBJECT_HPP__


//----------------------------------------------------------------------
// Definition of the name of the models
	static CString csSpotModelName = "Spot";
	static CString csSphericalModelName = "Spherical";
	static CString csParallelModelName = "Parallel";
	static CString csAmbientModelName = "Ambient";
//CHINA WFQ (MT) 16/02/98 {
	static CString csParallelBoxModelName = "ParallelBox";
//ENDCHINA WFQ }
//ROMTEAM Z_Light Ionut Grozea 01-05-1998
	static CString csZModelName = "Z_Light";
//ENDROMTEAM Z_Light Ionut Grozea 01-05-1998
//ANNECY jt {
	static CString csFogModelName = "Fog";
//ENDANNECY jt }
//----------------------------------------------------------------------


class DiaLight;
class Light_Interface;

class Light : public CPA_SaveObject, public CPA_EdMot<GLI_tdxHandleToLight>
{
protected:
	static Light_Interface*				ms_poInterface;
	static DiaLight*					ms_poDiaLight;			// dialog
	static BOOL							ms_bNotifyHeader;		// header of this file is already notify
	static BOOL							ms_bStopNotification;	// Stop notification
	static CPA_List<CPA_SectionObject>	ms_oListOfSectionObject;// List of all the sector sections

	BOOL								m_b3DsMaxLight;			// light created with 3DsMax
	BOOL								m_bLightOn;				// The light is on ?
	BOOL								m_bModify;				// the light has been changed since last load

	CPA_SuperObject*					m_poSuperObject;		// Super Object
	CPA_SectionObject*					m_poMatrixSection;

	CPA_List<CPA_SuperObject>			m_oSectorList;			// list of affected sectors
	CPA_List<CPA_SectionObject>			m_oListOfSectorSection;	// list of sector SectionObject

	float								m_fIntensity;			// light intensity ( 0-10 )
	long								m_lType;				// type of the light
//ROMTEAM BlendRLI (Ionut Grozea 24/02/98)
	long								m_lIsTypePaint;			// is type of the light Paint
//ENDROMTEAM BlendRLI (Ionut Grozea)

public:
	CPA_SuperObject*					m_poNearSuperObject;	// near edit objetct
	CPA_SuperObject*					m_poFarSuperObject;		// far edit object
//CHINA WFQ (MT) 16/02/98 {
	CPA_SuperObject*					m_poInterSuperObject;
	CPA_SuperObject*					m_poExterSuperObject;
//ENDCHINA WFQ }
	BOOL								m_bSelect;				// Is this light selected ?

	//--- static
	static void fn_vInitObject (void);
	static void fn_vSetDialog ( DiaLight* poDiaLight, Light_Interface* pInterface );
	static DiaLight* fn_pGetDialog ( void ) { return ms_poDiaLight; }
	static void fn_vSetNotifyHeader (BOOL bNotifyHeader) { ms_bNotifyHeader=bNotifyHeader; }
	static void fn_vStopNotification (BOOL bStopNotification) { ms_bStopNotification = bStopNotification; }
	static Light_Interface* GetInterface (void) { return ms_poInterface; }
	static void fn_vInitListOfSectionObject (void);
	static void fn_vFreeListOfSectionObject (void);
	static CPA_SectionObject* fn_poFindSectionObject ( CPA_SuperObject* poSector );
	static void fn_vUpdateSectorSection (void);

	// load save
	static SCRIPT_tdeReturnValue CallBackLoad (FILE *p_fFile, char *szAction, char *szParams[], SCRIPT_tdeAction cType);
	static void fn_vCallbackHeader ( SCR_tdst_File_Description *_p_stFile,	char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action	_eAction );
	static void fn_vCallbackSave ( SCR_tdst_File_Description *_p_stFile,	char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action	_eAction );
	static void fn_vCallBackSaveSector ( SCR_tdst_File_Description *_p_stFile,	char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action	_eAction );
	static void fn_vCallbackSaveMatrix ( SCR_tdst_File_Description *_p_stFile,	char *_p_szSectionName, void *_p_vData,SCR_tde_Ntfy_Action	_eAction );

	Light(CPA_MainWorld *p_oMainWorld, CPA_ObjectDLLBase *p_oDLL, CString csFileName );
	Light(CPA_MainWorld *p_oMainWorld, CPA_ObjectDLLBase *p_oDLL, GLI_tdxHandleToLight hEngineLight, CString csName, CString csFileName, CString csSectionName );
	Light( Light& rLight);
	~Light();

	//--- data
	long GetDataType (void);
	void* GetData (void);

	//--- get
	long fn_lGetType (void) { return m_lType; }
	CPA_List<CPA_SuperObject>* fn_pGetSectorList ( void ) { return &m_oSectorList; }
	BOOL fn_vAddSector ( CPA_SuperObject* poObject );
	BOOL fn_bIsAffectedSector ( CPA_SuperObject* poSuperSector ) { return m_oSectorList.Find(poSuperSector)!=NULL; }
	CPA_SuperObject* GetSuperObject (void) { return m_poSuperObject; }
	CPA_SectionObject* GetMatrixSection (void) { return m_poMatrixSection; }
	BOOL fn_bIs3DsMaxLight (void) { return m_b3DsMaxLight; }
	BOOL fn_bIsLightOn (void) { return 	m_bLightOn; }
	BOOL fn_bIsModify (void) { return m_bModify; }

	//--- set
	void SetSuperObject ( CPA_SuperObject* poSuperObject ) { m_poSuperObject = poSuperObject; }
	void Set3DsMaxLight (BOOL b3DsMaxLight) { m_b3DsMaxLight=b3DsMaxLight; }
	void fn_vSetLightOn (BOOL bOn) { m_bLightOn=bOn; }
	void fn_vSetModify ( BOOL bModify ) { m_bModify=bModify; }

	//--- Save notify
	void fn_vUpDateSectorSection	(void);
	void fn_vNotifySave				(void);
	void fn_vNotifyUnSave			(void);
	void fn_vNotifyRestore			(void);
	void fn_vNotifyRename			(void);
	void fn_vUpdateReference		(CPA_SaveObject *pReferencedObject);

	//--- color -> control edit manager
	void fn_vSetColor ( GEO_tdxColorValue xR, GEO_tdxColorValue xG, GEO_tdxColorValue xB, GEO_tdxColorValue xA );
	void fn_vGetColor ( GEO_tdxColorValue* xR, GEO_tdxColorValue* xG, GEO_tdxColorValue* xB, GEO_tdxColorValue* xA  );

	//--- intensity
	void fn_vSetIntensity ( float fIntensity ) { m_fIntensity = fIntensity; }
	float fn_fGetIntensity (void) { return m_fIntensity; }

	//--- intensity -> control edit manager
	void fn_vSetLightIntensity ( float& fIntensity );

	//--- alpha / near-far -> control edit manager
	void fn_vSetLightAlpha	 ( MTH_tdxReal& xLittleAlpha, MTH_tdxReal& xBigAlpha );
	void fn_vSetLightNearFar ( MTH_tdxReal& xNear, MTH_tdxReal& xFar );
//CHINA WFQ (MT) 16/02/98 {
	void fn_vSetLight_Intensity_Min_Max ( MTH_tdxReal& xIntensity_Min, MTH_tdxReal& xIntensity_Max );
	void fn_vSetLight_Inter_Min_Pos ( MTH3D_tdstVector& xInter_Min_Pos);
	void fn_vSetLight_Inter_Max_Pos ( MTH3D_tdstVector& xInter_Max_Pos);
	void fn_vSetLight_Exter_Min_Pos ( MTH3D_tdstVector& xExter_Min_Pos);
	void fn_vSetLight_Exter_Max_Pos ( MTH3D_tdstVector& xExter_Max_Pos);
//ENDCHINA WFQ }

	//--- change radius of lights
	void fn_vSetMouseControl (MTH3D_tdstVector* pstTranslation, BOOL bModifNearRadius, BOOL bModifFarRadius );

	//--- On/Off
	void fn_vSetOnOff (BOOL bState);
	BOOL fn_bGetOnOff (void);

//ROMTEAM BlendRLI (Ionut Grozea 24/02/98)
	BOOL fn_bIsPaint(void);
	BOOL fn_bIsAlphaLight(void);
	BOOL fn_bIsNoAlphaLight(void);
	void fn_vSetTypePaint();
	void fn_vSetLightForAlpha();
	void fn_vSetTypeNormal();
//ENDROMTEAM BlendRLI (Ionut Grozea)
//ROMTEAM color lights Ionut Grozea 10-08-1998
	void SetMultiColor();
	void Set2Colors();
//ENDROMTEAM color lights Ionut Grozea 10-08-1998
	//--- On decor
	void fn_vSetOnDecor (BOOL bState); 
	BOOL fn_bGetOnDecor (void);

	//---- selection of light
	void fn_vSelect (void);
	void fn_vUnSelect (BOOL bDraw=TRUE);

	//--- draw edit objects
	void fn_vDrawEditObject (void);

	//--- light move
	void fn_vOrientLight ( MTH3D_tdstVector* pstVertex );

	//--- Paint sectors
	void fn_vPaintSector (BOOL bColor=TRUE);

	//--- Compute sectors
	ACP_tdxBool fn_bSphericalLightAffectSector(HIE_tdxHandleToSuperObject hSuperSector);
	void fn_vComputeSector (void);
	void fn_vComputeSector ( MTH3D_tdstVector* pstVertex );

	//--- Update light from .lg2 file
	void fn_vUpdateLight (BOOL bComputeRLI=TRUE,BOOL bUpdateScreen=TRUE);

	void *GetEngineStruct() { return GetStruct(); };

	//------------------------------- compute motor object
	void fn_vSetEngineMatrix (BOOL bDraw=TRUE);

	//--- Referenced light ?
	BOOL fn_bReferenced (void) { return m_oSectorList.GetCount()>0; }

protected :
	void fn_vSetNearFar ( MTH_tdxReal xNear, MTH_tdxReal xFar );

	// color a sector
	void fn_vColorSector ( CPA_SuperObject* poSuperSector, tdeLocalColor eColor );

	// Is pSector see pIsVisibleSector ?
	BOOL fn_bIsSectorVisible ( CPA_SuperObject *pSector, CPA_SuperObject *pIsVisibleSector);

	// Check if engine sector limit
	BOOL fn_bCheckEngineLimit (CPA_SuperObject* poSuperObject);

};

extern CPA_List<Light> g_ListLight;

#endif //__OBJECT_HPP__
