/*
///////////////////////////////////////////////////////////////////////////////////////////////////
// Description : EdLight.c
//
// Engine structure for light
//
///////////////////////////////////////////////////////////////////////////////////////////////////
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
// Creation date: 11 feb 1997                        Author: J Thénoz
///////////////////////////////////////////////////////////////////////////////////////////////////
// Modification date:			                      Author:
//
//
//
//
///////////////////////////////////////////////////////////////////////////////////////////////////
*/

#include "acp_base.h"
#include "EdLight.h"
#include "geo.h"
#include "gli.h"

static long lType;

//-------------------------------- Light
// construction, destruction, copy
GLI_tdxHandleToLight fn_hConstructLight (void)
{
	GLI_tdxHandleToLight hLight;
//CHINA WFQ (MT) 16/02/98 {
	MTH3D_tdstVector xTemp;
//ENDCHINA WFQ }
	GLI_xCreateLight ( &hLight, lType ) ;

    GLI_xSetLightState ( hLight, TRUE ) ;
	GLI_vSetLightNearFar ( hLight, (float)0.50, (float)1. );
	GLI_vSetLightAlphas ( hLight, (float)30.f/180.f*MTH_C_Pi, (float)45.f/180.f*MTH_C_Pi );
//CHINA WFQ (MT) 16/02/98 {
	xTemp.xX = xTemp.xY = xTemp.xZ = (float)0;
	GLI_vSetLight_Inter_Min_Pos(hLight, xTemp);
	GLI_vSetLight_Exter_Min_Pos(hLight, xTemp);
	xTemp.xX = xTemp.xY = xTemp.xZ = (float)0.5;
	GLI_vSetLight_Inter_Max_Pos(hLight, xTemp);
	xTemp.xX = xTemp.xY = xTemp.xZ = (float)1.0;
	GLI_vSetLight_Exter_Max_Pos(hLight, xTemp);
	GLI_vSetLight_Intensity_Min_Max(hLight, (float)0, (float)0.5);
//ENDCHINA WFQ }
	return hLight;
}


void fn_vDestroyLight (GLI_tdxHandleToLight hLight)
{
	// C'est pas suffisant
	hLight=NULL;
}

void fn_vCopyLight ( GLI_tdxHandleToLight hLightDest, GLI_tdxHandleToLight hLightSrc )
{
	long lState;
//ROMTEAM  Near/far Ionut Grozea 14-08-1998
	MTH_tdxReal xLittleAlpha, xBigAlpha;
//ROMTEAM  Near/far Ionut Grozea 14-08-1998
	MTH_tdxReal xNear,xFar;
	GEO_tdstColor stColor;
	POS_tdstCompletePosition stMatrix;
//CHINA WFQ (MT) 16/02/98 {
	MTH3D_tdstVector xTemp;
//ENDCHINA WFQ }
	POS_fn_vSetIdentityMatrix(&stMatrix);

	GLI_xGetLightState ( hLightSrc, &lState );
	GLI_xSetLightState ( hLightDest, lState );

//ROMTEAM  Near/far Ionut Grozea 14-08-1998
	GLI_vGetLightAlphas ( hLightSrc , &xLittleAlpha, &xBigAlpha );
	GLI_vSetLightAlphas ( hLightDest , xLittleAlpha, xBigAlpha );
	GLI_vGetLightNearFar ( hLightSrc, &xNear, &xFar );
//ROMTEAM  Near/far Ionut Grozea 14-08-1998
	GLI_vSetLightNearFar ( hLightDest, xNear, xFar );

	GLI_xGetLightColor ( hLightSrc, &stColor);
	GLI_xSetLightColor ( hLightDest, &stColor);

	GLI_xGetLightMatrix ( hLightSrc, &stMatrix ) ;
	GLI_xSetLightMatrix ( hLightDest, &stMatrix ) ;

//CHINA WFQ (MT) 16/02/98 {
	GLI_vGetLight_Intensity_Min_Max ( hLightSrc, &xNear, &xFar);
	GLI_vSetLight_Intensity_Min_Max ( hLightDest, xNear, xFar );

	GLI_vGetLight_Inter_Min_Pos(hLightSrc, &xTemp);
	GLI_vSetLight_Inter_Min_Pos(hLightDest, xTemp);

	GLI_vGetLight_Exter_Min_Pos(hLightSrc, &xTemp);
	GLI_vSetLight_Exter_Min_Pos(hLightDest, xTemp);

	GLI_vGetLight_Inter_Max_Pos(hLightSrc, &xTemp);
	GLI_vSetLight_Inter_Max_Pos(hLightDest, xTemp);

	GLI_vGetLight_Exter_Max_Pos(hLightSrc, &xTemp);
	GLI_vSetLight_Exter_Max_Pos(hLightDest, xTemp);
//}C WFQ
    GLI_vSetLightType (hLightDest ,GLI_lGetLightType(hLightSrc) );
}

//------------- Type
void fn_vSetTypeLight (long lType_)
{
	lType=lType_;
}

long fn_lGetTypeLight (void)
{
	return lType;
}
