reman3/Rayman_X/cpa/tempgrp/PO/Specif/vsloadCB.c

163 lines
4.6 KiB
C
Raw Blame History

/*****************
loadCB.c
Ver 1.0
LDT version of
visual set loading
*****************/
#include "ldt.h"
/*****************************************************************
Name:
Description: Create callback for LDT
Author: Mircea Petrescu
Date: 6/30/98
Modified:
*****************************************************************/
int VS_iCreateGeneral( LDT_tdst_Link *pLink )
{
GEO_tdxHandleToVisualSet _hVisualSet;
GEO_M_CPAMalloc(_hVisualSet ,GEO_tdstVisualSet * ,sizeof ( GEO_tdstVisualSet ) ,E_uwGEONotEnoughtMemory );
pLink->pObject=(void *)_hVisualSet;
return 0;
}
/*****************************************************************
Name:
Description: Load callback for LDT
Author: Mircea Petrescu
Date: 6/30/98
Modified:
*****************************************************************/
int VS_iLoadGeneral( LDT_tdst_Link *pLink )
{
LDT_tdeParseResult result=ParseResult_BeginSection;
GEO_tdxHandleToVisualSet _hVisualSet=( GEO_tdxHandleToVisualSet )pLink->pObject;
ACP_tdxIndex xLodCounter;
GEO_tdstVisualSet *p_stLocalVS=(GEO_tdstVisualSet *)_hVisualSet;
long lNbLOD=atol( LDT_szGetParam( 1 ) );
char sz_LongPathForLinkTable[256];
int iLen;
iLen=LDT_ComputeSectionName(pLink,sz_LongPathForLinkTable);
SCR_M_v_Link_SetAdditionalLong(SCR_fnp_st_Link_SetValue(&VS_g_stLinkTable,sz_LongPathForLinkTable,(unsigned long)p_stLocalVS),1,iLen);
GEO_M_CPAMalloc(p_stLocalVS -> d_xThresholdsTable ,MTH_tdxReal *,sizeof ( MTH_tdxReal ) * lNbLOD,E_uwGEONotEnoughtMemory );
GEO_M_CPAMalloc(p_stLocalVS -> d_p_stLodDefinitions ,GEO_tdstGeometricObject ** ,sizeof ( GEO_tdstGeometricObject * ) * lNbLOD,E_uwGEONotEnoughtMemory );
p_stLocalVS -> xNbLodDefinitions = (ACP_tdxIndex)lNbLOD;
for (xLodCounter = 0;
xLodCounter < lNbLOD;
xLodCounter ++)
{
p_stLocalVS -> d_xThresholdsTable[xLodCounter] = 0.0;
p_stLocalVS -> d_p_stLodDefinitions[xLodCounter] = NULL;
}
while( result!=ParseResult_EndSection )
{
result=LDT_GetNextEntry();
switch( result )
{
case ParseResult_BeginSection: /* a subsection */
{
LDT_SetFileLong( 8, (long)_hVisualSet );
LDT_SetFileLong( 9, (long)(atoi( LDT_szGetSectionName() )-1 ) );
LDT_SetFileDouble( 7, (double)0.0 );
LDT_LoadSection( NULL );
}
}
}
return 0;
}
/*****************************************************************
Name:
Description: Create callback for LDT
Author: Mircea Petrescu
Date: 6/30/98
Modified:
*****************************************************************/
int VS_iCreateLOD( LDT_tdst_Link *pLink )
{
return 0;
}
/*****************************************************************
Name:
Description: Load callback for LDT
Author: Mircea Petrescu
Date: 6/30/98
Modified:
*****************************************************************/
int VS_iLoadLOD( LDT_tdst_Link *pLink )
{
GEO_tdxHandleToVisualSet _hVisualSet=(GEO_tdxHandleToVisualSet)LDT_GetFileLong( 8 );
ACP_tdxHandleOfObject _hGeometricObject;
long l_NumberOfLOD=LDT_GetFileLong( 9 );
MTH_tdxReal xThreshold=(MTH_tdxReal)LDT_GetFileDouble( 7 );
LDT_tdeParseResult result=ParseResult_BeginSection;
while( result!=ParseResult_EndSection )
{
result=LDT_GetNextEntry();
switch( result )
{
case ParseResult_Entry: /* an entry */
{
char *szEntry=LDT_szGetEntryName();
switch (*(long*)(szEntry+6))
{
case 'hser' : /* LOD_Threshold */
{
xThreshold=(MTH_tdxReal)atof( LDT_szGetParam( 1 ) );
}
break;
case 'DOMr' : /* FichierMOD */
{
_hGeometricObject = GLI_pLoadGeometricInFile(LDT_szGetParam( 1 ));
GLI_vSetVisualSetLOD(_hVisualSet,l_NumberOfLOD,xThreshold,_hGeometricObject);
}
break;
case 'ILRr' : /* FichierRLI */
{
long lNumberOfTable ;
ACP_tdxHandleToRadiosity *d_hRLI ;
d_hRLI = GLI_vVisualSetLoadRLI ( LDT_szGetParam( 1 ), &lNumberOfTable ) ;
GLI_vVisualSetSetRLITable(_hVisualSet, d_hRLI, lNumberOfTable) ;
}
break;
}
}
}
}
return 0;
}
/*-----------------------------------------------------------------------------
* Description : Used to register all script callback functions
*-----------------------------------------------------------------------------
* Creation date : 05/05/97 Author : Sebastien DAVID (G<>zmo)
*-----------------------------------------------------------------------------*/
void VS_fn_vRegisterAllScriptSections(void)
{
LDT_RegisterType( C_Section_VSGeneral, VS_iCreateGeneral, VS_iLoadGeneral, LDT_REG_SECTION );
LDT_RegisterType( C_SubSection_LOD, VS_iCreateLOD, VS_iLoadLOD, LDT_REG_SECTION );
}