/*=========================================================================
* Light.cpp : Light's functions
*
*
*
*         Light MUST BE REPLACE BY THE C FILENAME
*
*
* Version              1.0
* Creation date        01/10/96
* Revision date
*
* That file needs to be compatible for all platforms.
*
* (c) Ubi Studios 1996
*=======================================================================*/
 
/*******************************************************/
/**** For the structures and variables declarations ****/
/*******************************************************/
#define D_MSLight_StructureDefine
#define D_MSLight_VariableDefine
 
#include "ACP_Base.h"
#include "CPA_Expt.h"
 
 
#ifdef U64
#include "CPA_Std.h"
#include "GEO/color.h" 
#endif /*U64*/
 
 
#ifndef U64
#include "ToolsCPA.h"
#include "../../GLIGLOU/MULTIDRV/INC/light_st.h"
#else
#include "../../GLI/specif/light_st.h"
#include "ToolsCPA.h"
#endif /*U64*/
 
 
 
#include "Options/Options.h"
#include "Macros.h"
 
#include "Actions/AllActs.h"
 
#include "Structur/MemGame.h"
#include "Structur/ErrGame.h"
#include "Structur/Objects.h"
#include "Structur/GameScpt.h"
#include "Structur/StdObjSt.h"
#include "Structur/EngMode.h"
 
#include "Basic.h"
#include "GameEng.h"
#include "ObjInit.h"
#include "ZeMem.h"
#include "toolmatr.h"
 
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
GEO_tdstColor MSLight_g_stColorTmpColor;
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*-----------------------------------------------------------------------------
 *  Description : Light's object action script callback
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date : 18/02/96        Modification Author : Michaël
 *  Modifications : Direct access to GLI_tdstLight
 *---------------------------------------------------------------------------*/
#if defined(GAM_USE_SCRIPT)
SCR_tde_Anl_ReturnValue fn_eLightScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action	_eAction)
{
	SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
	MS_tdxHandleToMSLight h_MSLight;
	struct tdstEngineObject_ *p_stEngineObject;
 
	_p_stFile=_p_stFile;
 
	SCR_M_RdL0_GetSectionLong(C_ParentSection,0,struct tdstEngineObject_ *, p_stEngineObject);
 
	if (M_IsTitle)
	{
        MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeLight , p_stEngineObject);
		h_MSLight = fn_h_LightRealAlloc();
        MMG_fn_vEndMemoryInfo ();
		p_stEngineObject->h_MSLight=h_MSLight;
 
		M_CheckScriptParamNumber(1);
		if (!stricmp(_ap_szParams[0],"Parallel"))
			fn_vMSLightSetTypeOfLight(h_MSLight,1);
		else if (!stricmp(_ap_szParams[0],"Spherical"))
			fn_vMSLightSetTypeOfLight(h_MSLight,2);
		else if (!stricmp(_ap_szParams[0],"HotSpot"))
			fn_vMSLightSetTypeOfLight(h_MSLight,3);
		else if (!stricmp(_ap_szParams[0],"Ambient"))
			fn_vMSLightSetTypeOfLight(h_MSLight,4);
		/*CHINA WFQ (MT) 16-02-98 {*/
		else if (!stricmp(_ap_szParams[0],"ParallelBox"))
			fn_vMSLightSetTypeOfLight(h_MSLight,5);
		/*ENDCHINA WFQ }*/
		else
			fn_vMSLightSetTypeOfLight(h_MSLight,4);
 
		SCR_M_RdL0_SetSectionLong(C_ThisSection,0,h_MSLight);
	}
	else if (M_IsEntry)
	{
		SCR_M_RdL0_GetSectionLong(C_ThisSection,0,MS_tdxHandleToMSLight,h_MSLight);
		if (M_ActionIs(C_EntryLightOnOff))
		{
			M_CheckScriptParamNumber(1);
			fn_vMSLightSetOnOff(h_MSLight,(unsigned char)fn_lAToI(_ap_szParams[0]));
		}
		else if (M_ActionIs(C_EntryLightFarNear))
		{
			M_CheckScriptParamNumber(2);
			fn_vMSLightSetNearFar(h_MSLight,fn_fAToF(_ap_szParams[1]),fn_fAToF(_ap_szParams[0]));
		}
		else if (M_ActionIs(C_EntryLightLittleBigAlpha))
		{
			M_CheckScriptParamNumber(2);
			fn_vMSLightSetAlphas(h_MSLight,fn_fAToF(_ap_szParams[0]),fn_fAToF(_ap_szParams[1]));
		}
		else if (M_ActionIs(C_EntryLightColor))
		{
			M_CheckScriptParamNumber(4);
			fn_vMSLightSetColorRGBA(h_MSLight,(GEO_tdxColorValue)fn_fAToF(_ap_szParams[0]),(GEO_tdxColorValue)fn_fAToF(_ap_szParams[1]),(GEO_tdxColorValue)fn_fAToF(_ap_szParams[2]),(GEO_tdxColorValue)fn_fAToF(_ap_szParams[3]));
		}
		else if (M_ActionIs(C_EntryGiroPhare))
		{
			M_CheckScriptParamNumber(2);
			fn_vMSLightSetGiroPhare(h_MSLight,(unsigned char)fn_lAToI(_ap_szParams[0]),fn_fAToF(_ap_szParams[1]));
		}
		else if (M_ActionIs(C_EntryPulse))
		{
			M_CheckScriptParamNumber(3);
			fn_vMSLightSetPulse(h_MSLight,(unsigned char)fn_lAToI(_ap_szParams[0]),fn_fAToF(_ap_szParams[1]),fn_fAToF(_ap_szParams[2]));
		}
		else if (M_ActionIs(C_EntryOffset))
		{
			M_CheckScriptParamNumber(3);
			fn_vMSLightSetOffset(h_MSLight,fn_fAToF(_ap_szParams[0]),fn_fAToF(_ap_szParams[1]),fn_fAToF(_ap_szParams[2]));
		}
		else if (M_ActionIs(C_EntryDirection))
		{
			M_CheckScriptParamNumber(3);
			fn_vMSLightSetDirection(h_MSLight,fn_fAToF(_ap_szParams[0]),fn_fAToF(_ap_szParams[1]),fn_fAToF(_ap_szParams[2]));
		}
		/*ANNECY CT 13/01/98 {*/
		else if (M_ActionIs(C_EntryLocalLight))
		{
			M_CheckScriptParamNumber(1);
			fn_vMSLightSetLocalLight(h_MSLight,(unsigned char)fn_lAToI(_ap_szParams[0]));
		}
		else if (M_ActionIs(C_EntryOnlyLocalLight))
		{
			M_CheckScriptParamNumber(1);
			fn_vMSLightSetOnlyLocalLight(h_MSLight,(unsigned char)fn_lAToI(_ap_szParams[0]));
		}
		/*ENDANNECY CT }*/
		/*CHINA WFQ (MT) 16-02-98 {*/
		else if (M_ActionIs(C_EntryInterMinPos))
		{
			M_CheckScriptParamNumber(3);
			fn_xMSLightSetInterMinXYZ(h_MSLight,fn_fAToF(_ap_szParams[0]), fn_fAToF(_ap_szParams[1]), fn_fAToF(_ap_szParams[2]));
		}
		else if (M_ActionIs(C_EntryInterMaxPos))
		{
			M_CheckScriptParamNumber(3);
			fn_xMSLightSetInterMaxXYZ(h_MSLight,fn_fAToF(_ap_szParams[0]), fn_fAToF(_ap_szParams[1]), fn_fAToF(_ap_szParams[2]));
		}
		else if (M_ActionIs(C_EntryExterMinPos))
		{
			M_CheckScriptParamNumber(3);
			fn_xMSLightSetExterMinXYZ(h_MSLight,fn_fAToF(_ap_szParams[0]), fn_fAToF(_ap_szParams[1]), fn_fAToF(_ap_szParams[2]));
		}
		else if (M_ActionIs(C_EntryExterMaxPos))
		{
			M_CheckScriptParamNumber(3);
			fn_xMSLightSetExterMaxXYZ(h_MSLight,fn_fAToF(_ap_szParams[0]), fn_fAToF(_ap_szParams[1]), fn_fAToF(_ap_szParams[2]));
		}
		else if (M_ActionIs(C_EntryIntensityMinMax))
		{
			M_CheckScriptParamNumber(2);
			fn_xMSLightSetIntensityMinMax(h_MSLight,fn_fAToF(_ap_szParams[0]), fn_fAToF(_ap_szParams[1]));
		}
		/*ENDCHINA WFQ }*/
	}
 
	return(eReturnValue);
}
#endif /* GAM_USE_SCRIPT */
 
/*-----------------------------------------------------------------------------
 *  Description : Light's mini-structure sizeof
 *-----------------------------------------------------------------------------
 *  Input :         None
 *  Output :        Size of
 *-----------------------------------------------------------------------------
 *  Creation date : 14/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
unsigned long fn_ulLightSizeOf()
{
 return(sizeof(struct tdstMSLight_));
}
 
/*-----------------------------------------------------------------------------
 *  Description : Light's object action allocation
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vLightAlloc(struct tdstEngineObject_ *p_stObject)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_MSLight!=NULL)
  M_GameFatalError(E_uwGameMiniStructAllocAlreadyAlloc);
 
 MMG_fn_vBeginMemoryInfo (MMG_C_lTypeMiniStructure , MMG_C_lSubTypeLight , p_stObject);
 p_stObject->h_MSLight = fn_h_LightRealAlloc();
 MMG_fn_vEndMemoryInfo ();
 fn_vLightInitValueSAI(p_stObject->h_MSLight);
}
/*************************************************************************/
MS_tdxHandleToMSLight fn_h_LightRealAlloc()
{
	MS_tdxHandleToMSLight h_MSLight;
 
	h_MSLight = (MS_tdxHandleToMSLight)M_p_GameMallocInHLM(fn_ulLightSizeOf());
 
	fn_vMSLightSetGiroAngle(h_MSLight,0);
	fn_vMSLightSetOffset(h_MSLight,0,0,0);
	fn_vMSCreateLightWithType(h_MSLight,1);
 
	h_MSLight->hLightInSector = SECT_fn_hCreateElementLstDNMLights();
	return(h_MSLight);
}
 
/*-----------------------------------------------------------------------------
 *  Description : Light's object action free
 *-----------------------------------------------------------------------------
 *  Input :         Object pointer
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vLightFree(struct tdstEngineObject_ *p_stObject)
{
 if (p_stObject==NULL)
  M_GameFatalError(E_uwGameMiniStructObjectNull);
 
 if (p_stObject->h_MSLight==NULL)
  M_GameFatalError(E_uwGameMiniStructNull);
 
 fn_vLightFreeInitValueSAI(p_stObject->h_MSLight);
 MMG_fn_vAddMemoryInfo( MMG_C_lTypeMiniStructure , MMG_C_lSubTypeLight , p_stObject );
 M_GameFreeInHLM(p_stObject->h_MSLight);
}
 
/*-----------------------------------------------------------------------------
 *  Description : Light's object action initialisation
 *-----------------------------------------------------------------------------
 *  Input :         When this function's called (see ObjInit.h)
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date : 10 06 98        Modification Author : Fabien Bole-Feysot
 *  Modifications :	init matrix2 to complete position
 *---------------------------------------------------------------------------*/
void fn_vLightInit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit)
{
	POS_tdstCompletePosition *p_stMatrix,stMatrix2;
	HIE_tdxHandleToSuperObject /*hSuperObj,*/hSuperObjFather;
 
	if (p_stObject==NULL)
		M_GameFatalError(E_uwGameMiniStructObjectNull);
 
	if (p_stObject->h_MSLight==NULL)
		M_GameFatalError(E_uwGameMiniStructNull);
 
	switch(eObjectInit)
	{
	case OTI_MapLoaded:
		fn_vLightInitValueSAI(p_stObject->h_MSLight);
		fn_vLightSavedValueSAI(p_stObject->h_MSLight);
	case OTI_WhenGameStart:
		if (GLI_lGetLightType(fn_p_stMSLightGetLight(p_stObject->h_MSLight))!=GLI_C_lHotSpotLight)
		{
			p_stObject->h_MSLight->p_stVisuLight=fn_pCreateSphere(fn_xMSLightGetOffsetX(p_stObject->h_MSLight),fn_xMSLightGetOffsetY(p_stObject->h_MSLight),fn_xMSLightGetOffsetZ(p_stObject->h_MSLight),(MTH_tdxReal)0.2);
		}
		else
		{
			p_stObject->h_MSLight->p_stVisuLight=fn_pCreateCone(fn_xMSLightGetOffsetX(p_stObject->h_MSLight),fn_xMSLightGetOffsetY(p_stObject->h_MSLight),fn_xMSLightGetOffsetZ(p_stObject->h_MSLight),(MTH_tdxReal)1);
		}
 
	case OTI_AlwaysCreated:
	case OTI_PlayerDead:
	case OTI_ReinitTheMap:
	case OTI_LoadSavedGame:
		/* Update GLI_tdstLight object*/
		/* Set the matrix of the light equal to its father's one*/
		hSuperObjFather=M_GetSuperObject(p_stObject);
		if (hSuperObjFather!=NULL)
		{
			p_stMatrix=HIE_fn_hGetSuperObjectMatrix(hSuperObjFather);
/*			POS_fn_vInitPositionFlag(&stMatrix2); //AR 980623 position MUST be initialised*/
			POS_fn_vInvertIsoMatrix(&stMatrix2,p_stMatrix);
			POS_fn_vNormalizeMatrix(&stMatrix2);
			GLI_xSetLightMatrix ( fn_p_stMSLightGetLight(p_stObject->h_MSLight) , &stMatrix2);
		}
		break;
	}
}
 
#define C_Light_SAIInitFlags (SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded)
 
/*************************************************************************/
void fn_vLightInitValueSAI(MS_tdxHandleToMSLight _h_MSLight)
{
 /**** structure light GLI ****/
 GLI_vStoreLightForInit(_h_MSLight->p_stLight,SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded);
 
 /**** strcuture light MS ****/
 SAI_fn_bInsertMTHVectorInTable((void*)&_h_MSLight->stOffsetVect, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHVectorInTable((void*)&_h_MSLight->stAngle, C_Light_SAIInitFlags);
 SAI_fn_bInsertCharInTable((void*)&_h_MSLight->bPulsing, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xStepPulse, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xMaxRangePulse, C_Light_SAIInitFlags);
 SAI_fn_bInsertCharInTable((void*)&_h_MSLight->bLocalLight, C_Light_SAIInitFlags);
 SAI_fn_bInsertCharInTable((void*)&_h_MSLight->bOnlyLocalLight, C_Light_SAIInitFlags);
 SAI_fn_bInsertCharInTable((void*)&_h_MSLight->bGiroPhare, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xStepGiro, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xGiroAngle, C_Light_SAIInitFlags);
/* ANNECY AV {*/
/*
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xZ, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xZ, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xZ, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xZ, C_Light_SAIInitFlags);
*/
 SAI_fn_bInsertArrayInTable (& _h_MSLight -> p_stLight -> xInter_Min_Pos , sizeof (MTH3D_tdstVector) , C_Light_SAIInitFlags);
 SAI_fn_bInsertArrayInTable (& _h_MSLight -> p_stLight -> xInter_Max_Pos , sizeof (MTH3D_tdstVector) , C_Light_SAIInitFlags);
 SAI_fn_bInsertArrayInTable (& _h_MSLight -> p_stLight -> xExter_Min_Pos , sizeof (MTH3D_tdstVector) , C_Light_SAIInitFlags);
 SAI_fn_bInsertArrayInTable (& _h_MSLight -> p_stLight -> xExter_Max_Pos , sizeof (MTH3D_tdstVector) , C_Light_SAIInitFlags);
/* END ANNECY AV }*/
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xIntensity_Min, C_Light_SAIInitFlags);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xIntensity_Max, C_Light_SAIInitFlags);
}
/*************************************************************************/
void fn_vLightSavedValueSAI(MS_tdxHandleToMSLight _h_MSLight)
{
 /*
 // *** structure light GLI ***	- Oliv' - Portage v15 - 1 warning removed here
 GLI_vStoreLightForInit(_h_MSLight->p_stLight,SAI_ePlayerSaveCurrentValue);
 
 SAI_fn_bInsertMTHVectorInTable((void*)&_h_MSLight->stOffsetVect,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHVectorInTable((void*)&_h_MSLight->stAngle,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertCharInTable((void*)&_h_MSLight->bPulsing,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xStepPulse,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xMaxRangePulse,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertCharInTable((void*)&_h_MSLight->bGiroPhare,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xStepGiro,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->xGiroAngle,SAI_ePlayerSaveCurrentValue);
//CHINA WFQ (MT) 16-02-98 {
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xX,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xY,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xZ,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xX,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xY,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xZ,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xX,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xY,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xZ,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xX,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xY,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xZ,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xIntensity_Min,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bInsertMTHRealInTable((void*)&_h_MSLight->p_stLight->xIntensity_Max,SAI_ePlayerSaveCurrentValue);
//ENDCHINA WFQ }
 */
}
/*************************************************************************/
void fn_vLightFreeInitValueSAI(MS_tdxHandleToMSLight _h_MSLight)
{
 GLI_vRemoveLightForInit(_h_MSLight->p_stLight, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->stOffsetVect, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->stAngle, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->bPulsing, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xStepPulse, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xMaxRangePulse, C_Light_SAIInitFlags);
/*ANNECY CT 13/01/98 {*/
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->bLocalLight, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->bOnlyLocalLight, C_Light_SAIInitFlags);
/*ENDANNECY CT }*/
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->bGiroPhare, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xStepGiro, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xGiroAngle, C_Light_SAIInitFlags);
/*CHINA WFQ (MT) 16-02-98 {*/
/* ANNECY AV {*/
/*
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos.xZ, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos.xZ, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos.xZ, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xX, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xY, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos.xZ, C_Light_SAIInitFlags);
*/
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Min_Pos, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xInter_Max_Pos, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Min_Pos, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xExter_Max_Pos, C_Light_SAIInitFlags);
/* END ANNECY AV }*/
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xIntensity_Min, C_Light_SAIInitFlags);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->p_stLight->xIntensity_Max, C_Light_SAIInitFlags);
 /*ENDCHINA WFQ }*/
 /*
 GLI_vRemoveLightForInit(_h_MSLight->p_stLight,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->stOffsetVect,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->stAngle,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->bPulsing,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xStepPulse,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xMaxRangePulse,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->bGiroPhare,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xStepGiro,SAI_ePlayerSaveCurrentValue);
 SAI_fn_bRemoveValueFromTable((void*)&_h_MSLight->xGiroAngle,SAI_ePlayerSaveCurrentValue);
 */
}
/*************************************************************************/
 
/*-----------------------------------------------------------------------------
 *  Description : Light's object action desinitialisation
 *-----------------------------------------------------------------------------
 *  Input :         When this function's called (see ObjInit.h)
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 01/10/96            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vLightDesinit(struct tdstEngineObject_ *p_stObject,enum tdeObjectTreeInit_ eObjectInit)
{
	if (p_stObject==NULL)
		M_GameFatalError(E_uwGameMiniStructObjectNull);
 
	if (p_stObject->h_MSLight==NULL)
		M_GameFatalError(E_uwGameMiniStructNull);
 
	switch(eObjectInit)
	{
	case OTI_ReinitTheMap:
		break;
	case OTI_MapLoaded:
		break;
	case OTI_AlwaysCreated:
	case OTI_PlayerDead:
		break;
	default:
		break;
	}
}
 
/*-----------------------------------------------------------------------------
 *  Description : Light's object copy clone action
 *-----------------------------------------------------------------------------
 *  Input :         Handle to destination, handle to source
 *  Output :        None
 *-----------------------------------------------------------------------------
 *  Creation date : 30/06/97            Author : Olivier Jourdan
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vLightCopyClone(struct tdstEngineObject_ * _p_stObjectDest,struct tdstEngineObject_ * _p_stObjectSrc)
{
 GLI_tdstLight *p_stLight;
 SECT_tdxHandleOfElementLstDNMLights hLightInSector;
 
 p_stLight      = fn_p_stMSLightGetLight(_p_stObjectDest->h_MSLight);
 hLightInSector = fn_hMSLightGetLightNodeInSector(_p_stObjectDest->h_MSLight);
 
 memcpy(_p_stObjectDest->h_MSLight,_p_stObjectSrc->h_MSLight,fn_ulLightSizeOf());
 
 fn_vMSLightSetLight(_p_stObjectDest->h_MSLight,p_stLight);
 
 GLI_vCopyLight(fn_p_stMSLightGetLight(_p_stObjectDest->h_MSLight),fn_p_stMSLightGetLight(_p_stObjectSrc->h_MSLight));
 fn_vMSLightSetLightNodeInSector(_p_stObjectDest->h_MSLight,hLightInSector);
}
 
/*-----------------------------------------------------------------------------
 *  Description : MSLight access functions
 *-----------------------------------------------------------------------------
 *  Input :         MS_tdxHandleToMSLight + (value)
 *  Output :        (value or pointer)
 *-----------------------------------------------------------------------------
 *  Creation date : 04/02/97            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date : 18/2/97         Modification Author : Michaël
 *  Modifications : Direct Access to GLI_tdstLight
 *---------------------------------------------------------------------------*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vLightReInit(struct tdstEngineObject_ *p_stObject)
{
	if( p_stObject && p_stObject->h_MSLight)
	{
		MS_tdxHandleToMSLight h_MSLight = p_stObject->h_MSLight;
 
		/**** structure light GLI ****/
		GLI_vReInitLight(h_MSLight->p_stLight,SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded);
 
		/**** strcuture light MS ****/
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->stOffsetVect, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->stAngle, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->bPulsing, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->xStepPulse, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->xMaxRangePulse, C_Light_SAIInitFlags);
		/*ANNECY CT 13/01/98 {*/
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->bLocalLight, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->bOnlyLocalLight, C_Light_SAIInitFlags);
		/*ENDANNECY CT }*/
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->bGiroPhare, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->xStepGiro, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->xGiroAngle, C_Light_SAIInitFlags);
		/*CHINA WFQ (MT) 16-02-98 {*/
/* ANNECY AV {*/
/*
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Min_Pos.xX, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Min_Pos.xY, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Min_Pos.xZ, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Max_Pos.xX, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Max_Pos.xY, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Max_Pos.xZ, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Min_Pos.xX, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Min_Pos.xY, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Min_Pos.xZ, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Max_Pos.xX, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Max_Pos.xY, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Max_Pos.xZ, C_Light_SAIInitFlags);
*/
        SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Min_Pos, C_Light_SAIInitFlags);
        SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xInter_Max_Pos, C_Light_SAIInitFlags);
        SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Min_Pos, C_Light_SAIInitFlags);
        SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xExter_Max_Pos, C_Light_SAIInitFlags);
/* END ANNECY AV }*/
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xIntensity_Min, C_Light_SAIInitFlags);
		SAI_fn_bInitOneValueWhen((void*)&h_MSLight->p_stLight->xIntensity_Max, C_Light_SAIInitFlags);
		/* ENDCHINA WFQ }*/
	}
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
/*-----------------------------------------------------------------------------
 *  Description : MSLight access functions
 *-----------------------------------------------------------------------------
 *  Input :         MS_tdxHandleToMSLight + (value)
 *  Output :        (value or pointer)
 *-----------------------------------------------------------------------------
 *  Creation date : 04/02/97            Author : Francois
 *-----------------------------------------------------------------------------
 *  Modification date : 18/2/97         Modification Author : Michaël
 *  Modifications : Direct Access to GLI_tdstLight
 *---------------------------------------------------------------------------*/
SECT_tdxHandleOfElementLstDNMLights fn_hMSLightGetLightNodeInSector(MS_tdxHandleToMSLight _hMSLight)
{
   return _hMSLight->hLightInSector;
}
void fn_vMSLightSetLightNodeInSector(MS_tdxHandleToMSLight _hMSLight,SECT_tdxHandleOfElementLstDNMLights _hLightNode)
{
   _hMSLight->hLightInSector = _hLightNode;
}
 
/*************************************/
/**** Access functions for Editor ****/
/*************************************/
#if defined(ACTIVE_EDITOR)
 
/*ANNECY CT 13/01/98 {*/
/* Local Light*/
/*************************************************************************/
unsigned char *fn_p_ucMSLightGetLocalLightInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (unsigned char *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->bLocalLight, C_Light_SAIInitFlags);
}
/* OnlyLocalLight*/
/*************************************************************************/
unsigned char *fn_p_ucMSLightGetOnlyLocalInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (unsigned char *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->bOnlyLocalLight, C_Light_SAIInitFlags);
}
/*ENDANNECY CT }*/
 
/*************************************************************************/
unsigned char *fn_p_ucMSLightGetGiroPhareInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (unsigned char *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->bGiroPhare, C_Light_SAIInitFlags);
}
/*************************************************************************/
unsigned char *fn_p_ucMSLightGetPulsingInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (unsigned char *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->bPulsing, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH3D_tdstVector *fn_p_stMSLightGetOffsetVectInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH3D_tdstVector *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->stOffsetVect, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH3D_tdstVector *fn_p_stMSLightGetAngleInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH3D_tdstVector *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->stAngle, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetStepGiroInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->xStepGiro, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetStepPulseInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->xStepPulse, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetMaxRangePulseInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->xMaxRangePulse, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetGiroAngleInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->xGiroAngle, C_Light_SAIInitFlags);
}
/*************************************************************************/
long *fn_p_lMSLightGetOnOffInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (long *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->b_lOnOff, C_Light_SAIInitFlags);
}
/*************************************************************************/
long *fn_p_lMSLightGetTypeInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (long *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->lTypeOfLight, C_Light_SAIInitFlags);
}
 
/* ANNECY AV {*/
#ifdef ACTIVE_EDITOR
/*************************************************************************/
/*CHINA WFQ (MT) 16-02-98{*/
MTH3D_tdstVector *fn_p_stMSLightGetInterMinInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH3D_tdstVector *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Min_Pos, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetInterMinXInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetInterMinInit(_hMSLight) -> xX;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Min_Pos.xX, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetInterMinYInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetInterMinInit(_hMSLight) -> xY;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Min_Pos.xY, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetInterMinZInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetInterMinInit(_hMSLight) -> xZ;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Min_Pos.xZ,SAI_eInitWhenPlayerDead|SAI_eInitWhenReinitTheMap|SAI_eInitWhenMapLoaded);*/
}
/*************************************************************************/
MTH3D_tdstVector *fn_p_stMSLightGetInterMaxInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH3D_tdstVector *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Max_Pos, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetInterMaxXInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetInterMaxInit(_hMSLight) -> xX;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Max_Pos.xX, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetInterMaxYInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetInterMaxInit(_hMSLight) -> xY;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Max_Pos.xY, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetInterMaxZInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetInterMaxInit(_hMSLight) -> xZ;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xInter_Max_Pos.xZ, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH3D_tdstVector *fn_p_stMSLightGetExterMinInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH3D_tdstVector *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Min_Pos, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetExterMinXInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetExterMinInit(_hMSLight) -> xX;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Min_Pos.xX, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetExterMinYInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetExterMinInit(_hMSLight) -> xY;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Min_Pos.xY, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetExterMinZInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetExterMinInit(_hMSLight) -> xZ;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Min_Pos.xZ, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH3D_tdstVector *fn_p_stMSLightGetExterMaxInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH3D_tdstVector *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Max_Pos, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetExterMaxXInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetExterMaxInit(_hMSLight) -> xX;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Max_Pos.xX, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetExterMaxYInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetExterMaxInit(_hMSLight) -> xY;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Max_Pos.xY, C_Light_SAIInitFlags);*/
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetExterMaxZInit(MS_tdxHandleToMSLight _hMSLight)
{
 return & fn_p_stMSLightGetExterMaxInit(_hMSLight) -> xZ;
/*    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xExter_Max_Pos.xZ, C_Light_SAIInitFlags);*/
}
#endif  /* #ifdef ACTIVE_EDITOR*/
/* END ANNECY AV }*/
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetIntensityMinInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xIntensity_Min, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetIntensityMaxInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xIntensity_Max, C_Light_SAIInitFlags);
}
/*************************************************************************/
/*ENDCHINA WFQ }*/
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetFarInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xFar, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetNearInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xNear, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetLittleAlphaInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xLittleAlpha, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetBigAlphaInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xBigAlpha, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetLittleTangentInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xLittleTangent, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetBigTangentInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->xBigTangent, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetColorRInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->stColor.xR, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetColorBInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->stColor.xB, C_Light_SAIInitFlags);
}
/*************************************************************************/
MTH_tdxReal *fn_p_xMSLightGetColorGInit(MS_tdxHandleToMSLight _hMSLight)
{
 return
    (MTH_tdxReal *)SAI_fn_p_vGetTableValuePointerOf((void*)&_hMSLight->p_stLight->stColor.xG, C_Light_SAIInitFlags);
}
/* END ANNECY MT }*/
/*************************************************************************/
#endif /* ACTIVE_EDITOR */
 
/********************************************
 *** Access functions for currents values ***
 ********************************************/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
long fn_lMSLightGetTypeOfLight(MS_tdxHandleToMSLight h_MSLight)
{
 return(GLI_lGetLightType(fn_p_stMSLightGetLight(h_MSLight)));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vMSLightSetTypeOfLight(MS_tdxHandleToMSLight h_MSLight,long lTypeOfLight)
{
 GLI_vSetLightType(fn_p_stMSLightGetLight(h_MSLight),lTypeOfLight);
}
 
unsigned char fn_ucMSLightGetOnOff(MS_tdxHandleToMSLight h_MSLight)
{
 long lOnOff;
 
 GLI_xGetLightState(fn_p_stMSLightGetLight(h_MSLight),&lOnOff);
 return ((unsigned char)lOnOff);
}
void fn_vMSLightSetOnOff(MS_tdxHandleToMSLight h_MSLight,unsigned char ucOnOff)
{
 GLI_xSetLightState(fn_p_stMSLightGetLight(h_MSLight),ucOnOff);
}
void fn_vMSCreateLightWithType(MS_tdxHandleToMSLight h_MSLight,long lTypeOfLight)
{
 GLI_xCreateLight(fn_pp_stMSLightGetLight(h_MSLight),lTypeOfLight);
}
MTH_tdxReal fn_xMSLightGetFar(MS_tdxHandleToMSLight h_MSLight)
{
 MTH_tdxReal xFar,xNear;
 
 GLI_vGetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),&xNear,&xFar);
 return xFar;
}
void fn_vMSLightSetNearFar(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xNear,MTH_tdxReal xFar)
{
 GLI_vSetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),xNear,xFar);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vMSLightSetFar(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xFar)
{
 MTH_tdxReal xFarIni,xNearIni;
 GLI_vGetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),&xNearIni,&xFarIni);
 GLI_vSetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),xNearIni,xFar);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetNear(MS_tdxHandleToMSLight h_MSLight)
{
 MTH_tdxReal xFar,xNear;
 
 GLI_vGetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),&xNear,&xFar);
 return xNear;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vMSLightSetNear(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xNear)
{
 MTH_tdxReal xFarIni,xNearIni;
 GLI_vGetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),&xNearIni,&xFarIni);
 GLI_vSetLightNearFar(fn_p_stMSLightGetLight(h_MSLight),xNear,xFarIni);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vMSLightSetAlphas(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xLittleAlpha,MTH_tdxReal xBigAlpha)
{
 GLI_vSetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),xLittleAlpha,xBigAlpha);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetLittleAlpha(MS_tdxHandleToMSLight h_MSLight)
{
 MTH_tdxReal xLittleAlpha,xBigAlpha;
 
 GLI_vGetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),&xLittleAlpha,&xBigAlpha);
 return xLittleAlpha;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vMSLightSetLittleAlpha(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xLittleAlpha)
{
 MTH_tdxReal xLittleIni,xBigIni;
 GLI_vGetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),&xLittleIni,&xBigIni);
 GLI_vSetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),xLittleAlpha,xBigIni);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetBigAlpha(MS_tdxHandleToMSLight h_MSLight)
{
 MTH_tdxReal xLittleAlpha,xBigAlpha;
 
 GLI_vGetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),&xLittleAlpha,&xBigAlpha);
 return xBigAlpha;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vMSLightSetBigAlpha(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xBigAlpha)
{
 MTH_tdxReal xLittleIni,xBigIni;
 GLI_vGetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),&xLittleIni,&xBigIni);
 GLI_vSetLightAlphas(fn_p_stMSLightGetLight(h_MSLight),xLittleIni,xBigAlpha);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
GEO_tdstColor *fn_p_stMSLightGetColor(MS_tdxHandleToMSLight h_MSLight)
{
 GLI_xGetLightColor(fn_p_stMSLightGetLight(h_MSLight),&MSLight_g_stColorTmpColor);
 
 return (&MSLight_g_stColorTmpColor);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vMSLightSetColor(MS_tdxHandleToMSLight h_MSLight,GEO_tdstColor *p_stColor)
{
 GLI_xSetLightColor(fn_p_stMSLightGetLight(h_MSLight),p_stColor);
}
void fn_vMSLightSetColorRGBA(MS_tdxHandleToMSLight h_MSLight,GEO_tdxColorValue xR,GEO_tdxColorValue xG,GEO_tdxColorValue xB,GEO_tdxColorValue xA)
{
 GEO_tdstColor stColor;
 
 stColor.xR=xR;
 stColor.xG=xG;
 stColor.xB=xB;
 stColor.xA=xA;
 fn_vMSLightSetColor(h_MSLight,&stColor);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
GEO_tdxColorValue fn_xMSLightGetColorR(MS_tdxHandleToMSLight h_MSLight)
{
 GEO_tdstColor stColor;
 
 GLI_xGetLightColor (fn_p_stMSLightGetLight(h_MSLight),&stColor);
 return(stColor.xR);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
GEO_tdxColorValue fn_xMSLightGetColorG(MS_tdxHandleToMSLight h_MSLight)
{
 GEO_tdstColor stColor;
 
 GLI_xGetLightColor (fn_p_stMSLightGetLight(h_MSLight),&stColor);
 return(stColor.xG);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
GEO_tdxColorValue fn_xMSLightGetColorB(MS_tdxHandleToMSLight h_MSLight)
{
 GEO_tdstColor stColor;
 
 GLI_xGetLightColor (fn_p_stMSLightGetLight(h_MSLight),&stColor);
 return(stColor.xB);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
GEO_tdxColorValue fn_xMSLightGetColorA(MS_tdxHandleToMSLight h_MSLight)
{
 GEO_tdstColor stColor;
 
 GLI_xGetLightColor (fn_p_stMSLightGetLight(h_MSLight),&stColor);
 return(stColor.xA);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
GLI_tdstLight **fn_pp_stMSLightGetLight(MS_tdxHandleToMSLight h_MSLight)
{
 return(&(h_MSLight->p_stLight));
}
GLI_tdstLight *fn_p_stMSLightGetLight(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->p_stLight);
}
void fn_vMSLightSetLight(MS_tdxHandleToMSLight h_MSLight,GLI_tdstLight *p_stLight)
{
 h_MSLight->p_stLight=p_stLight;
}
 
/*ANNECY CT 13/01/98 {*/
void fn_vMSLightSetLocalLight(MS_tdxHandleToMSLight h_MSLight,unsigned char bLocalLight) {
 h_MSLight->bLocalLight=bLocalLight;
}
unsigned char fn_bMSLightGetLocalLight(MS_tdxHandleToMSLight h_MSLight) {
 return(h_MSLight->bLocalLight);
}
 
void fn_vMSLightSetOnlyLocalLight(MS_tdxHandleToMSLight h_MSLight,unsigned char bOnlyLocalLight) {
 h_MSLight->bOnlyLocalLight=bOnlyLocalLight;
}
unsigned char fn_bMSLightGetOnlyLocalLight(MS_tdxHandleToMSLight h_MSLight) {
 return(h_MSLight->bOnlyLocalLight);
}
/*ENDANNECY CT }*/
 
void fn_vMSLightSetGiroPhare(MS_tdxHandleToMSLight h_MSLight,unsigned char bOnOff,MTH_tdxReal xStep)
{
 h_MSLight->bGiroPhare=bOnOff;
 h_MSLight->xStepGiro=xStep;
}
unsigned char fn_bMSLightGetGiroPhare(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->bGiroPhare);
}
MTH_tdxReal fn_xMSLightGetGiroStep(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->xStepGiro);
}
void fn_vMSLightSetGiroAngle(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xAngle)
{
 h_MSLight->xGiroAngle=xAngle;
}
MTH_tdxReal fn_xMSLightGetGiroAngle(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->xGiroAngle);
}
void fn_vMSLightSetPulse(MS_tdxHandleToMSLight h_MSLight,unsigned char bOnOff,MTH_tdxReal xStep,MTH_tdxReal xMaxRange)
{
 h_MSLight->bPulsing=bOnOff;
 h_MSLight->xStepPulse=xStep;
 h_MSLight->xMaxRangePulse=xMaxRange;
}
unsigned char fn_bMSLightGetPulse(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->bPulsing);
}
MTH_tdxReal fn_xMSLightGetPulseStep(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->xStepPulse);
}
void fn_xMSLightSetPulseStep(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xStep)
{
 h_MSLight->xStepPulse=xStep;
}
MTH_tdxReal fn_xMSLightGetPulseMaxRange(MS_tdxHandleToMSLight h_MSLight)
{
 return(h_MSLight->xMaxRangePulse);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_xMSLightSetPulseMaxRange(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xRange)
{
 h_MSLight->xMaxRangePulse=xRange;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
void fn_vMSLightSetOffset(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xX,MTH_tdxReal xY,MTH_tdxReal xZ)
{
	MTH3D_M_vSetXofVector(&h_MSLight->stOffsetVect,xX);
	MTH3D_M_vSetYofVector(&h_MSLight->stOffsetVect,xY);
	MTH3D_M_vSetZofVector(&h_MSLight->stOffsetVect,xZ);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
void fn_vMSLightSetOffsetVector(MS_tdxHandleToMSLight h_MSLight,MTH3D_tdstVector *p_stVector)
{
 MTH3D_M_vCopyVector(&h_MSLight->stOffsetVect,p_stVector);
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
MTH3D_tdstVector *fn_p_stMSLightGetOffset(MS_tdxHandleToMSLight h_MSLight)
{
	return(&(h_MSLight->stOffsetVect));
}
MTH_tdxReal fn_xMSLightGetOffsetX(MS_tdxHandleToMSLight h_MSLight)
{
	return((h_MSLight->stOffsetVect).xX);
}
MTH_tdxReal fn_xMSLightGetOffsetY(MS_tdxHandleToMSLight h_MSLight)
{
	return((h_MSLight->stOffsetVect).xY);
}
MTH_tdxReal fn_xMSLightGetOffsetZ(MS_tdxHandleToMSLight h_MSLight)
{
	return((h_MSLight->stOffsetVect).xZ);
}
/*CHINA WFQ (MT) 16-02-98 {*/
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetInterMinX(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xInterMin;
	GLI_vGetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),&xInterMin);
	return xInterMin.xX;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetInterMinY(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xInterMin;
	GLI_vGetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),&xInterMin);
	return xInterMin.xY;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetInterMinZ(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xInterMin;
	GLI_vGetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),&xInterMin);
	return xInterMin.xZ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetInterMaxX(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xInterMax;
	GLI_vGetLight_Inter_Max_Pos(fn_p_stMSLightGetLight(h_MSLight),&xInterMax);
	return xInterMax.xX;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetInterMaxY(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xInterMax;
	GLI_vGetLight_Inter_Max_Pos(fn_p_stMSLightGetLight(h_MSLight),&xInterMax);
	return xInterMax.xY;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetInterMaxZ(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xInterMax;
	GLI_vGetLight_Inter_Max_Pos(fn_p_stMSLightGetLight(h_MSLight),&xInterMax);
	return xInterMax.xZ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetExterMinX(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xExterMin;
	GLI_vGetLight_Exter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),&xExterMin);
	return xExterMin.xX;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetExterMinY(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xExterMin;
	GLI_vGetLight_Exter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),&xExterMin);
	return xExterMin.xY;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetExterMinZ(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xExterMin;
	GLI_vGetLight_Exter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),&xExterMin);
	return xExterMin.xZ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetExterMaxX(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xExterMax;
	GLI_vGetLight_Exter_Max_Pos(fn_p_stMSLightGetLight(h_MSLight),&xExterMax);
	return xExterMax.xX;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetExterMaxY(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xExterMax;
	GLI_vGetLight_Exter_Max_Pos(fn_p_stMSLightGetLight(h_MSLight),&xExterMax);
	return xExterMax.xY;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetExterMaxZ(MS_tdxHandleToMSLight h_MSLight)
{
	MTH3D_tdstVector xExterMax;
	GLI_vGetLight_Exter_Max_Pos(fn_p_stMSLightGetLight(h_MSLight),&xExterMax);
	return xExterMax.xZ;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetIntensityMin(MS_tdxHandleToMSLight h_MSLight)
{
	MTH_tdxReal xIntensity_Min, xIntensity_Max;
	GLI_vGetLight_Intensity_Min_Max(fn_p_stMSLightGetLight(h_MSLight),&xIntensity_Min, &xIntensity_Max);
	return xIntensity_Min;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetIntensityMax(MS_tdxHandleToMSLight h_MSLight)
{
	MTH_tdxReal xIntensity_Min, xIntensity_Max;
	GLI_vGetLight_Intensity_Min_Max(fn_p_stMSLightGetLight(h_MSLight),&xIntensity_Min, &xIntensity_Max);
	return xIntensity_Max;
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
void fn_xMSLightSetInterMinXYZ(MS_tdxHandleToMSLight h_MSLight, MTH_tdxReal xInterMinX , MTH_tdxReal xInterMinY,  MTH_tdxReal xInterMinZ)
{
	MTH3D_tdstVector xInterMin;
	xInterMin.xX = xInterMinX;xInterMin.xY = xInterMinY;xInterMin.xZ = xInterMinZ;
	GLI_vSetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),xInterMin);
}
 
void fn_xMSLightSetInterMaxXYZ(MS_tdxHandleToMSLight h_MSLight, MTH_tdxReal xInterMaxX, MTH_tdxReal xInterMaxY, MTH_tdxReal xInterMaxZ)
{
	MTH3D_tdstVector xInterMax;
	xInterMax.xX = xInterMaxX;xInterMax.xY = xInterMaxY;xInterMax.xZ = xInterMaxZ;
	GLI_vSetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),xInterMax);
}
 
void fn_xMSLightSetExterMinXYZ(MS_tdxHandleToMSLight h_MSLight, MTH_tdxReal xExterMinX, MTH_tdxReal xExterMinY, MTH_tdxReal xExterMinZ)
{
	MTH3D_tdstVector xExterMin;
	xExterMin.xX = xExterMinX;xExterMin.xY = xExterMinY;xExterMin.xZ = xExterMinZ;
	GLI_vSetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),xExterMin);
}
 
void fn_xMSLightSetExterMaxXYZ(MS_tdxHandleToMSLight h_MSLight, MTH_tdxReal xExterMaxX, MTH_tdxReal xExterMaxY, MTH_tdxReal xExterMaxZ)
{
	MTH3D_tdstVector xExterMax;
	xExterMax.xX = xExterMaxX;xExterMax.xY = xExterMaxY;xExterMax.xZ = xExterMaxZ;
	GLI_vSetLight_Inter_Min_Pos(fn_p_stMSLightGetLight(h_MSLight),xExterMax);
}
 
void fn_xMSLightSetIntensityMinMax(MS_tdxHandleToMSLight h_MSLight, MTH_tdxReal xIntensity_Min, MTH_tdxReal xIntensity_Max)
{
	GLI_vSetLight_Intensity_Min_Max(fn_p_stMSLightGetLight(h_MSLight),xIntensity_Min, xIntensity_Max);
}
 
/*ENDCHINA WFQ }*/
 
void fn_vMSLightSetDirection(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal xX,MTH_tdxReal xY,MTH_tdxReal xZ)
{
	MTH3D_M_vSetXofVector(&h_MSLight->stAngle,xX);
	MTH3D_M_vSetYofVector(&h_MSLight->stAngle,xY);
	MTH3D_M_vSetZofVector(&h_MSLight->stAngle,xZ);
}
void fn_vMSLightGetDirection(MS_tdxHandleToMSLight h_MSLight,MTH_tdxReal *p_xX,MTH_tdxReal *p_xY,MTH_tdxReal *p_xZ)
{
	*p_xX=MTH3D_M_xGetXofVector(&h_MSLight->stAngle);
	*p_xY=MTH3D_M_xGetYofVector(&h_MSLight->stAngle);
	*p_xZ=MTH3D_M_xGetZofVector(&h_MSLight->stAngle);
}
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetDirectionX(MS_tdxHandleToMSLight h_MSLight)
{
 return (MTH3D_M_xGetXofVector(&h_MSLight->stAngle));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetDirectionY(MS_tdxHandleToMSLight h_MSLight)
{
 return (MTH3D_M_xGetYofVector(&h_MSLight->stAngle));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifndef _FIRE_DEADCODE_U64_ /* Added by RUC */
MTH_tdxReal fn_xMSLightGetDirectionZ(MS_tdxHandleToMSLight h_MSLight)
{
 return (MTH3D_M_xGetYofVector(&h_MSLight->stAngle));
}
#endif /* _FIRE_DEADCODE_U64_ */ /* Added by RUC */
 
 
#ifdef __3DOSLIGHTS
/* Previously in dnmcame.c*/
GLI_tdxValue fn_xComputeAngleOfPerso(HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
   GLI_tdxValue xCos,xSin,xAngle;
 
   MTH3D_tdstVector p_stI,p_stJ,p_stK;
   POS_fn_vGetRotationMatrix(HIE_fn_hGetSuperObjectMatrix(p_SuperObjPerso),&p_stI,&p_stJ,&p_stK);
   xCos=MTH3D_M_xGetXofVector(&p_stI);
   xSin=MTH3D_M_xGetYofVector(&p_stI);
 
   if(xCos!=0)
   {
      xAngle=MTH_M_xATan(GLI_M_Div(xSin,xCos));
      if(xCos<0)
         xAngle=MTH_M_xAdd(xAngle,MTH_C_Pi);
      if(xAngle<0)
         xAngle=MTH_M_xAdd(xAngle,MTH_C_2Pi);
      else if(xAngle>=MTH_C_2Pi)
         xAngle=MTH_M_xSub(xAngle,MTH_C_2Pi);
   }
   else
   {
      if(xSin>=0)
         xAngle=(MTH_tdxReal)MTH_C_PiBy2;
      else
         xAngle=MTH_M_xNeg(MTH_C_PiBy2);
   }
   return (xAngle);
}
 
/* Provisoire...*/
#undef extern
 
/*-----------------------------------------------------------------------------
 *  Description :   Function to update matrix attached to light...
 *-----------------------------------------------------------------------------
 *  Input :         None
 *  Output :
 *-----------------------------------------------------------------------------
 *  Creation date : 17/02/97            Author : Michael
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
void fn_vUpdateLight(HIE_tdxHandleToSuperObject hSupObject)
{
	if ((M_GetEngineObject(hSupObject)->h_MSLight)&&(fn_ucMSLightGetOnOff(M_GetEngineObject(hSupObject)->h_MSLight)))
	{
	  POS_tdstCompletePosition *p_stMatrix,stMatrix2,stMatrix3;
	  POS_tdstCompletePosition stMatrixD;	/* MR2003*/
	  MTH3D_tdstVector stDirection;	/* MR2003*/
	  MTH3D_tdstVector stTransVect,stOffsetVect;
	  static MTH_tdxReal x=0,y=0,z=0;
/*XB980504*/
/*	  MTH_tdxReal dx=MTH_M_xDoubleToReal(0.2);*/
/*End XB*/
	  static MTH_tdxReal step=MTH_M_xDoubleToReal(0.2);
	  GLI_tdxValue xAnglePerso;
 
		 xAnglePerso=fn_xComputeAngleOfPerso(hSupObject);
		 p_stMatrix=HIE_fn_hGetSuperObjectGlobalMatrix(hSupObject);
		 GEO_M_vCopyMatrix(&stMatrix2,p_stMatrix);
 
		 /* ------------------------------------*/
		 /* Light follows its attached character*/
		 /* ------------------------------------*/
		 /*if (HIE_fn_ulGetSuperObjectType(HIE_fn_hGetSuperObjectFirstChild(hSupObject))!=C_ucLight)*/
		 {
			 memcpy(&stOffsetVect,fn_p_stMSLightGetOffset(M_GetEngineObject(hSupObject)->h_MSLight),sizeof(MTH3D_tdstVector));
 
			 POS_fn_vSetIdentityMatrix(&stMatrix3);
			 POS_fn_vSetTranslationVector(&stMatrix3,&stOffsetVect);
			 fn_vTurnMatrixZ(&stMatrix3,xAnglePerso);
			 POS_fn_vGetTranslationVector(&stMatrix3,&stOffsetVect);
 
			 POS_fn_vGetTranslationVector(p_stMatrix,&stTransVect);
			 MTH3D_M_vAddVector(&stTransVect,&stTransVect,&stOffsetVect);	/* TransVect = Position de la lumière*/
 
			 fn_vMSLightGetDirection(M_GetEngineObject(hSupObject)->h_MSLight,&x,&y,&z);
			 fn_vTurnMatrixZ(&stMatrix2,z);
			 /* MR2602*/
			 fn_vTurnMatrixX(&stMatrix2,x);
			 if (y)
			 fn_vTurnMatrixY(&stMatrix2,y);		/* Matrice de rotation de Matrix2 = Orientation de la lumière (-ox)*/
 
			 POS_fn_vSetTranslationVector( &stMatrix2,&stTransVect);
 
 
			 /* MR2003*/
			 if (g_bShowLight)
			 {
				 MTH3D_M_vSetVectorElements(&stDirection,-1,0,0);
				 /*MTH3D_M_vSetVectorElements(&stDirection,fn_xMSLightGetOffsetX(M_GetEngineObject(hSupObject)->h_MSLight)-0.1,fn_xMSLightGetOffsetY(M_GetEngineObject(hSupObject)->h_MSLight),fn_xMSLightGetOffsetZ(M_GetEngineObject(hSupObject)->h_MSLight));*/
				 /*//MTH3D_M_vSetVectorElements(&stDirection,MTH3D_M_xGetXofVector(&stOffsetVect)-0.1,MTH3D_M_xGetYofVector(&stOffsetVect),MTH3D_M_xGetZofVector(&stOffsetVect));*/
				 /*GLI_vMulMatrixVertexMTH3D2GLI(&stDirection,&p_stMatrix2,&stDirection);*/
				 /*The function above is declared but not implemented so...*/
				 POS_fn_vSetIdentityMatrix(&stMatrixD);
				 POS_fn_vSetTranslationVector(&stMatrixD,&stDirection);
				 /*fn_vTurnMatrixZ(&stMatrixD,xAnglePerso);*/
				 fn_vTurnMatrixX(&stMatrixD,x);
				 fn_vTurnMatrixY(&stMatrixD,y);
				 fn_vTurnMatrixZ(&stMatrixD,z);
			 }
			 /* End2003*/
		 }
 
		 /* -----------------------------------*/
		 /* For HotSpots: Rotation around Z-axe*/
		 /* -----------------------------------*/
		 if (fn_bMSLightGetGiroPhare(M_GetEngineObject(hSupObject)->h_MSLight))
		 {
			y=fn_xMSLightGetGiroAngle(M_GetEngineObject(hSupObject)->h_MSLight);
			fn_vTurnMatrixZ(&stMatrix2,y);
 
			/* MR2003*/
			if (g_bShowLight)
				fn_vTurnMatrixZ(&stMatrixD,y);
 
			/* MR2702*/
			POS_fn_vSetTranslationVector( &stMatrix2,&stTransVect);
			/*fn_vTurnMatrixX(&p_stMatrix2,y);*/
			/*y+=MTH_C_PiBy8;*/
			y+=fn_xMSLightGetGiroStep(M_GetEngineObject(hSupObject)->h_MSLight);
			if (y>MTH_C_2Pi)
			{
				y=0;
			}
			fn_vMSLightSetGiroAngle(M_GetEngineObject(hSupObject)->h_MSLight,y);
		 }
 
		 /* --------------------------------------*/
		 /* For HotSpots & Spherical: Change radius*/
		 /* --------------------------------------*/
		 if (fn_bMSLightGetPulse(M_GetEngineObject(hSupObject)->h_MSLight))
		 {
			 /*x=fn_xMSLightGetNear(M_GetEngineObject(hSupObject)->h_MSLight);*/
			 x=fn_xMSLightGetFar(M_GetEngineObject(hSupObject)->h_MSLight);
			 /*x+=step;
			 if ((x>12)||(x<0))
			 {	step=-step;
				x+=2*step;
			 }*/
			 step=fn_xMSLightGetPulseStep(M_GetEngineObject(hSupObject)->h_MSLight);
			 x+=step;
			 if ((x>fn_xMSLightGetPulseMaxRange(M_GetEngineObject(hSupObject)->h_MSLight))||(x<0))
			 {	step=-step;
				x+=2*step;
			 }
			 fn_xMSLightSetPulseStep(M_GetEngineObject(hSupObject)->h_MSLight,step);
			 /*GLI_vSetLightNearFar(fn_p_stMSLightGetLight(M_GetEngineObject(hSupObject)->h_MSLight),x,x+dx);*/
			 GLI_vSetLightNearFar(fn_p_stMSLightGetLight(M_GetEngineObject(hSupObject)->h_MSLight),0,x);
		 }
 
		 /*POS_fn_vInvertIsoMatrix(&p_stMatrix2,&p_stMatrix2);	// MR1202 (temporarily in comment for Pentium version)*/
		 /*POS_fn_vNormalizeMatrix(&p_stMatrix2);*/
		 GLI_xSetLightMatrix ( fn_p_stMSLightGetLight(M_GetEngineObject(hSupObject)->h_MSLight) , &stMatrix2);
 
		/* MR1803*/
		if (g_bShowLight)
		{
			POS_fn_vGetTranslationVector(&stMatrixD,&stDirection);
			/*MTH3D_M_vAddVector(&stDirection,&stDirection,&stOffsetVect);*/
			MTH3D_M_vAddVector(&stDirection,&stDirection,fn_p_stMSLightGetOffset(M_GetEngineObject(hSupObject)->h_MSLight));
			GEO_vSetPointOfObject(M_GetEngineObject(hSupObject)->h_MSLight->p_stVisuLight,&stDirection,1);
			GLI_xSendObjectToViewport(&g_stEngineStructure.stViewportAttr,M_GetEngineObject(hSupObject)->h_MSLight->p_stVisuLight,gp_stLight,GLI_C_lAllIsEnable-GLI_C_lIsNotDrawCollideInformation);
		}
	}
}
 
/*-----------------------------------------------------------------------------
 *  Description :   Create a sphere object (for light visualisation)
 *-----------------------------------------------------------------------------
 *  Input :         None
 *  Output :
 *-----------------------------------------------------------------------------
 *  Creation date : 18/03/97            Author : Michael
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
GEO_tdstGeometricObject *fn_pCreateSphere(MTH_tdxReal x,MTH_tdxReal y,MTH_tdxReal z,MTH_tdxReal xRadius)
{ 
	GEO_tdstGeometricObject		*p_stSphere;
	MTH3D_tdstVector			stCenter;
	ACP_tdxHandleOfElement		hElement;
	ACP_tdxHandleOfMaterial		hMaterial;
/* Oliv' - Portage v15*/
#ifndef CONST_VMT
	GEO_tdstColor				stColor;
#endif
	GMT_tdxHandleToGameMaterial hGameMaterial;
 
	/*
	 * Create object
	 */
	GEO_vCreateGeometricObject(&p_stSphere,1,1);
	MTH3D_M_vSetVectorElements(&stCenter,x,y,z);
	GEO_vSetPointOfObject(p_stSphere,&stCenter,0);
 
	/* 
	 * create sphere element
	 */
	GEO_vCreateElementSpheres(p_stSphere,&hElement,1);
	GEO_vSetCenterPointOfIndexedSphere(p_stSphere,hElement,0,0);
	GEO_vSetRadiusOfIndexedSphere(p_stSphere,hElement,0,xRadius);
	
	/*
	 * create game material
	 */
	hGameMaterial = GMT_fn_hCreateGameMaterial();
	GLI_xCreateMaterial(&hMaterial);
	GMT_fn_vSetVisualMaterial(hGameMaterial, hMaterial);
 
#ifndef CONST_VMT
	stColor.xR=(GEO_tdxColorValue)0.100000;
	stColor.xG=(GEO_tdxColorValue)0.100000;
	stColor.xB=(GEO_tdxColorValue)0.100000;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialAmbientCoef(hMaterial,&stColor);
	
	stColor.xR=(GEO_tdxColorValue)0.700000;
	stColor.xG=(GEO_tdxColorValue)0.700000;
	stColor.xB=(GEO_tdxColorValue)0.700000;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialDiffuseCoef(hMaterial,&stColor);
 
	
	stColor.xR=(GEO_tdxColorValue)0.7;
	stColor.xG=(GEO_tdxColorValue)0.7;
	stColor.xB=(GEO_tdxColorValue)0.7;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialSpecularCoef(hMaterial,0,&stColor);
	
	stColor.xR=(GEO_tdxColorValue)0.8;
	stColor.xG=(GEO_tdxColorValue)0.8;
	stColor.xB=(GEO_tdxColorValue)0.8;
	stColor.xA=(GEO_tdxColorValue)-4e+8;
	GLI_xSetMaterialColor(hMaterial,&stColor);
#endif	/* Oliv' - Portage v15 - Please, this SHOULD BE HERE AND NOT ABOVE (since v14 at least)*/
	
	GLI_xSetMaterialType(hMaterial,2042);
 
	GEO_vSetGameMaterialOfIndexedSphere (p_stSphere,hElement,0,hGameMaterial);
	GEO_vSetMaterialOfIndexedSphere (p_stSphere,hElement,0,hMaterial);
	GEO_vEndModifyObject(p_stSphere);
 
	return p_stSphere;
}
 
/*-----------------------------------------------------------------------------
 *  Description :   Create a cone object (for light visualisation)
 *-----------------------------------------------------------------------------
 *  Input :         None
 *  Output :
 *-----------------------------------------------------------------------------
 *  Creation date : 19/03/97            Author : Michael
 *-----------------------------------------------------------------------------
 *  Modification date :                 Modification Author :
 *  Modifications :
 *---------------------------------------------------------------------------*/
GEO_tdstGeometricObject *fn_pCreateCone(MTH_tdxReal xS,MTH_tdxReal yS,MTH_tdxReal zS, MTH_tdxReal xRadius)
{ 
	GEO_tdstGeometricObject		*p_stSphere;
	MTH3D_tdstVector			stCenter;
	ACP_tdxHandleOfElement		hElement;
	ACP_tdxHandleOfMaterial		hMaterial;
/* Oliv' - Portage v15*/
#ifndef CONST_VMT
	GEO_tdstColor				stColor;
#endif
	GMT_tdxHandleToGameMaterial hGameMaterial;
 
	GEO_vCreateGeometricObject(&p_stSphere,2,1);
	MTH3D_M_vSetVectorElements(&stCenter,xS,yS,zS);
	GEO_vSetPointOfObject(p_stSphere,&stCenter,0);
	MTH3D_M_vSetVectorElements(&stCenter,xS-MTH_M_xDoubleToReal(0.1),yS,zS);
	
	GEO_vSetPointOfObject(p_stSphere,&stCenter,1);
 
	GEO_vCreateElementCones(p_stSphere,&hElement,1);
	GEO_vSetPointsOfIndexedCone(p_stSphere,hElement,0,1,0);
	GEO_vSetRadiusOfIndexedCone(p_stSphere,hElement,0,xRadius);
	hGameMaterial=GMT_fn_hCreateGameMaterial(); /*AR270397*/
	GLI_xCreateMaterial(&hMaterial);
	GMT_fn_vSetVisualMaterial(hGameMaterial,hMaterial); /*AR270397*/
	
#ifndef CONST_VMT 	
	stColor.xR=(GEO_tdxColorValue)0;
	stColor.xG=(GEO_tdxColorValue)0;
	stColor.xB=(GEO_tdxColorValue)0;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialAmbientCoef(hMaterial,&stColor);
	
	stColor.xR=(GEO_tdxColorValue)0;
	stColor.xG=(GEO_tdxColorValue)0;
	stColor.xB=(GEO_tdxColorValue)0;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialDiffuseCoef(hMaterial,&stColor);
 
	
	stColor.xR=(GEO_tdxColorValue)0;
	stColor.xG=(GEO_tdxColorValue)0;
	stColor.xB=(GEO_tdxColorValue)0;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialSpecularCoef(hMaterial,0,&stColor);
	
	stColor.xR=(GEO_tdxColorValue)0;
	stColor.xG=(GEO_tdxColorValue)0;
	stColor.xB=(GEO_tdxColorValue)0;
	stColor.xA=(GEO_tdxColorValue)0;
	GLI_xSetMaterialColor(hMaterial,&stColor);
#endif	/* Oliv' - Portage v15 - Please, this SHOULD BE HERE AND NOT ABOVE (since v14 at least)*/
	GLI_xSetMaterialType(hMaterial,2042);
 
	GEO_vSetGameMaterialOfIndexedCone(p_stSphere,hElement,0,hGameMaterial); /*AR270397*/
	GEO_vSetMaterialOfIndexedCone (p_stSphere,hElement,0,hMaterial);
 
	GEO_vEndModifyObject(p_stSphere);
 
	return p_stSphere;
}
 
#endif	/* __3DOSLIGHTS */
 
 
/* ##F===================================================================================
NAME :          fn_ucGetNumberOfRLI
DESCRIPTION :   return the blend RLI parameters of the character.
INPUT : hMSLight = mini-structure 
        ucIndex1 = index of the first RLI table
        ucIndex1 = index of the second RLI table
				xPercent = percentage of the blend
OUTPUT : Return the number of table to use. 
				 0 -> don't use RLI
				 1 -> use only one RLI table (ucIndex1)
				 2 -> makea blend between two table of RLI
=========================================================================================
LAST MODIFICATIONS : 17/02/98 Jean-Marc Drouaud
=======================================================================================*/
unsigned char fn_ucGetNumberOfRLI (MS_tdxHandleToMSLight hMSLight, 
														       unsigned char *ucIndex1, 
													         unsigned char *ucIndex2, 
																	 MTH_tdxReal *xPercent ) {
	if ( hMSLight ) {
		*ucIndex1 = hMSLight->ucFirstRLI ;
		*ucIndex2 = hMSLight->ucSecondRLI ;
		*xPercent = MTH_M_xDivHigh(MTH_M_xLongToReal(hMSLight->ucBlendPercent), MTH_M_xLongToReal(100)) ;
		return (hMSLight->ucNbRLIUse) ;
	}
	return (0) ;
}
 
/* ##F===================================================================================
NAME :          fn_ucGetNumberOfRLIFromCharacter
DESCRIPTION :   return the blend RLI parameters of the character. 
								Look for a charactere in the SPO ancestor
INPUT : hSprObj  = super object.
        ucIndex1 = index of the first RLI table
        ucIndex1 = index of the second RLI table
				xPercent = percentage of the blend
OUTPUT : Return the number of table to use. 
				 0 -> don't use RLI
				 1 -> use only one RLI table (ucIndex1)
				 2 -> makea blend between two table of RLI
=========================================================================================
LAST MODIFICATIONS : 17/02/98 Jean-Marc Drouaud
=======================================================================================*/
unsigned char fn_ucGetNumberOfRLIFromCharacter (HIE_tdxHandleToSuperObject hSprObj, unsigned char *p_ucIndex1, unsigned char *p_ucIndex2, MTH_tdxReal *p_xPercent) {
	unsigned char ucNbRLIUse=0 ;
 
	if ( HIE_fn_ulGetSuperObjectType(hSprObj) == HIE_C_ulActor ) {
		ucNbRLIUse = fn_ucGetNumberOfRLI (M_GetMSHandle(hSprObj, MSLight), p_ucIndex1, p_ucIndex2, p_xPercent) ;
	}
	return (ucNbRLIUse) ;
 
}
/* ##F===================================================================================
NAME :          fn_vMSLightSetRLIParameter
DESCRIPTION :   update the mini-structure parameters.
INPUT : hMSLight = mini-structure 
				lNbRLI   = number of table to use
        lIndex1  = index of the first RLI table
        lIndex1  = index of the second RLI table
				lPercent = percentage of the blend
=========================================================================================
LAST MODIFICATIONS : 17/02/98 Jean-Marc Drouaud
=======================================================================================*/
void  fn_vMSLightSetRLIParameter ( MS_tdxHandleToMSLight hMSLight, long lNbRLI, 
																	 long lIndex1, long lIndex2, long lPercent ) {
	if ( hMSLight ) {
		hMSLight->ucNbRLIUse     = (unsigned char)lNbRLI ;
		hMSLight->ucFirstRLI     = (unsigned char)lIndex1 ;
		hMSLight->ucSecondRLI    = (unsigned char)lIndex2 ;
		hMSLight->ucBlendPercent = (unsigned char)lPercent ;
	}
}
 
/* ##F===================================================================================
NAME :          HIE_fn_hGetSuperObjectLight
DESCRIPTION :   return the handle of the light in the MSLight when the SO is an actor
INPUT : p_SuperObjPerso = Handle of SO Actor
=========================================================================================
LAST MODIFICATIONS : 24/08/98 Marc Trabucato
=======================================================================================*/
GLI_tdstLight *HIE_fn_hGetSuperObjectLight(HIE_tdxHandleToSuperObject p_SuperObjPerso)
{
	if ( HIE_fn_ulGetSuperObjectType(p_SuperObjPerso) == HIE_C_ulActor )
	{
		MS_tdxHandleToMSLight hMSLight;
 
		hMSLight = M_GetEngineObject(p_SuperObjPerso)->h_MSLight;
 
		return ( hMSLight && fn_bMSLightGetLocalLight(hMSLight) ? fn_p_stMSLightGetLight(hMSLight) : NULL);
	}
	return NULL;
}
