/* *======================================================================================= * Name :Save.c * * Author : Date :25/04/97 * * Description : *======================================================================================= * Modification -> Author : Date : * Description : *======================================================================================= */ /*---------------------------------------------*/ #include "stdafx.h" #include "ACP_Base.h" #include "ITF.h" #include "GMT.h" #include "GEO.h" #include "GLI.h" #undef CPA_WANTS_IMPORT #undef CPA_EXPORT #define CPA_WANTS_EXPORT #include "OGD.h" #undef CPA_WANTS_EXPORT #define CPA_WANTS_IMPORT #include "save.h" /*---------------------------------------------*/ /* *======================================================================================= * GLOBALS *======================================================================================= */ /* char *g_szElementTypeName[] = { "", "IndexedTriangles", "FaceMapDescriptors", "Sprites", "TMeshes", "Points", "Lines", "Spheres", "AlignedBoxes", "Cones" }; */ /* *======================================================================================= * TYPEDEF *======================================================================================= */ typedef char xString[256]; /* *======================================================================================= * FUNCTIONS *======================================================================================= */ /* double GLI_dGetUnitInFile( SCR_tdst_File_Description *p_stFile ) { double dUnit = 1; SCR_M_RdL0_GetFileDouble( 0, 1,dUnit ); if (dUnit == 0) dUnit = 1.0; // return unit found return dUnit; } */ /* ---------------------------------------------------------------------------------------- Description : save a geometric object description p_stFile -> Script file description p_stGeometric -> pointer on geometric object that is to be saved ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveGeometricObject(SCR_tdst_File_Description *p_stFile, GEO_tdstGeometricObject *p_stGeometric, void *pEditorObject) { Geometry3D *pObject = (Geometry3D *)pEditorObject; CString csSectionName; xString mes, sFile, sAction, sIdent, sSection; char *p_cName; long i; double dUnit; // Get unit from script file dUnit = GLI_dGetUnitInFile( p_stFile ); // get section name of object // p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stGeometric); // if(p_cName == NULL) // return; // SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); // sprintf(sSection, "%s:%s", sAction, sIdent); csSectionName = pObject->GetCompleteSectionName(); SCR_fn_v_RdL0_SplitSectionName((char*)(LPCSTR) csSectionName, sFile, sAction, sIdent); SCR_fn_v_RdL0_ComputeSectionName(sSection, NULL, sAction, sIdent); // write beginning of section sprintf ( mes, "%d,%d,%d", p_stGeometric->xNbPoints, 0, //p_stGeometric->xNbEdges, p_stGeometric->xNbElements ); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // write list of points for(i=0; ixNbPoints; i++) { sprintf ( mes, "%d,%.6f,%.6f,%.6f,%.6f,%.6f,%.6f,%.1f,%.1f,%.1f", i, p_stGeometric->d_stListOfPoints[i].xX / dUnit, p_stGeometric->d_stListOfPoints[i].xY / dUnit, p_stGeometric->d_stListOfPoints[i].xZ / dUnit, p_stGeometric->d_stListOfPointsNormals[i].xX, p_stGeometric->d_stListOfPointsNormals[i].xY, p_stGeometric->d_stListOfPointsNormals[i].xZ, p_stGeometric->d_stListOfPointsReceivedLightIntensity[i].xR, p_stGeometric->d_stListOfPointsReceivedLightIntensity[i].xG, p_stGeometric->d_stListOfPointsReceivedLightIntensity[i].xB ); SCR_M_SvL0_SaveEntry(p_stFile, "AddVertex", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // write list of elements for(i=0; ixNbElements; i++) { p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stGeometric->d_stListOfElements[i]); if(p_cName == NULL) return; sprintf( mes, "%d,%s,%s", i, g_szElementTypeName[ p_stGeometric->d_xListOfElementsTypes[i] ], p_cName ); SCR_M_SvL0_SaveEntry(p_stFile, "AddElement", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // write end section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save visual material section p_stFile -> script file descriptor p_stMaterial -> pointer on material to save ---------------------------------------------------------------------------------------- */ void GLI_vSaveVisualMaterial(SCR_tdst_File_Description *p_stFile, ACP_tdxHandleOfMaterial hMaterial) { xString mes,sAction, sIdent, sSection, sFile; ACP_tdxIndex xType; char *p_cName; GEO_tdstColor stColor; long lSpecularExponent; GLI_tdstTexture *p_stTexture; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long) hMaterial); if(p_cName == NULL) return; /* * save beginning of section */ SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_EOL); /* * save type entry */ GLI_xGetMaterialType(hMaterial, &xType); if(xType == C_lGouraudElement) sprintf(mes, "Gouraud"); else if(xType == C_lGouraudElement - GLI_C_lIsGouraud) sprintf(mes, "Flat"); else sprintf(mes, "Gouraud"); SCR_M_SvL0_SaveEntry(p_stFile, "Type", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); /* * save ambient color */ GLI_xGetMaterialAmbientCoef ( hMaterial , &stColor ); sprintf ( mes, "%.6f,%.6f,%.6f", stColor.xR, stColor.xG, stColor.xB ); SCR_M_SvL0_SaveEntry(p_stFile, "AmbientColor", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); /* * save diffuse color */ GLI_xGetMaterialDiffuseCoef( hMaterial , &stColor ); sprintf ( mes, "%.6f,%.6f,%.6f", stColor.xR, stColor.xG, stColor.xB ); SCR_M_SvL0_SaveEntry(p_stFile, "DiffuseColor", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); /* * save specular color */ GLI_xGetMaterialSpecularCoef( hMaterial, &lSpecularExponent, &stColor ); sprintf ( mes, "%.6f,%.6f,%.6f,%.6f", stColor.xR, stColor.xG, stColor.xB, lSpecularExponent ); SCR_M_SvL0_SaveEntry(p_stFile, "SpecularColor", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); /* * save texture entry */ GLI_xGetMaterialTexture( hMaterial, &p_stTexture ); p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long) p_stTexture); if(p_cName != NULL) { SCR_M_SvL0_SaveEntry(p_stFile, "Texture", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, p_cName); } /* * save end of section */ SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /* ---------------------------------------------------------------------------------------- Description : save an element indexed triangles section p_stFile -> script file descriptor p_stElement -> pointer on element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementIndexedTriangle(SCR_tdst_File_Description *p_stFile, GEO_tdstElementIndexedTriangles *p_stElement) { xString mes, sFile, sAction, sIdent, sSection; char *p_cName; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // write section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d,%d", p_stElement->xNbFaces,p_stElement->xNbElementUV); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // saving material entry SCR_tdst_Link_Table *p_stTable = GMT_fn_p_stGetLinkTable(); p_cName = SCR_M_p_sz_Link_GetKey(SCR_fnp_st_Link_SearchValue(p_stTable, (unsigned long) p_stElement->hMaterial)); if(p_cName != NULL) { SCR_M_SvL0_SaveEntry(p_stFile, "Material", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, p_cName); } // saving faces for(i=0; ixNbFaces; i++) { sprintf ( mes, "%d,%d,%d,%d,%.6f,%.6f,%.6f,%d,%d,%d", i, p_stElement->d_stListOfFacesTripled[i].a3_xIndex[0], p_stElement->d_stListOfFacesTripled[i].a3_xIndex[1], p_stElement->d_stListOfFacesTripled[i].a3_xIndex[2], p_stElement->d_stListOfFacesNormals[i].xX, p_stElement->d_stListOfFacesNormals[i].xY, p_stElement->d_stListOfFacesNormals[i].xZ, p_stElement->d_stListOfFacesTripledIndexUV[i].a3_xIndex[0], p_stElement->d_stListOfFacesTripledIndexUV[i].a3_xIndex[1], p_stElement->d_stListOfFacesTripledIndexUV[i].a3_xIndex[2] ); SCR_M_SvL0_SaveEntry(p_stFile, "AddFaceUV", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // saving list of uv for(i=0; ixNbElementUV; i++) { sprintf ( mes, "%d,%.6f,%.6f", i, p_stElement->d_stListOfElementUV[i].xU, p_stElement->d_stListOfElementUV[i].xV ); SCR_M_SvL0_SaveEntry(p_stFile, "AddUV", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save a face map descriptor section p_stFile -> script file description hFMD -> pointer on face face descriptor ---------------------------------------------------------------------------------------- */ void GLI_vSaveFaceMapDescriptor(SCR_tdst_File_Description *p_stFile, GEO_tdstFaceMapDescriptor *hFMD) { xString mes, sFile, sAction, sIdent, sSection; char *p_cName; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)hFMD); if(p_cName == NULL) return; /* * save beginning of section */ SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_EOL); /* * save pointedSector or material entry */ p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)hFMD->hMaterial); if(p_cName != NULL) { SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, NULL); if(strcmp(sAction, "Sector") == 0) { SCR_M_SvL0_SaveEntry(p_stFile, "PointedSector", SCR_CC_C_Cfg_NoChar); } else { SCR_M_SvL0_SaveEntry(p_stFile, "Material", SCR_CC_C_Cfg_NoChar); } SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, p_cName); } /* * save triplde index entry */ sprintf ( mes, "%.6f,%.6f,%.6f,%.6f,%.6f,%.6f", hFMD->stUVValues[0].xU, hFMD->stUVValues[0].xV, hFMD->stUVValues[1].xU, hFMD->stUVValues[1].xV, hFMD->stUVValues[2].xU, hFMD->stUVValues[2].xV ); SCR_M_SvL0_SaveEntry(p_stFile, "TripledUV", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); /* * save end of section */ SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /* ---------------------------------------------------------------------------------------- Description : saving face map descriptors element p_stFile -> script file descriptor p_stElement -> pointer on element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementFaceMapDescriptors(SCR_tdst_File_Description *p_stFile, GEO_tdstElementFaceMapDescriptors *p_stElement) { xString mes, sSection, sAction, sIdent, sFile; char *p_cName; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbFaces); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save each face for(i=0; ixNbFaces; i++) { p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement->d_stListOfFacesQuadrupled[i].hFaceMapDescriptor); if(p_cName == NULL) return; sprintf ( mes, "%d,%d,%d,%d,%.6f,%.6f,%.6f,%s", i, p_stElement->d_stListOfFacesQuadrupled[i].stFaceTripled.a3_xIndex[0], p_stElement->d_stListOfFacesQuadrupled[i].stFaceTripled.a3_xIndex[1], p_stElement->d_stListOfFacesQuadrupled[i].stFaceTripled.a3_xIndex[2], p_stElement->d_stListOfFacesNormals[i].xX, p_stElement->d_stListOfFacesNormals[i].xY, p_stElement->d_stListOfFacesNormals[i].xZ, p_cName ); SCR_M_SvL0_SaveEntry(p_stFile, "AddFaceFMD", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : saving a sprite section p_hFile -> script file descriptor hSprite -> pointer on sprite to save ---------------------------------------------------------------------------------------- */ void GLI_vSaveSprite(SCR_tdst_File_Description *p_stFile, GEO_tdstSprite *hSprite) { xString sFile, sAction, sIdent, sSection, sType, mes; long i; char *p_cName; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)hSprite); if(p_cName == NULL) return; /* * save section beginning */ SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_EOL); /* * save each sprite */ for(i=0; i< hSprite->xNbSprites; i++) { /* * save material entry */ p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)hSprite->d_hMaterial[i]); if(p_cName != NULL) { SCR_M_SvL0_SaveEntry(p_stFile, "AddMaterial", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, p_cName); } /* * get 2DScale type */ if( hSprite->d_xSpriteDrawMode[i] == (GEO_C_lSpriteDrawMode2DScaled | GEO_C_lSpriteDrawMode2DRotativ) ) sprintf(sType,"2DScaled"); else sprintf(sType,"2DNonScaled"); /* * save add info entry */ sprintf ( mes, "%d,%s,%.6f,%.6f,%.6f,%.6f,%.6f", i, sType, hSprite->d_xThresholds[i], hSprite->d_xSizeOfSprite[i].xX, hSprite->d_xSizeOfSprite[i].xY, hSprite->d_xDisplacementOfSprite[i].xX, hSprite->d_xDisplacementOfSprite[i].xY ); SCR_M_SvL0_SaveEntry(p_stFile, "AddInfo", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } /* * save end of section */ SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /* ---------------------------------------------------------------------------------------- Description : saving element sprites section p_stFile -> script file descriptor p_stElement -> pointer on sprites element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementSprites(SCR_tdst_File_Description *p_stFile, GEO_tdstElementSprite *p_stElement) { xString mes, sAction, sIdent, sSection, sFile; char *p_cName; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbSprites); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save each sprites for(i=0; ixNbSprites; i++) { p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement->d_stListOfSprites[i].hSprite); if(p_cName == NULL) return; sprintf ( mes, "%d,%d,%.6f,%.6f,%s", i, p_stElement->d_stListOfSprites[i].xCenterPoint, p_stElement->d_stListOfSprites[i].stSize.xX, p_stElement->d_stListOfSprites[i].stSize.xY, p_cName ); SCR_M_SvL0_SaveEntry(p_stFile, "AddSprite", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save a TMeshes element section p_stFile -> script file descriptor p_stElement -> pointer on TMeshes element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementTMeshes(SCR_tdst_File_Description *p_stFile, GEO_tdstElementTMeshes *p_stElement) { } */ /* ---------------------------------------------------------------------------------------- Description : save a point element section p_stFile -> script file descriptor p_stElement -> pointer on a Points Element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementPoints(SCR_tdst_File_Description *p_stFile, GEO_tdstElementPoints *p_stElement) { xString mes, sAction, sIdent, sSection, sFile; char *p_cName; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbPoints); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save fatness entry sprintf(mes, "%.6f", p_stElement->xFatness); SCR_M_SvL0_SaveEntry(p_stFile, "Fatness", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save list of points for(i=0; ixNbPoints; i++) { sprintf(mes, "%d,%d", i, p_stElement->d_xListOfPointIndex[i]); SCR_M_SvL0_SaveEntry(p_stFile, "AddPoint", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save an element lines section p_stFile -> script file descriptor p_stElement -> pointer on lines element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementLines(SCR_tdst_File_Description *p_stFile, GEO_tdstElementLines *p_stElement) { xString mes, sAction, sIdent, sSection, sFile; char *p_cName; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbLines); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save thickness entry sprintf(mes, "%.6f", p_stElement->xThickness); SCR_M_SvL0_SaveEntry(p_stFile, "Thickness", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save list of lines for(i=0; ixNbLines; i++) { sprintf ( mes, "%d,%d,%d", i, p_stElement->d_stListOfLineIndex[i].a2_xIndex[0], p_stElement->d_stListOfLineIndex[i].a2_xIndex[1] ); SCR_M_SvL0_SaveEntry(p_stFile, "AddLine", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // Save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save spheres element section p_stFile -> script file descriptor p_stElement -> pointer on spheres element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementSpheres(SCR_tdst_File_Description *p_stFile, GEO_tdstElementSpheres *p_stElement) { xString mes, sFile, sAction, sIdent, sSection; char *p_cName; char szDefaultMaterial[] = "DefaultMaterial"; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbSpheres); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save list of spheres for(i=0; ixNbSpheres; i++) { p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement->d_stListOfSpheres[i].hMaterial); if(p_cName == NULL) p_cName = szDefaultMaterial; sprintf ( mes, "%d,%d,%.6f,%s", i, p_stElement->d_stListOfSpheres[i].xCenterPoint, p_stElement->d_stListOfSpheres[i].xRadius, p_cName ); SCR_M_SvL0_SaveEntry(p_stFile, "AddSphere", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save an aligned boxes element section p_stFile -> script file descriptor p_stElement -> pointer on element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementAlignedBox(SCR_tdst_File_Description *p_stFile, GEO_tdstElementAlignedBoxes *p_stElement) { xString mes, sFile, sAction, sIdent, sSection; char *p_cName; char szDefaultMaterial[] = "DefaultMaterial"; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbAlignedBoxes); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save list of aligned boxes for(i=0; ixNbAlignedBoxes; i++) { p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement->d_stListOfAlignedBoxes[i].hMaterial); if(p_cName == NULL) p_cName = szDefaultMaterial; sprintf ( mes, "%d,%d,%d,%s", i, p_stElement->d_stListOfAlignedBoxes[i].xMinPoint, p_stElement->d_stListOfAlignedBoxes[i].xMaxPoint, p_cName ); SCR_M_SvL0_SaveEntry(p_stFile, "AddAlignedBox", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* ---------------------------------------------------------------------------------------- Description : save cone element section p_stFile -> script file descriptor p_stElement -> pointer on cones element ---------------------------------------------------------------------------------------- */ /* void GLI_vSaveElementCones(SCR_tdst_File_Description *p_stFile, GEO_tdstElementCones *p_stElement) { xString mes, sFile, sAction, sIdent, sSection; char *p_cName; long i; p_cName = GLI_p_cSearchValueInLinkTableOfGeometric((unsigned long)p_stElement); if(p_cName == NULL) return; // save section beginning SCR_fn_v_RdL0_SplitSectionName(p_cName, sFile, sAction, sIdent); sprintf(sSection, "%s:%s", sAction, sIdent); sprintf(mes, "%d", p_stElement->xNbCones); SCR_M_SvL0_SaveBeginSection(p_stFile, sSection, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); // save list of cones for(i=0; ixNbCones; i++) { sprintf ( mes, "%d,%d,%d,%d", i, p_stElement->d_stListOfCones[i].xTopPoint, p_stElement->d_stListOfCones[i].xBasePoint, p_stElement->d_stListOfCones[i].xBaseRadius ); SCR_M_SvL0_SaveEntry(p_stFile, "AddCone", SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } // save end of section SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } */ /* *======================================================================================= * CALL BACK for NOTIFICATION *======================================================================================= */ /* ---------------------------------------------------------------------------------------- Description : call back for Geometric object notification ---------------------------------------------------------------------------------------- */ /* void OGD_fn_vSaveGeometricObject( SCR_tdst_File_Description *p_stFile, char *p_szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction) { Geometry3D *p_oObject = (Geometry3D *) p_vData; ACP_tdxHandleOfObject hObject = (ACP_tdxHandleOfObject) p_oObject->GetEngineStruct(); if (eAction == SCR_EA_Ntfy_AddSection) { // go to end of file (we need all file directive to load this section) SCR_fn_v_SvL1_ToEndSection(p_stFile); SCR_M_SvL0_SaveBlankLine (p_stFile); } if ( (eAction == SCR_EA_Ntfy_RebuildSection) || (eAction == SCR_EA_Ntfy_AddSection) ) { GLI_vSaveGeometricObject( p_stFile, hObject, p_vData ); } } */ /* ---------------------------------------------------------------------------------------- Description : call back for Geometric object element notification ---------------------------------------------------------------------------------------- */ /* void OGD_fn_vSaveGeometricObjectElement( SCR_tdst_File_Description *p_stFile, char *p_szSectionName, void *p_vData, SCR_tde_Ntfy_Action eAction) { char *p_szActionName = strchr( p_szSectionName, '^' ); char *p_szName = strchr( p_szSectionName, ':' ); ACP_tdxIndex xElementType; if (eAction == SCR_EA_Ntfy_AddSection) { // go to end of file (we need all file directive to load this section) SCR_fn_v_SvL1_ToEndSection(p_stFile); SCR_M_SvL0_SaveBlankLine (p_stFile); } //assert( p_szActionName != NULL ); //assert( p_szName != NULL ); p_szActionName+= strlen( "^Element" ); *p_szName = 0; // finding element type from action name for (xElementType = 0; xElementType < 10; xElementType ++) { if (strcmp( p_szActionName, g_szElementTypeName[xElementType]) == 0) break; } //assert( xElementType < 10 ); switch (xElementType) { case GEO_C_xElementIndexedTriangles: GLI_vSaveElementIndexedTriangle(p_stFile, (GEO_tdstElementIndexedTriangles *) p_vData); break; case GEO_C_xElementFaceMapDescriptors: GLI_vSaveElementFaceMapDescriptors(p_stFile, (GEO_tdstElementFaceMapDescriptors *) p_vData); break; case GEO_C_xElementSprites: GLI_vSaveElementSprites(p_stFile, (GEO_tdstElementSprite *) p_vData); break; case GEO_C_xElementTMeshes: GLI_vSaveElementTMeshes(p_stFile, (GEO_tdstElementTMeshes *) p_vData); break; case GEO_C_xElementPoints: GLI_vSaveElementPoints(p_stFile, (GEO_tdstElementPoints *) p_vData); break; case GEO_C_xElementLines: GLI_vSaveElementLines(p_stFile, (GEO_tdstElementLines *) p_vData); break; case GEO_C_xElementSpheres: GLI_vSaveElementSpheres(p_stFile, (GEO_tdstElementSpheres *) p_vData); break; case GEO_C_xElementAlignedBoxes: GLI_vSaveElementAlignedBox(p_stFile, (GEO_tdstElementAlignedBoxes *) p_vData); break; case GEO_C_xElementCones: GLI_vSaveElementCones(p_stFile, (GEO_tdstElementCones *) p_vData); break; } } */