/* MLT CC BEGIN 10/9/98 */
 
#include "ldt.h"
 
int ISI_LDT_LoadISI(LDT_tdst_Link * pLink)
{
	ACP_tdxIndex xIndex;
	ISI_tdstColor *d_stVertexRLI;
	char a255_cTempName[255];
	ACP_tdxHandleToRadiosity hISI;
	LDT_tdeParseResult result=ParseResult_BeginSection;
 
    if (LDT_iGetNbParams()==3)
      /*New ISI*/
      hISI=ISI_fn_hCreateISI(atol(LDT_szGetParam(2)));
    else
    {
      hISI=ISI_fn_hCreateISI(1);
      d_stVertexRLI=ISI_fn_hCreateISILOD(hISI,0,(ACP_tdxIndex)atol(LDT_szGetParam(1)));
    }
	
	pLink->pObject = hISI;
 
	LDT_ComputeSectionName( pLink, a255_cTempName);
    SCR_fnp_st_Link_SetValue( &ISI_stLinkTable, a255_cTempName, (unsigned long)hISI );
 
	while( result!=ParseResult_EndSection ) 
	{
  		result=LDT_GetNextEntry();
  		switch( result )
  		{
		case ParseResult_Entry: /* an entry */
			{
				char* szEntry=LDT_szGetEntryName();
				switch(*(long*)szEntry)
				{
				case 'LddA': /* "AddLODRLI" */
				    d_stVertexRLI=ISI_fn_hCreateISILOD(hISI,(ACP_tdxIndex)atoi(LDT_szGetParam(1)),(ACP_tdxIndex)atoi(LDT_szGetParam(2)));
					break;
				default:
					xIndex = (ACP_tdxIndex)atoi(LDT_szGetParam(1));
					if(strlen(szEntry) > 12) /*"AddVertexRLILOD"*/
					{
						d_stVertexRLI[xIndex].xRed=(ISI_tdxColorComp)(atoi(LDT_szGetParam(2)));
						d_stVertexRLI[xIndex].xGreen=(ISI_tdxColorComp)(atoi(LDT_szGetParam(3)));
						d_stVertexRLI[xIndex].xBlue=(ISI_tdxColorComp)(atoi(LDT_szGetParam(4)));
						if(LDT_iGetNbParams() == 6)
						d_stVertexRLI[xIndex].xAlpha=(ISI_tdxColorComp)(atoi(LDT_szGetParam(5)));
					}
					else
					{
						d_stVertexRLI[xIndex].xRed=(ISI_tdxColorComp)(atof(LDT_szGetParam(2)) * 255.f);
						d_stVertexRLI[xIndex].xGreen=(ISI_tdxColorComp)(atof(LDT_szGetParam(3)) * 255.f);
						d_stVertexRLI[xIndex].xBlue=(ISI_tdxColorComp)(atof(LDT_szGetParam(4)) * 255.f);
						if(LDT_iGetNbParams() == 6)
						d_stVertexRLI[xIndex].xAlpha=(ISI_tdxColorComp)(atof(LDT_szGetParam(5)) * 255.f);
					}
				}
			}
		}
	}
	return 0;
}
/* MLT CC END   10/9/98 */
