/* ISI_Func.c*/ /* ##-########################### ## Saving / Loading ############################## */ /* ##F=================================================================================== NAME : ISI_fn_pGetLinkTable DESCRIPTION : Function to get the link table. OUTPUT : Link table. ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ SCR_tdst_Link_Table *ISI_fn_pGetLinkTable(void) { return &ISI_stLinkTable; } /* ##F=================================================================================== NAME : ISI_fn_vDisinitLinkTable DESCRIPTION : Function to disinit the link table. ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ void ISI_fn_vDisinitLinkTable(void) { SCR_fn_v_Link_CloseTable(&ISI_stLinkTable); } /* ##F=================================================================================== NAME : ISI_fn_xLoadISI DESCRIPTION : Load the ISI of an IPO. (Script callback) INPUT : p_fFile = script file description. szAction = action name. szParams = table of param. cType = type of action. OUTPUT : script error code. ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ SCR_tde_Anl_ReturnValue ISI_fn_xLoadISI(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType) { ACP_tdxHandleToRadiosity hISI; ACP_tdxIndex xIndex; char a255_cTempName[255]; static ISI_tdstColor *d_stVertexRLI; switch (cType) { case SCR_EA_Anl_BeginSection: if (SCR_fn_uc_RdL0_GetNumberOfParameters(szParams)==2) { /*New ISI*/ hISI=ISI_fn_hCreateISI((ACP_tdxIndex)(atol(szParams[1]))); } else { hISI=ISI_fn_hCreateISI(1); d_stVertexRLI=ISI_fn_hCreateISILOD(hISI,0,(ACP_tdxIndex)atol(szParams[0])); } SCR_M_RdL0_SetSectionLong(0,0,(long)hISI); SCR_M_RdL0_SetContextLong(0,0,(long)hISI); /*Get Path*/ strcpy(a255_cTempName,fn_szGetLevelsDataPath()); strcat(a255_cTempName,"\\"); strcat(a255_cTempName,SCR_M_RdL0_GetCompleteSectionNameR(0)); SCR_fnp_st_Link_SetValue( &ISI_stLinkTable, a255_cTempName, (unsigned long)hISI ); break; case SCR_EA_Anl_Entry: SCR_M_RdL0_GetContextLong(0,0,void *, hISI); /* New LOD*/ if (strcmp(szAction,"AddLODRLI")==0) { d_stVertexRLI=ISI_fn_hCreateISILOD(hISI,(ACP_tdxIndex)atoi(szParams[0]),(ACP_tdxIndex)atoi(szParams[1])); } /* Loading of object's vertex*/ if (strcmp(szAction,"AddVertexRLILOD")==0) { xIndex = (ACP_tdxIndex)atoi(szParams[0]); d_stVertexRLI[xIndex].xRed=(ISI_tdxColorComp)(atoi(szParams[1])); d_stVertexRLI[xIndex].xGreen=(ISI_tdxColorComp)(atoi(szParams[2])); d_stVertexRLI[xIndex].xBlue=(ISI_tdxColorComp)(atoi(szParams[3])); if(SCR_fn_uc_RdL0_GetNumberOfParameters(szParams) == 5) d_stVertexRLI[xIndex].xAlpha=(ISI_tdxColorComp)(atoi(szParams[4])); } /* Loading of object's vertex*/ if (strcmp(szAction,"AddVertexRLI")==0) { xIndex = (ACP_tdxIndex)atoi(szParams[0]); d_stVertexRLI[xIndex].xRed=(ISI_tdxColorComp)(atof(szParams[1]) * 255.f); d_stVertexRLI[xIndex].xGreen=(ISI_tdxColorComp)(atof(szParams[2]) * 255.f); d_stVertexRLI[xIndex].xBlue=(ISI_tdxColorComp)(atof(szParams[3]) * 255.f); if(SCR_fn_uc_RdL0_GetNumberOfParameters(szParams) == 5) d_stVertexRLI[xIndex].xAlpha=(ISI_tdxColorComp)(atof(szParams[4]) * 255.f); } case SCR_EA_Anl_EndSection: break; } return SCR_ERV_Anl_NormalReturn; } /* ##F=================================================================================== NAME : ISI_vSaveVertexISI DESCRIPTION : Save an ISI of an IPO. (Script callback) INPUT : _p_stFile = script file description. _sFileName = file name. _p_vPtr = struct adress. _xAction = type of action ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ void ISI_vSaveVertexISI(SCR_tdst_File_Description *_p_stFile, char *_sFileName, void *_p_vPtr, SCR_tde_Ntfy_Action _xAction) { ACP_tdxIndex xI,xNumISILOD,xNbVertexRLI; ISI_HandleToISI hCpyISI; char sFile[255]; char sSection[255]; char sIdent[255]; char sBeginSection[255]; ISI_tdstColor *d_stVertexRLI; hCpyISI=(ISI_HandleToISI)_p_vPtr; if(_xAction == SCR_EA_Ntfy_AddSection) { SCR_fn_v_SvL1_ToEndSection(_p_stFile); } else { SCR_fn_v_SvL1_DeleteSection(_p_stFile); } SCR_fn_v_RdL0_SplitSectionName(_sFileName, sFile, sSection, sIdent); sprintf(sBeginSection,"%s:%s", sSection, sIdent); /*BeginSection*/ SCR_M_SvL0_SaveBeginSection(_p_stFile, sBeginSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(_p_stFile, SCR_EF_SvL0_Scanf, 2,"%s,%d", "NBRLOD",hCpyISI->xNbISILOD); /* For all LOD.*/ for(xNumISILOD=0;xNumISILODxNbISILOD;xNumISILOD++) { xNbVertexRLI=hCpyISI->d_stISILOD[xNumISILOD].xNbVertexRLI; d_stVertexRLI=hCpyISI->d_stISILOD[xNumISILOD].d_stVertexRLI; SCR_M_SvL0_SaveEntry(_p_stFile, "AddLODRLI", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(_p_stFile,SCR_EF_SvL0_Scanf,3,"%d,%d",xNumISILOD,xNbVertexRLI); /* For all RLI of the LOD.*/ for(xI=0;xId_stISILOD,sizeof(ISI_tdstISILOD)*hISI->xNbISILOD); // For all LOD. for(xNumISILOD=0;xNumISILODxNbISILOD;xNumISILOD++) { xNbVertexRLI=hISI->d_stISILOD[xNumISILOD].xNbVertexRLI; d_stVertexRLI=hISI->d_stISILOD[xNumISILOD].d_stVertexRLI; p_cBufferPointer=BIN_fn_p_cPutStruct(p_cBufferPointer,(char*)d_stVertexRLI,sizeof(ISI_tdstColor)*xNbVertexRLI); } return p_cBufferPointer-_p_cDestBuffer; } */ /* ##F=================================================================================== NAME : ISI_fn_vWriteAllISIBinaryBlocs DESCRIPTION : Write all the binary blocs for the ISI INPUT : _szBinaryFileName = Name of the binary file. ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ /* void ISI_fn_vWriteAllISIBinaryBlocs(char* _szBinaryFileName) { ISI_fn_vPrepareSaveBinaryBloc(); BIN_fn_vPutBinaryDataIntoFileFromLinkTable( (char*)_szBinaryFileName, ISI_fn_pGetLinkTable(), ISI_C_BUFFER_SIZE, ISI_fn_ulWriteBinaryBloc); } */ /* ##F=================================================================================== NAME : ISI_fn_ulReadISIBinaryBloc DESCRIPTION : Read the binary bloc for ISI. INPUT : _p_cLoadedBuffer = pointer to the loaded buffer. _ulLoadedBufferSize = Size of the loaded buffer. OUTPUT : The pointer to the allocated element. ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ /* void ISI_fn_ulReadISIBinaryBloc(unsigned long _ulLoadedBuffer) { ISI_HandleToISI hISI=(ISI_HandleToISI)_ulLoadedBuffer; ISI_tdstColor *d_stVertexRLI; ACP_tdxIndex xNumISILOD; hISI->d_stISILOD=(ISI_tdstISILOD *)(hISI+1); d_stVertexRLI=(ISI_tdstColor *)(hISI->d_stISILOD+hISI->xNbISILOD); // For all LOD. for(xNumISILOD=0;xNumISILODxNbISILOD;xNumISILOD++) { hISI->d_stISILOD[xNumISILOD].d_stVertexRLI=d_stVertexRLI; d_stVertexRLI+=hISI->d_stISILOD[xNumISILOD].xNbVertexRLI; } } */ /* ##F=================================================================================== NAME : ISI_fn_vReadAllISIBinaryBlocs DESCRIPTION : Read all the binary blocs for the ISI. INPUT : _szBinaryFile = Name of the binary file. ========================================================================================= LAST MODIFICATIONS : 20/11/97 David Fournier : New commentary form. =======================================================================================*/ /* void ISI_fn_vReadAllISIBinaryBlocs(char* _szBinaryFile) { BIN_fn_vReadDataFromLinkTableWithoutAllocation(ISI_fn_pGetLinkTable(), ISI_fn_ulReadISIBinaryBloc, ISI_C_BUFFER_SIZE,_szBinaryFile, ISI_fn_p_cGenericAllocateFunction); } */ /*ANNECY JMD 17/02/98{*/ /* ##F=================================================================================== NAME : ISI_fn_xLoadISI2 DESCRIPTION : Load the ISI of an PO. (Script callback) INPUT : p_fFile = script file description. szAction = action name. szParams = table of param. cType = type of action. OUTPUT : script error code. ========================================================================================= LAST MODIFICATIONS : 13/02/98 Jean-Marc Drouaud =======================================================================================*/ SCR_tde_Anl_ReturnValue ISI_fn_xLoadISI2(SCR_tdst_File_Description *p_fFile, char *szAction, char *szParams[], SCR_tde_Anl_Action cType) { ACP_tdxHandleToRadiosity hISI; ACP_tdxHandleToRadiosity *d_hRLI ; ACP_tdxIndex xIndex; static ISI_tdstColor *d_stVertexRLI; switch (cType) { case SCR_EA_Anl_BeginSection: SCR_M_RdL0_GetContextLong(-1,0,ACP_tdxHandleToRadiosity *, d_hRLI); if (SCR_fn_uc_RdL0_GetNumberOfParameters(szParams)==2) { /*New ISI*/ hISI=ISI_fn_hCreateISI((ACP_tdxIndex)atol(szParams[1])); } else { hISI=ISI_fn_hCreateISI(1); d_stVertexRLI=ISI_fn_hCreateISILOD(hISI,0,(ACP_tdxIndex)atol(szParams[0])); } *(d_hRLI++) = hISI ; SCR_M_RdL0_SetContextLong(-1,0,(long)d_hRLI); SCR_M_RdL0_SetSectionLong(0,0,(long)hISI); SCR_M_RdL0_SetContextLong(0,0,(long)hISI); break; case SCR_EA_Anl_Entry: SCR_M_RdL0_GetContextLong(0,0,void *, hISI); /* New LOD*/ if (strcmp(szAction,"AddLODRLI")==0) { d_stVertexRLI=ISI_fn_hCreateISILOD(hISI,(ACP_tdxIndex)atoi(szParams[0]),(ACP_tdxIndex)atoi(szParams[1])); } /* Loading of object's vertex*/ if (strcmp(szAction,"AddVertexRLILOD")==0) { xIndex = (ACP_tdxIndex)atoi(szParams[0]); d_stVertexRLI[xIndex].xRed=(ISI_tdxColorComp)(atoi(szParams[1])); d_stVertexRLI[xIndex].xGreen=(ISI_tdxColorComp)(atoi(szParams[2])); d_stVertexRLI[xIndex].xBlue=(ISI_tdxColorComp)(atoi(szParams[3])); if(SCR_fn_uc_RdL0_GetNumberOfParameters(szParams) == 5) d_stVertexRLI[xIndex].xAlpha=(ISI_tdxColorComp)(atoi(szParams[4])); } /* Loading of object's vertex*/ if (strcmp(szAction,"AddVertexRLI")==0) { xIndex = (ACP_tdxIndex)atoi(szParams[0]); d_stVertexRLI[xIndex].xRed=(ISI_tdxColorComp)(atof(szParams[1]) * 255.f); d_stVertexRLI[xIndex].xGreen=(ISI_tdxColorComp)(atof(szParams[2]) * 255.f); d_stVertexRLI[xIndex].xBlue=(ISI_tdxColorComp)(atof(szParams[3]) * 255.f); if(SCR_fn_uc_RdL0_GetNumberOfParameters(szParams) == 5) d_stVertexRLI[xIndex].xAlpha=(ISI_tdxColorComp)(atof(szParams[4]) * 255.f); } case SCR_EA_Anl_EndSection: break; } return SCR_ERV_Anl_NormalReturn; }