/***************** loadCB.c Ver 1.0 LDT version of geometric objects loading *****************/ #include "ldt.h" #define PostProcessPriority_MOD 1 HREF g_hRefGeom; enum{ iElementMaterial_AddTexture, iElementIndexedTriangles_GetFaces, iElementIndexedTriangles_GetUVs, iElementLines_GetLines, iElementLines_GetThickness, iElementPoints_GetPoints, iElementPoints_GetFatness, iElementPoints_GameMaterial, iElementPoints_EndSection, iFaceMapDescriptor_GetTripledUV, iGeometric_GetVertices, iGeometric_GetEdges, iGeometric_GetElements, iElementMaterial_Backface, iGeometric_EndSection }; void GLI_vPostProcessLDT( HREF hRef ) { LDT_tdst_Link *pObject; LDT_tdst_Link *pGetFrom; int iType; short xCount; long *pVal; while( LDT_GetRefFromTable( hRef, &pObject, &pGetFrom, &iType, &xCount, &pVal )==0 ) { switch( iType ) { case iElementMaterial_AddTexture: { ACP_tdxHandleOfMaterial hVisualMat=( ACP_tdxHandleOfMaterial )pObject->pObject; GLI_tdstTexture *p_stTexture=(GLI_tdstTexture *)pGetFrom->pObject; if( xCount==1 ) { GLI_vAddMaterialAnimatedTexture(hVisualMat, 0xffffff ,p_stTexture,MTH_M_xDoubleToFloat(*(float *)pVal)); LDT_FreeRefValues( pVal ); } else GLI_xSetMaterialTexture(hVisualMat, p_stTexture); } break; case iElementMaterial_Backface: { ACP_tdxHandleOfMaterial hVisualMat=( ACP_tdxHandleOfMaterial )pObject->pObject; long lType; if (!pVal[0]) { GLI_xGetMaterialType (hVisualMat,&lType); lType &= 0xffffffff - GLI_C_lIsTestingBackface; GLI_xSetMaterialType (hVisualMat,lType); } else { GLI_xGetMaterialType (hVisualMat,&lType); lType |= GLI_C_lIsTestingBackface; GLI_xSetMaterialType (hVisualMat,lType); } LDT_FreeRefValues( pVal ); break; } case iElementIndexedTriangles_GetFaces: { GEO_tdstElementIndexedTriangles *p_stElement=(GEO_tdstElementIndexedTriangles *)pObject->pObject; GEO_tdstElementIndexedTriangles *p_stTemp=(GEO_tdstElementIndexedTriangles *)pGetFrom->pObject; GEO_M_CPAFree(p_stElement->d_stListOfFacesTripled); GEO_M_CPAFree(p_stElement->d_stListOfFacesNormals); GEO_M_CPAFree(p_stElement->d_stListOfFacesTripledIndexUV); p_stElement->d_stListOfFacesTripled = p_stTemp->d_stListOfFacesTripled; p_stElement->d_stListOfFacesNormals = p_stTemp->d_stListOfFacesNormals; p_stElement->d_stListOfFacesTripledIndexUV = p_stTemp->d_stListOfFacesTripledIndexUV; } break; case iElementIndexedTriangles_GetUVs: { GEO_tdstElementIndexedTriangles *p_stElement=(GEO_tdstElementIndexedTriangles *)pObject->pObject; GEO_tdstElementIndexedTriangles *p_stTemp=(GEO_tdstElementIndexedTriangles *)pGetFrom->pObject; GEO_M_CPAFree(p_stElement->d_stListOfElementUV); p_stElement->d_stListOfElementUV = p_stTemp->d_stListOfElementUV; } break; case iElementLines_GetLines: { GEO_tdstElementLines *p_stElement=(GEO_tdstElementLines *)pObject->pObject; GEO_tdstElementLines *p_stTemp=(GEO_tdstElementLines *)pGetFrom->pObject; GEO_M_CPAFree(p_stElement->d_stListOfLineIndex); p_stElement->d_stListOfLineIndex = p_stTemp->d_stListOfLineIndex; } break; case iElementLines_GetThickness: { GEO_tdstElementLines *p_stElement=(GEO_tdstElementLines *)pObject->pObject; GEO_tdstElementLines *p_stTemp=(GEO_tdstElementLines *)pGetFrom->pObject; p_stElement->xThickness = p_stTemp->xThickness; } break; case iElementPoints_GetPoints: { GEO_tdstElementPoints *p_stElement=(GEO_tdstElementPoints *)pObject->pObject; GEO_tdstElementPoints *p_stTemp=(GEO_tdstElementPoints *)pGetFrom->pObject; GEO_M_CPAFree(p_stElement->d_xListOfPointIndex); p_stElement->d_xListOfPointIndex = p_stTemp->d_xListOfPointIndex; } break; case iElementPoints_GetFatness: { GEO_tdstElementPoints *p_stElement=(GEO_tdstElementPoints *)pObject->pObject; GEO_tdstElementPoints *p_stTemp=(GEO_tdstElementPoints *)pGetFrom->pObject; p_stElement->xFatness = p_stTemp->xFatness; } break; case iElementPoints_GameMaterial: { GEO_tdstElementPoints *p_stElement=(GEO_tdstElementPoints *)pObject->pObject; if( GMT_fn_hGetVisualMaterial(p_stElement->hMaterial)==NULL ) { ACP_tdxHandleOfMaterial hVisualMat; GLI_xCreateMaterial(&hVisualMat); GMT_fn_vSetVisualMaterial(p_stElement->hMaterial,hVisualMat); } } break; case iElementPoints_EndSection: { GEO_tdstElementPoints *p_stElement=(GEO_tdstElementPoints *)pObject->pObject; /* Create a default material to avoid crash*/ if( p_stElement->hMaterial==NULL ) { ACP_tdxHandleOfMaterial hVisualMat; p_stElement->hMaterial=GMT_fn_hCreateGameMaterial(); GLI_xCreateMaterial(&hVisualMat); GMT_fn_vSetVisualMaterial(p_stElement->hMaterial,hVisualMat); } } break; case iFaceMapDescriptor_GetTripledUV: { ACP_tdst2DUVValues stUV1,stUV2,stUV3; ACP_tdxHandleOfFMD hFMD=(ACP_tdxHandleOfFMD)pObject->pObject; ACP_tdxHandleOfFMD hTemp=(ACP_tdxHandleOfFMD)pGetFrom->pObject; GEO_xGetFaceMapDescriptorUV(hTemp, &stUV1, &stUV2, &stUV3); GEO_xSetFaceMapDescriptorUV(hFMD, &stUV1, &stUV2, &stUV3); } break; case iGeometric_GetVertices: { ACP_tdxHandleOfObject hObject=(ACP_tdxHandleOfObject)pObject->pObject; GEO_tdstGeometricObject *p_stTemp=(GEO_tdstGeometricObject *)pGetFrom->pObject; GEO_M_CPAFree(hObject->d_stListOfPoints); GEO_M_CPAFree(hObject->d_stListOfPointsNormals); hObject->d_stListOfPoints = p_stTemp->d_stListOfPoints; hObject->d_stListOfPointsNormals = p_stTemp->d_stListOfPointsNormals; } break; case iGeometric_GetEdges: { ACP_tdxHandleOfObject hObject=(ACP_tdxHandleOfObject)pObject->pObject; GEO_tdstGeometricObject *p_stTemp=(GEO_tdstGeometricObject *)pGetFrom->pObject; GEO_M_CPAFree(hObject->d_stListOfEdges); hObject->d_stListOfEdges = p_stTemp->d_stListOfEdges; } break; case iGeometric_GetElements: { ACP_tdxHandleOfObject hObject=(ACP_tdxHandleOfObject)pObject->pObject; GEO_tdstGeometricObject *p_stTemp=(GEO_tdstGeometricObject *)pGetFrom->pObject; long xIndexElement=pVal[1]; ACP_tdxIndex xIndex = (ACP_tdxIndex)pVal[0]; hObject->d_xListOfElementsTypes[xIndex] = p_stTemp->d_xListOfElementsTypes[xIndexElement]; hObject->d_stListOfElements[xIndex] = p_stTemp->d_stListOfElements[xIndexElement]; if( xCount == 3 ) { ACP_tdxIndex xBoundingVolume = (ACP_tdxIndex)pVal[2]; if ( xBoundingVolume < 0 ) xBoundingVolume = 0; else if ( xBoundingVolume > hObject->xNbElements ) xBoundingVolume = hObject->xNbElements; GEO_vSetParallelBoxIndexOfElement(hObject,xIndex,xBoundingVolume); if( xBoundingVolume+1 > hObject->xNbParallelBoxes ) hObject->xNbParallelBoxes = xBoundingVolume+1; } LDT_FreeRefValues( pVal ); } break; case iGeometric_EndSection: { ACP_tdxHandleOfObject hObject=(ACP_tdxHandleOfObject)pObject->pObject; GEO_vEndModifyObject (hObject); } break; } } } /***************************************************************** Name: GLI_iCreateElementIndexedTriangles Description: Create callback for LDT Author: Mircea Petrescu Date: 6/12/98 Modified: *****************************************************************/ int GLI_iCreateElementIndexedTriangles( LDT_tdst_Link *pLink ) { GEO_tdstElementIndexedTriangles *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementIndexedTriangles*, sizeof(GEO_tdstElementIndexedTriangles), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: GLI_iLoadElementIndexedTriangles Description: Load callback for LDT Author: Mircea Petrescu Date: 6/12/98 Modified: *****************************************************************/ int GLI_iLoadElementIndexedTriangles( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; ACP_tdxIndex xIndex; GEO_tdstElementIndexedTriangles *p_stElement=(GEO_tdstElementIndexedTriangles *)pLink->pObject; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementIndexedTriangle(), a255_cLongName, (unsigned long)p_stElement), 1,iLen ); p_stElement->xNbFaces=atoi( LDT_szGetParam( 1 ) ); p_stElement->xNbElementUV=atoi( LDT_szGetParam( 2 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfFacesTripled , GEO_tdstTripledIndex*, p_stElement->xNbFaces*sizeof(GEO_tdstTripledIndex), E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc(p_stElement->d_stListOfFacesNormals , MTH3D_tdstVector*, p_stElement->xNbFaces*sizeof(MTH3D_tdstVector), E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc(p_stElement->d_stListOfFacesTripledIndexUV , GEO_tdstTripledIndex*, p_stElement->xNbFaces*sizeof(GEO_tdstTripledIndex), E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc(p_stElement->d_stListOfElementUV , ACP_tdst2DUVValues*, p_stElement->xNbElementUV*sizeof(ACP_tdst2DUVValues), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'FddA' : /* AddFaceUV, AddFace */ { if( szEntry[7]==0 ) /* AddFace */ { double f5, f6, f7; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[0]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[1]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[2]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 4 ) )); f5=atof( LDT_szGetParam( 5 ) ); f6=atof( LDT_szGetParam( 6 ) ); f7=atof( LDT_szGetParam( 7 ) ); MTH3D_M_vSetVectorElements((p_stElement->d_stListOfFacesNormals+xIndex), MTH_M_xDoubleToReal(f5), MTH_M_xDoubleToReal(f6), MTH_M_xDoubleToReal(f7) ); p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[0]=(long)(0); p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[1]=(long)(0); p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[2]=(long)(0); } else /*AddFaceUV */ { double f5, f6, f7; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[0]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[1]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfFacesTripled[xIndex].a3_xIndex[2]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 4 ) )); f5=atof( LDT_szGetParam( 5 ) ); f6=atof( LDT_szGetParam( 6 ) ); f7=atof( LDT_szGetParam( 7 ) ); MTH3D_M_vSetVectorElements((p_stElement->d_stListOfFacesNormals+xIndex), MTH_M_xDoubleToReal(f5), MTH_M_xDoubleToReal(f6), MTH_M_xDoubleToReal(f7) ); p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[0]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 8 ) )); p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[1]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 9 ) )); p_stElement->d_stListOfFacesTripledIndexUV[xIndex].a3_xIndex[2]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 10 ) )); } } break; case 'FteG' : /* GetFaces */ { GEO_tdstElementIndexedTriangles *p_stTemp; p_stTemp = (GEO_tdstElementIndexedTriangles*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementIndexedTriangles_GetFaces, 0 ); } break; case 'UddA' : /* AddUV */ { xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_stListOfElementUV[xIndex].xU=(GLI_tdxUVValue)(atof( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfElementUV[xIndex].xV=(GLI_tdxUVValue)(atof( LDT_szGetParam( 3 ) )); } break; case 'UteG' : /* GetUVs */ { GEO_tdstElementIndexedTriangles *p_stTemp; p_stTemp = (GEO_tdstElementIndexedTriangles*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementIndexedTriangles_GetUVs, 0 ); } break; case 'etaM' : /* Material */ { char sFile[256], sParent[256], sAction[256], sId[256]; char *szVal; LDT_SplitSectionName( szVal=LDT_szGetParam( 1 ), sFile, sParent, sAction, sId ); if(strcmp(sAction,"Material") == 0) { ACP_tdxHandleOfMaterial hMat; GMT_tdxHandleToGameMaterial hGameMat; hMat = (ACP_tdxHandleOfMaterial) LDT_LoadSection( szVal ); hGameMat = GMT_fn_hCreateGameMaterial(); GMT_fn_vSetVisualMaterial(hGameMat, hMat); p_stElement->hMaterial = hGameMat; } else { p_stElement->hMaterial=GMT_fn_hLoadGameMaterial(szVal); } } break; case 'nioP' : /* Pointed Sector */ { SCR_tdst_Link_Value *p_stRemoveValue; char a255_cLongName[256]; /* Add the element into a special list of frontier elements */ int iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfFrontierElement(), a255_cLongName, (unsigned long)p_stElement), 1,iLen ); /* Remove it from the normal list of indexed triangles */ p_stRemoveValue=SCR_fnp_st_Link_SearchValue(GLI_p_stGetLinkTableOfElementIndexedTriangle(), (unsigned long)p_stElement); SCR_fn_v_Link_DeleteEntry(GLI_p_stGetLinkTableOfElementIndexedTriangle(),p_stRemoveValue); /* Analyse the pointed sector */ p_stElement->hMaterial = (GMT_tdxHandleToGameMaterial)GMT_fn_hLoadGameMaterial( LDT_szGetParam( 1 ) ); } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateElementFaceMapDescriptors Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementFaceMapDescriptors( LDT_tdst_Link *pLink ) { GEO_tdstElementFaceMapDescriptors *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementFaceMapDescriptors*, sizeof(GEO_tdstElementFaceMapDescriptors), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementFaceMapDescriptors( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstElementFaceMapDescriptors *p_stElement=(GEO_tdstElementFaceMapDescriptors *)pLink->pObject; ACP_tdxIndex xIndex; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementFaceMapDescriptor(), a255_cLongName, (unsigned long)p_stElement), 1, iLen ); p_stElement->xNbFaces=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfFacesQuadrupled , GEO_tdstFaceMapTriangle*, p_stElement->xNbFaces*sizeof(GEO_tdstFaceMapTriangle), E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc(p_stElement->d_stListOfFacesNormals , MTH3D_tdstVector*, p_stElement->xNbFaces*sizeof(MTH3D_tdstVector), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'FddA' : /* AddFaceFMD */ { ACP_tdxHandleOfFMD hFaceMapDescriptor; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); hFaceMapDescriptor = (ACP_tdxHandleOfFMD)LDT_LoadSection( LDT_szGetParam( 8 ) ); assert(hFaceMapDescriptor != NULL); p_stElement->d_stListOfFacesQuadrupled[xIndex].stFaceTripled.a3_xIndex[0]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfFacesQuadrupled[xIndex].stFaceTripled.a3_xIndex[1]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfFacesQuadrupled[xIndex].stFaceTripled.a3_xIndex[2]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 4 ) )); p_stElement->d_stListOfFacesQuadrupled[xIndex].hFaceMapDescriptor = hFaceMapDescriptor; MTH3D_M_vSetVectorElements((p_stElement->d_stListOfFacesNormals+xIndex), MTH_M_xDoubleToReal(atof( LDT_szGetParam( 5 ) )), MTH_M_xDoubleToReal(atof( LDT_szGetParam( 6 ) )), MTH_M_xDoubleToReal(atof( LDT_szGetParam( 7 ) )) ); } break; } } } } return 0; } /***************************************************************** Name: Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementSprites( LDT_tdst_Link *pLink ) { GEO_tdstElementSprite *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementSprite*, sizeof(GEO_tdstElementSprite), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: GLI_iLoadElementSprites Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementSprites( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; ACP_tdxIndex xIndex; GEO_tdstElementSprite *p_stElement=(GEO_tdstElementSprite *)pLink->pObject; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementSprite(), a255_cLongName, (unsigned long)p_stElement), 1, iLen ); p_stElement->xNbSprites=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfSprites , GEO_tdstIndexedSprite*, p_stElement->xNbSprites*sizeof(GEO_tdstIndexedSprite), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'SddA' : /* AddSprite */ { ACP_tdxHandleOfSprite hSprite; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); hSprite = (ACP_tdxHandleOfSprite)LDT_LoadSection( LDT_szGetParam( 5 ) ); assert(hSprite != NULL); p_stElement->d_stListOfSprites[xIndex].xCenterPoint=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfSprites[xIndex].stSize.xX=(MTH_tdxReal)(atof( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfSprites[xIndex].stSize.xY=(MTH_tdxReal)(atof( LDT_szGetParam( 4) )); p_stElement->d_stListOfSprites[xIndex].hSprite=hSprite; } break; case 'RddA' : /* AddRotationAxe */ { xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_stListOfSprites[xIndex].stAxe.xX = (MTH_tdxReal)(atof( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfSprites[xIndex].stAxe.xY = (MTH_tdxReal)(atof( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfSprites[xIndex].stAxe.xZ = (MTH_tdxReal)(atof( LDT_szGetParam( 4 ) )); } break; case 'UddA' : /* AddUV */ { xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_stListOfSprites[xIndex].stUVpos.xU = (MTH_tdxReal)(atof( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfSprites[xIndex].stUVpos.xV = (MTH_tdxReal)(atof( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfSprites[xIndex].stUVsize.xU = (MTH_tdxReal)(atof( LDT_szGetParam( 4 ) )); p_stElement->d_stListOfSprites[xIndex].stUVsize.xV = (MTH_tdxReal)(atof( LDT_szGetParam( 5 ) )); } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateElementLines Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementLines( LDT_tdst_Link *pLink ) { GEO_tdstElementLines *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementLines*, sizeof(GEO_tdstElementLines), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: GLI_iLoadElementLines Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementLines( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstElementLines *p_stElement=( GEO_tdstElementLines *)pLink->pObject; ACP_tdxIndex xIndex; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementLine(), a255_cLongName, (unsigned long)p_stElement), 1, iLen ); p_stElement->xNbLines=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfLineIndex , GEO_tdstDoubledIndex*, p_stElement->xNbLines*sizeof(GEO_tdstDoubledIndex), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'LddA' : /* AddLine */ { xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_stListOfLineIndex[xIndex].a2_xIndex[0]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfLineIndex[xIndex].a2_xIndex[1]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); } break; case 'LteG' : /* GetLines */ { GEO_tdstElementLines *p_stTemp; p_stTemp = (GEO_tdstElementLines*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementLines_GetLines, 0 ); } break; case 'cihT' : /* Thickness */ { p_stElement->xThickness = (MTH_tdxReal)(atof( LDT_szGetParam( 1 ) )); } break; case 'TteG' : /* GetThickness */ { GEO_tdstElementLines *p_stTemp; p_stTemp = (GEO_tdstElementLines*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementLines_GetThickness, 0 ); } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateElementSpheres Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementSpheres( LDT_tdst_Link *pLink ) { GEO_tdstElementSpheres *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementSpheres*, sizeof(GEO_tdstElementSpheres), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementSpheres( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstElementSpheres *p_stElement=( GEO_tdstElementSpheres *)pLink->pObject; ACP_tdxIndex xIndex; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementSphere(), a255_cLongName, (unsigned long)p_stElement), 1, iLen ); p_stElement->xNbSpheres=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfSpheres , GEO_tdstIndexedSphere*, p_stElement->xNbSpheres*sizeof(GEO_tdstIndexedSphere), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'SddA' : /* AddSphere */ { char szName[256]; GMT_tdxHandleToGameMaterial hMaterial; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); hMaterial=GMT_fn_hLoadGameMaterial( strcpy(szName, LDT_szGetParam( 4 )) ); assert(hMaterial != NULL); p_stElement->d_stListOfSpheres[xIndex].xCenterPoint=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfSpheres[xIndex].xRadius=(MTH_tdxReal)(GLI_dGetUnitInMeterInFile(pLink->szFile)*atof( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfSpheres[xIndex].hMaterial = hMaterial; } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateElementAlignedBoxes Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementAlignedBoxes( LDT_tdst_Link *pLink ) { GEO_tdstElementAlignedBoxes *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementAlignedBoxes*, sizeof(GEO_tdstElementAlignedBoxes), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: GLI_iLoadElementAlignedBoxes Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementAlignedBoxes( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstElementAlignedBoxes *p_stElement=( GEO_tdstElementAlignedBoxes *)pLink->pObject; ACP_tdxIndex xIndex; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementAlignedBoxe(), a255_cLongName, (unsigned long)p_stElement), 1, iLen ); p_stElement->xNbAlignedBoxes=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfAlignedBoxes , GEO_tdstIndexedAlignedBox*, p_stElement->xNbAlignedBoxes*sizeof(GEO_tdstIndexedAlignedBox), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'AddA' : /* AddAlignedBox */ { char szName[256]; GMT_tdxHandleToGameMaterial hMaterial; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); hMaterial=GMT_fn_hLoadGameMaterial( strcpy( szName, LDT_szGetParam( 4 )) ); assert(hMaterial != NULL); p_stElement->d_stListOfAlignedBoxes[xIndex].xMinPoint=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfAlignedBoxes[xIndex].xMaxPoint=(ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfAlignedBoxes[xIndex].hMaterial = hMaterial; } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateElementPoints Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementPoints( LDT_tdst_Link *pLink ) { GEO_tdstElementPoints *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementPoints*, sizeof(GEO_tdstElementPoints), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: GLI_iLoadElementPoints Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementPoints( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstElementPoints *p_stElement=( GEO_tdstElementPoints * )pLink->pObject; ACP_tdxIndex xIndex; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementPoint(), a255_cLongName, (unsigned long)p_stElement), 1, iLen ); p_stElement->xNbPoints=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_xListOfPointIndex , ACP_tdxIndex*, p_stElement->xNbPoints*sizeof(ACP_tdxIndex), E_uwGEONotEnoughtMemory ); p_stElement->hMaterial = NULL; while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'PddA' : /* AddPoint */ { xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); p_stElement->d_xListOfPointIndex[xIndex]=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); } break; case 'PteG' : /* GetPoints */ { GEO_tdstElementPoints *p_stTemp; p_stTemp = (GEO_tdstElementPoints*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementPoints_GetPoints, 0 ); } break; case 'ntaF' : /* Fatness */ { p_stElement->xFatness = (MTH_tdxReal)(atof( LDT_szGetParam( 1 ) )); } break; case 'FteG' : /* GetFatness */ { GEO_tdstElementPoints *p_stTemp; p_stTemp = (GEO_tdstElementPoints*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementPoints_GetFatness, 0 ); } break; case 'emaG' : /* GameMaterial */ { char szName[256]; p_stElement->hMaterial = GMT_fn_hLoadGameMaterial( strcpy( szName, LDT_szGetParam( 1 ) ) ); LDT_AddToRefsTable( g_hRefGeom, pLink, iElementPoints_GameMaterial, 0 ); } break; } } break; case ParseResult_EndSection: /* end section */ LDT_AddToRefsTable( g_hRefGeom, pLink, iElementPoints_EndSection, 0 ); } } return 0; } /***************************************************************** Name: GLI_iCreateElementCones Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateElementCones( LDT_tdst_Link *pLink ) { GEO_tdstElementCones *p_stElement; GEO_M_CPAMalloc(p_stElement, GEO_tdstElementCones*, sizeof(GEO_tdstElementCones), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stElement; return 0; } /***************************************************************** Name: GLI_iLoadElementCones Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadElementCones( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstElementCones *p_stElement=( GEO_tdstElementCones *)pLink->pObject; ACP_tdxIndex xIndex; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfElementCone(), a255_cLongName, (unsigned long)p_stElement), 1, iLen); p_stElement->xNbCones=atoi( LDT_szGetParam( 1 ) ); GEO_M_CPAMalloc(p_stElement->d_stListOfCones, GEO_tdstIndexedCone*, p_stElement->xNbCones*sizeof(GEO_tdstIndexedCone), E_uwGEONotEnoughtMemory ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'CddA' : /* AddCone */ { GMT_tdxHandleToGameMaterial hMaterial; xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); if(LDT_iGetNbParams() == 6) { char *sz; if( strstr( sz=LDT_szGetParam( 5 ) ,"GameMaterial") == NULL) /* VisualMaterial*/ { ACP_tdxHandleOfMaterial hMat; GMT_tdxHandleToGameMaterial hGameMat; hMat = (ACP_tdxHandleOfMaterial)LDT_LoadSection( sz ); hGameMat = GMT_fn_hCreateGameMaterial(); GMT_fn_vSetVisualMaterial(hGameMat, hMat); hMaterial = hGameMat; } else { char szName[256]; hMaterial = GMT_fn_hLoadGameMaterial( strcpy( szName, LDT_szGetParam( 5 ))); } assert(hMaterial != NULL); } else hMaterial = NULL; p_stElement->d_stListOfCones[xIndex].xTopPoint=(ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); p_stElement->d_stListOfCones[xIndex].xBasePoint=(ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); p_stElement->d_stListOfCones[xIndex].xBaseRadius=MTH_M_xDoubleToReal(atof( LDT_szGetParam( 4 ) ) * GLI_dGetUnitInMeterInFile(pLink->szFile)); p_stElement->d_stListOfCones[xIndex].hMaterial = hMaterial; } break; } } } } return 0; } /***************************************************************** Name: Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateMaterial( LDT_tdst_Link *pLink ) { ACP_tdxHandleOfMaterial hVisualMat; GLI_xCreateMaterial(&hVisualMat); GLI_vSetMaterialName ( hVisualMat, LDT_szGetSectionType()); pLink->pObject=(void *)hVisualMat; return 0; } /***************************************************************** Name: GLI_iLoadMaterial Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadMaterial( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; ACP_tdxHandleOfMaterial hVisualMat=( ACP_tdxHandleOfMaterial )pLink->pObject; GEO_tdstColor stColor; long localType; int AddTextureHasLeftTheBuilding = 0; char a255_cLongName[256]; int iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfVisualMaterial(), a255_cLongName, (unsigned long)hVisualMat), 1, iLen); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'epyT' : /* Type */ { char *sz=LDT_szGetParam( 1 ); switch( *(long *)sz ) { case 'ruoG' : if( sz[7]==0 ) /*"Gouraud"*/ GLI_xSetMaterialType(hVisualMat, C_lGouraudElement); else GLI_xSetMaterialType(hVisualMat, C_lGouraudElement - GLI_C_lIsNotGrided - GLI_C_lIsNotLightAlphaSensitive); break; case 'talF' : /*"Flat"*/ GLI_xSetMaterialType(hVisualMat, C_lGouraudElement - GLI_C_lIsGouraud); break; case 'narT' : /*"Transparent"*/ GLI_xSetMaterialType(hVisualMat, C_lGouraudElement - GLI_C_lIsNotGrided ); break; } } break; case 'ibmA' : /* AmbientColor */ { stColor.xR = (float)atof( LDT_szGetParam( 1 ) ); stColor.xG = (float)atof( LDT_szGetParam( 2 ) ); stColor.xB = (float)atof( LDT_szGetParam( 3 ) ); if (LDT_iGetNbParams()==5) stColor.xA = (float)atof( LDT_szGetParam( 4 ) ); else stColor.xA = 1.0f; GLI_xSetMaterialAmbientCoef(hVisualMat, &stColor); } break; case 'ffiD' : /* DiffuseColor */ { stColor.xR = (float)atof( LDT_szGetParam( 1 ) ); stColor.xG = (float)atof( LDT_szGetParam( 2 ) ); stColor.xB = (float)atof( LDT_szGetParam( 3 ) ); if (LDT_iGetNbParams()==5) stColor.xA = (float)atof( LDT_szGetParam( 4 ) ); else stColor.xA = 1.0f; GLI_xSetMaterialDiffuseCoef(hVisualMat, &stColor); } break; case 'cepS' : /* SpecularColor */ { stColor.xR = (float)atof( LDT_szGetParam( 1 ) ); stColor.xG = (float)atof( LDT_szGetParam( 2 ) ); stColor.xB = (float)atof( LDT_szGetParam( 3 ) ); if (LDT_iGetNbParams()>=5) stColor.xA = (float)atof( LDT_szGetParam( 4 ) ); else stColor.xA = 1.0f; if (LDT_iGetNbParams()>=6) GLI_xSetMaterialSpecularCoef(hVisualMat, atol( LDT_szGetParam( 5 ) ), &stColor); else GLI_xSetMaterialSpecularCoef(hVisualMat, 100 , &stColor); } break; case 'txeT' : /* Texture */ if( szEntry[7]==0 ) { char a_cFullName[255]; GLI_tdstTexture *p_stTexture; char *szVal; if( GLI_bGetTextureName((szVal=LDT_szGetParam( 1 )), a_cFullName) ) { long localType; GLI_xLoadTexture(&p_stTexture,NULL,szVal,0,0); if (p_stTexture==NULL) { GLI_xSetMaterialType(hVisualMat, C_lGouraudElement); break; } SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfTexture(), a_cFullName, (unsigned long)p_stTexture), 1, strlen(a_cFullName) - strlen(szVal)); if (szVal=LDT_szGetParam( 2 )) { float f1=(float)atof( szVal ); if(szVal=LDT_szGetParam( 3 )) { float f2=(float)atof(szVal); GLI_xSetMaterialTextureScrollingCoef( hVisualMat , 0 , 1 , f1,f2); } } GLI_xGetMaterialType(hVisualMat, &localType); localType |= GLI_C_lIsTextured; GLI_xSetMaterialType(hVisualMat, localType); GLI_xSetMaterialTexture(hVisualMat, p_stTexture); } } else /* Texture1 */ { char a_cName[255]; char a_cFullName[255]; char a_cFullNameMipMap[255]; long lNbLoD,lLodCounter; GLI_tdstTexture *p_stTexture; char * szVal, *szVal1, *szVal2; if( GLI_bGetTextureName((szVal=LDT_szGetParam( 1 )), a_cFullName) ) { strcpy( a_cName, szVal ); GLI_xLoadTexture(&p_stTexture,NULL,a_cName,0,atol( LDT_szGetParam( 2 ) )); if (p_stTexture==NULL) { GLI_xSetMaterialType(hVisualMat, C_lGouraudElement); break; } szVal1=LDT_szGetParam( 3 ); if (strcmp(szVal1,"AUTO") == 0) { GLI_vComputeLod(p_stTexture); } else { if (atol(szVal1)>0) { lNbLoD = atol(szVal1); for (lLodCounter = 0 ; lLodCounter < lNbLoD ; lLodCounter ++ ) { if (GLI_bGetTextureName((szVal2=LDT_szGetParam( lLodCounter+4 )), a_cFullNameMipMap)) GLI_vLoadLodAndAddItToTexture(p_stTexture,NULL,szVal2,0,0); } } } } SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfTexture(), a_cFullName, (unsigned long)p_stTexture), 1, strlen(a_cFullName) - strlen(a_cName)); GLI_xGetMaterialType(hVisualMat, &localType); localType |= GLI_C_lIsTextured; GLI_xSetMaterialType(hVisualMat, localType); GLI_xSetMaterialTexture(hVisualMat, p_stTexture); } break; case 'orcS' : /* Scroll */ { GLI_xSetMaterialTextureScrollingCoef( hVisualMat , 0 , 1 , (float)atof( LDT_szGetParam( 2 ) ),(float)atof( LDT_szGetParam( 3 ) )); } break; case 'TddA' : /* AddTexture */ { ACP_tdxIndex xIndex; char *szVal; AddTextureHasLeftTheBuilding = 1; xIndex = atoi( LDT_szGetParam( 1 ) ); LDT_LoadSection( LDT_szGetParam( 2 ) ); if ((szVal= LDT_szGetParam( 3 ) )) LDT_AddToRefsTable( g_hRefGeom, pLink, iElementMaterial_AddTexture , 1, atof(szVal) ); else LDT_AddToRefsTable( g_hRefGeom, pLink, iElementMaterial_AddTexture , 0 ); GLI_xGetMaterialType(hVisualMat, &localType); localType |= GLI_C_lIsTextured; GLI_xSetMaterialType(hVisualMat, localType); } break; case '1vnE' : /* Env1 */ case 'TteS' : /* SetTextureAsEnvironnement */ { GLI_vSetMaterialAsChromed ( hVisualMat, 1); } break; case 'kcaB' : /* Backface */ { if(AddTextureHasLeftTheBuilding) LDT_AddToRefsTable( g_hRefGeom, pLink, iElementMaterial_Backface, 1, *(long*)LDT_szGetParam(1)=='FFO' ); /* OFF*/ else { long lType; if (!(*(long*)LDT_szGetParam(1)=='FFO')) { GLI_xGetMaterialType (hVisualMat,&lType); lType &= 0xffffffff - GLI_C_lIsTestingBackface; GLI_xSetMaterialType (hVisualMat,lType); } else { GLI_xGetMaterialType (hVisualMat,&lType); lType |= GLI_C_lIsTestingBackface; GLI_xSetMaterialType (hVisualMat,lType); } } } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateFaceMapDescriptor Description: Create callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iCreateFaceMapDescriptor( LDT_tdst_Link *pLink ) { ACP_tdxHandleOfFMD hFMD; GEO_xCreateFaceMapDescriptor(&hFMD); pLink->pObject=(void *)hFMD; return 0; } /***************************************************************** Name: GLI_iLoadFaceMapDescriptor Description: Load callback for LDT Author: Mircea Petrescu Date: 6/18/98 Modified: *****************************************************************/ int GLI_iLoadFaceMapDescriptor( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; ACP_tdxHandleOfFMD hFMD=( ACP_tdxHandleOfFMD )pLink->pObject; char a255_cLongName[256]; int iLen; iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfFaceMapDescriptor(), a255_cLongName, (unsigned long)hFMD), 1, iLen); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'pirT' : /* TripledUV */ { ACP_tdst2DUVValues stUV1,stUV2,stUV3; stUV1.xU = (float)atof( LDT_szGetParam( 1 ) ); stUV1.xV = (float)atof( LDT_szGetParam( 2 ) ); stUV2.xU = (float)atof( LDT_szGetParam( 3 ) ); stUV2.xV = (float)atof( LDT_szGetParam( 4 ) ); stUV3.xU = (float)atof( LDT_szGetParam( 5 ) ); stUV3.xV = (float)atof( LDT_szGetParam( 6 ) ); GEO_xSetFaceMapDescriptorUV(hFMD, &stUV1, &stUV2, &stUV3); } break; case 'TteG' : /* GetTripledUV */ { ACP_tdxHandleOfFMD hTemp; hTemp = (ACP_tdxHandleOfFMD)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(hTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iFaceMapDescriptor_GetTripledUV, 0 ); } break; case 'etaM' : /* Material */ /*case 'nioP' : /* Pointed Sector */ { char sFile[256], sParent[256], sAction[256], sIdent[256]; GMT_tdxHandleToGameMaterial hMaterial; char * szName; szName=LDT_szGetParam( 1 ); LDT_SplitSectionName(szName, sFile, sParent, sAction, sIdent); if(strcmp(sAction,"Material") == 0) { ACP_tdxHandleOfMaterial hMat; GMT_tdxHandleToGameMaterial hGameMat; hMat = (ACP_tdxHandleOfMaterial)LDT_LoadSection( szName ); hGameMat = GMT_fn_hCreateGameMaterial(); GMT_fn_vSetVisualMaterial(hGameMat, hMat); hMaterial = hGameMat; } else { char szName[256]; hMaterial = GMT_fn_hLoadGameMaterial( strcpy( szName, LDT_szGetParam( 1 )) ); } assert(hMaterial != NULL); GEO_xSetFaceMapDescriptorGameMaterial(hFMD, hMaterial); } break; } } } } return 0; } /***************************************************************** Name: GLI_iCreateSprite Description: Create callback for LDT Author: Mircea Petrescu Date: 6/19/98 Modified: *****************************************************************/ int GLI_iCreateSprite( LDT_tdst_Link *pLink ) { ACP_tdxHandleOfSprite hSprite; GEO_M_CPAMalloc ( hSprite , GEO_tdstSprite * , sizeof ( GEO_tdstSprite ) , E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)hSprite; return 0; } /***************************************************************** Name: GLI_iLoadSprite Description: Load callback for LDT Author: Mircea Petrescu Date: 6/19/98 Modified: *****************************************************************/ int GLI_iLoadSprite( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; ACP_tdxHandleOfSprite hSprite=( ACP_tdxHandleOfSprite )pLink->pObject; MTH2D_tdstVector stSize; char a255_cLongName[256]; int iLen; long liCount; int xNbAngles=atoi( LDT_szGetParam( 1 ) ); iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfSprite(), a255_cLongName, (unsigned long)hSprite), 1, iLen); GEO_M_CPAMalloc ( hSprite -> d_xThresholds , MTH_tdxReal * , sizeof ( MTH_tdxReal ) * xNbAngles , E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc ( hSprite -> d_xSpriteDrawMode , short * , sizeof ( short ) * xNbAngles, E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc ( hSprite -> d_hMaterial , GMT_tdxHandleToGameMaterial * , sizeof ( GMT_tdxHandleToGameMaterial ) * xNbAngles, E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc ( hSprite -> d_xSizeOfSprite , MTH2D_tdstVector *, sizeof ( MTH2D_tdstVector ) * xNbAngles , E_uwGEONotEnoughtMemory ); GEO_M_CPAMalloc ( hSprite -> d_xDisplacementOfSprite , MTH2D_tdstVector * , sizeof ( MTH2D_tdstVector ) * xNbAngles , E_uwGEONotEnoughtMemory ); for ( liCount = 0; liCount < xNbAngles ; liCount ++) { hSprite -> d_hMaterial [liCount] = NULL; hSprite -> d_xSpriteDrawMode [liCount] = GEO_C_lSpriteDrawMode2DRotativ ; hSprite -> d_xSizeOfSprite [liCount] . xX = 1.00f; hSprite -> d_xSizeOfSprite [liCount] . xY = 1.00f; hSprite -> d_xDisplacementOfSprite [liCount] . xX = 0.0f; hSprite -> d_xDisplacementOfSprite [liCount] . xY = 0.0f; } hSprite -> xNbSprites = xNbAngles ; while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'MddA' : /* AddMaterial */ { char sFile[256], sParent[256],sAction[256], sIdent[256]; GMT_tdxHandleToGameMaterial hMaterial; ACP_tdxIndex xIndex; char szName[256]; xIndex = atoi( LDT_szGetParam( 1 ) ); strcpy( szName, LDT_szGetParam( 2 ) ); LDT_SplitSectionName(szName, sFile, sParent, sAction, sIdent); if(strcmp(sAction,"Material") == 0) { ACP_tdxHandleOfMaterial hMat; GMT_tdxHandleToGameMaterial hGameMat; hMat = (ACP_tdxHandleOfMaterial)LDT_LoadSection( szName ); hGameMat = GMT_fn_hCreateGameMaterial(); GMT_fn_vSetVisualMaterial(hGameMat, hMat); hMaterial = hGameMat; } else hMaterial = GMT_fn_hLoadGameMaterial(szName); assert(hMaterial != NULL); GEO_vSetGameMaterialOfSprite(hSprite, hMaterial, xIndex); } break; case 'IddA' : /* AddInfo */ { ACP_tdxIndex xIndex; MTH_tdxReal xParam; BOOL b2DScaled; char *szVal; xIndex = atoi( LDT_szGetParam( 1 ) ); szVal=LDT_szGetParam( 2 ); if( strcmp(szVal,"2DScaled")==0) { GEO_vSetModeOfSprite(hSprite, GEO_C_lSpriteDrawMode2DScaled , xIndex);/*Philippe*/ b2DScaled = TRUE; } else if( strcmp(szVal,"2DNonScaled")==0) { GEO_vSetModeOfSprite(hSprite, 0, xIndex); /* Marc V*/ b2DScaled = FALSE; } else if ( strcmp(szVal,"SemiLookAt")==0 ) { GEO_vSetModeOfSprite(hSprite, GEO_C_lSpriteDrawModeSemiLookAt , xIndex); b2DScaled = TRUE; } else if ( strcmp(szVal,"LensFlare")==0 ) { GEO_vSetModeOfSprite(hSprite, GEO_C_lSpriteDrawModeLensFlare , xIndex); b2DScaled = TRUE; } xParam = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 3 ) )); GEO_vSetThresholdOfSprite(hSprite, xParam, xIndex); if(b2DScaled) { stSize.xX = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 4 ) )*GLI_dGetUnitInMeterInFile(pLink->szFile) / 2.0); stSize.xY = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 5 ) )*GLI_dGetUnitInMeterInFile(pLink->szFile) / 2.0); } else { stSize.xX = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 4 ) ) / 2.0); stSize.xY = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 5 ) ) / 2.0); } GEO_vSetSizeOfSprite(hSprite, &stSize, xIndex); stSize.xX = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 6 ) )); stSize.xY = MTH_M_xDoubleToReal(atof( LDT_szGetParam( 7 ) )); GEO_vSetDisplacementOfSprite(hSprite, &stSize, xIndex); } break; } } } } return 0; } /***************************************************************** Name: GLI_iLoadTextureSection Description: Load callback for LDT Author: Mircea Petrescu Date: 6/19/98 Modified: *****************************************************************/ int GLI_iLoadTextureSection( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GLI_tdstTexture *hTexture; char a255_cLongName[256]; int iLen; GLI_xCreateTexture(&hTexture); iLen=LDT_ComputeSectionName( pLink, a255_cLongName ) ; SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfTextureSection(), a255_cLongName, (unsigned long)hTexture), 1, iLen); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'orhC' : /* Chromakey */ { BOOL bFiltering; bFiltering = 0; if (strcmp(LDT_szGetParam( 1 ),"DISABLE") == 0) { TEX_vSetTextureChromakey (hTexture, 0 , 0, 0, 0, 0, 0);/* No chromakey.*/ } else { if (strcmp(LDT_szGetParam( 2 ),"FILTERING_ON") == 0) { bFiltering = 1; } TEX_vSetTextureChromakey ( hTexture , 1 , bFiltering , (unsigned char)(atol( LDT_szGetParam( 3 ) ) & 0xff) , (unsigned char)(atol( LDT_szGetParam( 4 ) ) & 0xff) , (unsigned char)(atol( LDT_szGetParam( 5 ) ) & 0xff) , (unsigned char)(atol( LDT_szGetParam( 6 ) ) & 0xff) ) ; } } break; case 'lauQ' : /* Quality */ { char lQuality; char *szVal= LDT_szGetParam( 1 ); if (*(long *)szVal=='WOL'/*LOW*/) { lQuality = TEX_C_QLOW; } else if (*(long *)szVal=='HGIH'/*HIGH*/) { lQuality = (char)TEX_C_QHIGH; } else lQuality = (char)TEX_C_QNORMAL; TEX_vSetTextureQualityLevel(hTexture , lQuality ) ; } break; case 'iliT' : /* Tiling */ { TEX_vSetTextureTilingMode( hTexture , *(short *)LDT_szGetParam( 1 )=='NO' /*ON*/ , *(short *)LDT_szGetParam( 2 )=='NO'/*ON*/ ); } break; case 'rriM' : /* Mirror */ case 'edoM' : /* ModeUsed */ case 'issA' : /* AssignPalette */ break; case 'MpiM' : /* MipMapping */ { if (*(long *)LDT_szGetParam( 1 )!='FFO') /* OFF */ GLI_vComputeLod(hTexture); } break; case 'daoL' : /* LoadTexture */ { char a_cFullName[255]; char *szVal= LDT_szGetParam( 1 ) ; if( GLI_bGetTextureName(szVal, a_cFullName) ) { GLI_xLoadTextureHeader(&hTexture,NULL,szVal,0,0); if( hTexture == NULL ) { while((result=LDT_GetNextEntry())!=ParseResult_EndSection ); break; } SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfTexture(), a_cFullName, (unsigned long)hTexture), 1, strlen(a_cFullName) - strlen(szVal)); } } break; case 'iliB' : /* Bilinear */ { TEX_vSetTextureBilinearMode( hTexture , *(short *)LDT_szGetParam( 1 )=='NO' /*ON*/ , *(short *)LDT_szGetParam( 2 )=='NO'/*ON*/ ); } break; case 'irWZ' : /* ZWrite */ { TEX_vSetTextureZWriteMode( hTexture , strcmp( LDT_szGetParam( 1 ) ,"OFF")); } break; } } } } pLink->pObject=(void *)hTexture; return 0; } /***************************************************************** Name: GLI_iCreateGeometric Description: Create callback for LDT Author: Mircea Petrescu Date: 6/19/98 Modified: *****************************************************************/ int GLI_iCreateGeometric( LDT_tdst_Link *pLink ) { GEO_tdstGeometricObject *p_stObjectToCreate; GEO_M_CPAMalloc (p_stObjectToCreate , GEO_tdstGeometricObject * , sizeof ( GEO_tdstGeometricObject), E_uwGEONotEnoughtMemory ); pLink->pObject=(void *)p_stObjectToCreate; return 0; } /***************************************************************** Name: GLI_iLoadGeometric Description: Load callback for LDT Author: Mircea Petrescu Date: 6/19/98 Modified: *****************************************************************/ int GLI_iLoadGeometric( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GEO_tdstGeometricObject *p_stObjectToCreate=( GEO_tdstGeometricObject * )pLink->pObject; ACP_tdxHandleOfObject hObject=(ACP_tdxHandleOfObject)p_stObjectToCreate; short xNbElements=atoi( LDT_szGetParam( 3 ) ); short xNbPoints=atoi( LDT_szGetParam( 1 ) ); char a255_cLongName[256]; int iLen=LDT_ComputeSectionName(pLink,a255_cLongName); SCR_M_v_Link_SetAdditionalLong( SCR_fnp_st_Link_SetValue(GLI_p_stGetLinkTableOfGeometric(), a255_cLongName, (unsigned long)p_stObjectToCreate), 1, iLen); p_stObjectToCreate->xNbElements = xNbElements; p_stObjectToCreate->xNbPoints = xNbPoints; /* alloc Array of Element Type*/ GEO_M_CPAMalloc (p_stObjectToCreate->d_xListOfElementsTypes , ACP_tdxIndex * , sizeof ( ACP_tdxIndex ) * xNbElements , E_uwGEONotEnoughtMemory ); /* alloc Array of Element*/ GEO_M_CPAMalloc (p_stObjectToCreate->d_stListOfElements , void ** , sizeof ( void * ) * xNbElements , E_uwGEONotEnoughtMemory ); /* alloc Array of Points*/ GEO_M_CPAMalloc (p_stObjectToCreate->d_stListOfPoints , MTH3D_tdstVector * , sizeof ( MTH3D_tdstVector ) * xNbPoints , E_uwGEONotEnoughtMemory ); /* alloc Array of Normals*/ GEO_M_CPAMalloc (p_stObjectToCreate->d_stListOfPointsNormals , MTH3D_tdstVector * , sizeof ( MTH3D_tdstVector ) * xNbPoints , E_uwGEONotEnoughtMemory ); { ACP_tdxIndex xInitCount; for (xInitCount=0;xInitCountd_xListOfElementsTypes[xInitCount]=GEO_C_xElementNULL; p_stObjectToCreate->p_stOctree = NULL; /* ANNECY MT 20/02/98 {*/ p_stObjectToCreate -> xNbParallelBoxes = 0; p_stObjectToCreate -> d_stListOfParallelBoxes = NULL; /* ANNECY MT }*/ /*JMD*/ p_stObjectToCreate->ulType = GEO_C_NotALookAt ; /*JMD*/ #if defined(U64) p_stObjectToCreate->fScale = 1.0; p_stObjectToCreate->fRadius = 16384.0; p_stObjectToCreate->uwRliFlag = 0; #endif /* U64 */ } hObject->xNbEdges=atoi( LDT_szGetParam( 2 ) ); while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case 'VddA' : /* AddVertex */ { double dUnit=GLI_dGetUnitInMeterInFile(pLink->szFile); double f1, f2, f3; MTH3D_tdstVector stPoint; ACP_tdxIndex xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); f1=atof( LDT_szGetParam( 2 ) ) * dUnit; f2=atof( LDT_szGetParam( 3 ) ) * dUnit; f3=atof( LDT_szGetParam( 4 ) ) * dUnit; MTH3D_M_vSetVectorElements(&stPoint, MTH_M_xDoubleToReal(f1), MTH_M_xDoubleToReal(f2), MTH_M_xDoubleToReal(f3) ); GEO_vSetPointOfObject(hObject, &stPoint, xIndex); f1=atof( LDT_szGetParam( 5 ) ); f2=atof( LDT_szGetParam( 6 ) ); f3=atof( LDT_szGetParam( 7 ) ); MTH3D_M_vSetVectorElements(&stPoint, MTH_M_xDoubleToReal(f1), MTH_M_xDoubleToReal(f2), MTH_M_xDoubleToReal(f3) ); GEO_vSetNormalOfPointOfObject(hObject, &stPoint, xIndex); } break; case 'VteG' : /* GetVertices */ { GEO_tdstGeometricObject *p_stTemp; p_stTemp = (GEO_tdstGeometricObject*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iGeometric_GetVertices, 0 ); } break; case 'EteG' : if( szEntry[8]==0 ) /* GetEdges */ { GEO_tdstGeometricObject *p_stTemp; p_stTemp = (GEO_tdstGeometricObject*)LDT_LoadSection( LDT_szGetParam( 1 ) ); assert(p_stTemp != NULL); LDT_AddToRefsTable( g_hRefGeom, pLink, iGeometric_GetEdges, 0 ); } else /* GetElements */ { GEO_tdstGeometricObject *p_stTemp; long xIndexElement; short xCount=2; ACP_tdxIndex xBoundingVolume ; ACP_tdxIndex xIndex = atoi( LDT_szGetParam( 1 ) ); xIndexElement = atoi( LDT_szGetParam( 3 ) ); if( LDT_iGetNbParams() == 5 ) { xBoundingVolume = (ACP_tdxIndex)atoi( LDT_szGetParam( 4 ) ); xCount=3; } p_stTemp = (GEO_tdstGeometricObject*)LDT_LoadSection( LDT_szGetParam( 2 ) ); assert(p_stTemp != NULL); if( xCount==3 ) LDT_AddToRefsTable( g_hRefGeom, pLink, iGeometric_GetElements, xCount, (long)xIndex, (long)xIndexElement, (long)xBoundingVolume ); else LDT_AddToRefsTable( g_hRefGeom, pLink, iGeometric_GetElements, xCount, (long)xIndex, (long)xIndexElement ); } break; case 'EddA' : if( szEntry[7]==0 ) /* AddEdge */ { ACP_tdxIndex xIndex = (ACP_tdxIndex)atoi( LDT_szGetParam( 1 ) ); hObject->d_stListOfEdges[xIndex].a2_xIndex[0] = (ACP_tdxIndex)(atoi( LDT_szGetParam( 2 ) )); hObject->d_stListOfEdges[xIndex].a2_xIndex[1] = (ACP_tdxIndex)(atoi( LDT_szGetParam( 3 ) )); } else /* AddElement */ { char sFile[256], sParent[256], sAction[256], sIdent[256]; unsigned short uwTypeElement; void *p_stElement; char *szName; ACP_tdxIndex xIndex = atoi( LDT_szGetParam( 1 ) ); szName=LDT_szGetParam( 3 ); LDT_SplitSectionName(szName, sFile, sParent, sAction, sIdent); if(strcmp(sAction,"ElementIndexedTriangles")==0) uwTypeElement = GEO_C_xElementIndexedTriangles; else if(strcmp(sAction,"ElementFaceMapDescriptors")==0) uwTypeElement = GEO_C_xElementFaceMapDescriptors; else if(strcmp(sAction,"ElementTMeshes")==0) uwTypeElement = GEO_C_xElementTMeshes; else if(strcmp(sAction,"ElementSpheres")==0) uwTypeElement = GEO_C_xElementSpheres; else if(strcmp(sAction,"ElementAlignedBoxes")==0) uwTypeElement = GEO_C_xElementAlignedBoxes; else if(strcmp(sAction,"ElementPoints")==0) uwTypeElement = GEO_C_xElementPoints; else if(strcmp(sAction,"ElementSprites")==0) uwTypeElement = GEO_C_xElementSprites; else if(strcmp(sAction,"ElementLines")==0) uwTypeElement = GEO_C_xElementLines; else if(strcmp(sAction,"ElementCones")==0) uwTypeElement = GEO_C_xElementCones; #ifdef USE_ALTIMAPS /*--- Marc FASCIA - Annecy - 12/02/1998 ---*/ else if(strcmp(sAction,"ElementAltimap")==0) uwTypeElement = GEO_C_xElementAltimap; #endif /*USE_ALTIMAPS*/ /* Lecture du graphique*/ p_stElement = (void *)LDT_LoadSection( szName ); assert(p_stElement != NULL); hObject->d_xListOfElementsTypes[xIndex] = uwTypeElement; hObject->d_stListOfElements[xIndex] = p_stElement; if( (LDT_iGetNbParams()==5) && (hObject->xNbElements>1) ) { ACP_tdxIndex xBoundingVolume = (ACP_tdxIndex)atoi( LDT_szGetParam( 4 ) ); if( (xBoundingVolume>=0) && (xBoundingVolumexNbElements) ) { GEO_vSetParallelBoxIndexOfElement(hObject,xIndex,xBoundingVolume); if( xBoundingVolume+1 > hObject->xNbParallelBoxes ) hObject->xNbParallelBoxes = xBoundingVolume+1; } } } break; case 'kooL' : /* LookAt */ { if ( stricmp (LDT_szGetParam( 1 ), "TRUE") ) hObject->ulType = GEO_C_LookAt ; else hObject->ulType = GEO_C_SemiLookAt ; } break; } } break; case ParseResult_EndSection: LDT_AddToRefsTable( g_hRefGeom, pLink, iGeometric_EndSection, 0 ); } } return 0; } /***************************************************************** Name: GLI_iCreateMod Description: Create callback for LDT Author: Mircea Petrescu Date: 6/25/98 Modified: *****************************************************************/ int GLI_iCreateMod( LDT_tdst_Link *pLink ) { GLI_tdstGeometricInfo *p_xGeometricInFile; p_xGeometricInFile = (GLI_tdstGeometricInfo*)malloc(sizeof(GLI_tdstGeometricInfo)); pLink->pObject=(void *)p_xGeometricInFile; return 0; } /***************************************************************** Name: GLI_iLoadMod Description: Load callback for LDT Author: Mircea Petrescu Date: 6/25/98 Modified: *****************************************************************/ int GLI_iLoadMod( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; GLI_tdstGeometricInfo *p_xGeometricInFile=(GLI_tdstGeometricInfo *)pLink->pObject; ACP_tdxIndex xNbGeometric=0; while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_BeginSection: { char *szType=LDT_szGetSectionType(); int iIsGeometric= (strcmpi( szType, "Geometric" )==0 ); ACP_tdxHandleOfObject hGeometric; void *p=LDT_LoadSection( NULL ); if( iIsGeometric ) { hGeometric=(ACP_tdxHandleOfObject)p; p_xGeometricInFile = (GLI_tdstGeometricInfo*)realloc(p_xGeometricInFile,++xNbGeometric*sizeof(GLI_tdstGeometricInfo)); strcpy(p_xGeometricInFile[xNbGeometric-1].a_cFileName,pLink->szFile); strcpy(p_xGeometricInFile[xNbGeometric-1].a_cSectionName,LDT_szGetSectionName()); p_xGeometricInFile[xNbGeometric-1].hObject=hGeometric; } } break; case ParseResult_EndSection: { pLink->pObject=(void *)p_xGeometricInFile; LDT_SetLinkValue( pLink, (long)xNbGeometric ); } break; } } return 0; } void GLI_vLoadMODFile(char *szPathName, char *szFileName, GLI_tdstGeometricInfo **h_xGeometricInFile, ACP_tdxIndex *p_xNbGeometric) { char buffer[256]; strcpy( buffer, szPathName ); strcat( buffer, "\\" ); strcat( buffer, szFileName ); *h_xGeometricInFile = (GLI_tdstGeometricInfo *)LDT_LoadSection( buffer ); *p_xNbGeometric = (ACP_tdxIndex)LDT_GetFileLong( 9 ); } /* Get File version*/ double GLI_dGetFileVersion(char *szGeometricFile) { double ret; ret=LDT_GetFileDouble(0); return ret; } /* Get Unite In Meter*/ double GLI_dGetUnitInMeterInFile(char *szGeometricFile) { double ret; ret=LDT_GetFileDouble(1); return ret; } void GLI_vInitLoad() { LDT_RegisterType( GLI_C_SectionTexture, LDT_Default_NULL_Create, GLI_iLoadTextureSection, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionGeometric, GLI_iCreateGeometric, GLI_iLoadGeometric, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionPhysical, GLI_iCreateGeometric, GLI_iLoadGeometric, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionSpecialEffect, GLI_iCreateGeometric, GLI_iLoadGeometric, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementIndexedTriangles, GLI_iCreateElementIndexedTriangles, GLI_iLoadElementIndexedTriangles, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementFaceMapDescriptors, GLI_iCreateElementFaceMapDescriptors, GLI_iLoadElementFaceMapDescriptors, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementSprites, GLI_iCreateElementSprites, GLI_iLoadElementSprites, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementLines, GLI_iCreateElementLines, GLI_iLoadElementLines, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementSpheres, GLI_iCreateElementSpheres, GLI_iLoadElementSpheres, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementAlignedBoxes, GLI_iCreateElementAlignedBoxes, GLI_iLoadElementAlignedBoxes, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementPoints, GLI_iCreateElementPoints, GLI_iLoadElementPoints, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionElementCones, GLI_iCreateElementCones, GLI_iLoadElementCones, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionVisualMaterial, GLI_iCreateMaterial, GLI_iLoadMaterial, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionFaceMapDescriptor, GLI_iCreateFaceMapDescriptor, GLI_iLoadFaceMapDescriptor, LDT_REG_SECTION ); LDT_RegisterType( GLI_C_SectionSprite, GLI_iCreateSprite, GLI_iLoadSprite, LDT_REG_SECTION ); LDT_RegisterType( "mod", GLI_iCreateMod, GLI_iLoadMod, LDT_REG_FILE ); g_hRefGeom=LDT_RegisterSolver( GLI_vPostProcessLDT, PostProcessPriority_MOD ); sprintf(szTexturePath,"."); GLI_vInitLinkTableOfGeometric(); }