/*========================================================================= * * ModSave.h - Saving functions for MOD file * * Version 1.0 * Revision date * *=======================================================================*/ #include "ModSave.h" #include "conventi.h" #include "defines.h" #include "main.h" #include "print.h" #include "system.h" #include "ModLib.h" #include "PhySave.h" #include "SpoSave.h" #include "VseSave.h" #include "ZooSave.h" #include "Altimaps.h" //--- Global statics -------------------------------------------------------- static char *gs_a_szElementTypeName[] = { "", M_IndexedTriangles, M_FaceMapDescriptors, M_Sprites, M_TMeshes, M_Points, M_Lines, M_Spheres, M_AlignedBoxes, M_Cones, M_Altimap, M_MegaFace }; //--- Global extern -------------------------------------------------------- char g_szInstancesSaved[200][256]; int g_iNbInstancesSaved = 0; //--- header functions -------------------------------------------------------- void MLT_vSaveEmptyModHeader(SCR_tdst_File_Description *p_stFile, char *sFileName, void *p_vPtr, SCR_tde_Ntfy_Action xAction) { } //-------------------------------------------------------------------- /**************************************************************************** * Description: save geometric object * * Parameters: p_stFile : script file pointer * p_stGeometric : geometric object * bPhy : flag to save PHY * bTbl : flag to save TBL * bZoo : flag to save ZOO * bVse : flag to save VSE *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveGeometricObject (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstGeometricObject *p_stGeometric, BOOL bPhy, BOOL bTbl, BOOL bZoo, BOOL bVse) { long lNoPhy, lNoLod; long i; MLT_tdstGeometricObject *p_stObjOrg; MLT_tdstElementAltimap *p_stAltimap; ACP_tdxIndex xIndexOfParallelBox; xString sSection, sFileOut; xString mes, sComment; xString sFile2, sIdent2; xString sFile, sAction, sIdent; xString sForme, sHabillage, sName; BOOL bTest; BOOL bAltimap = TRUE; char *sName1, *p_Char1, *p_char; int iX=0, iY=0, iZ=0; if(p_stGeometric == NULL) return; if(p_stGeometric->bNotForSave) return; // Rayman2 version : no more GoThrough if ((g_bRaymanII)&&(strstr(p_stGeometric->sName, "Gothrough"))) return; //don't save anymore the frtb objects if(strlen(p_stGeometric->sPhysicalSection) != 0) { // save TBL if(bTbl) { sprintf(sFile, "%s.tbl", g_sFileIn); sprintf(mes, "%d", p_stGeometric->lNumberInTable); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, M_Tbl, mes); SCR_fn_v_SvL1_RegisterNotify(sSection, MLT_vSaveTbl, p_stGeometric, SCR_EA_Ntfy_AddSection); } // save PHY if(bPhy) { SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sPhysicalSection, sFile, sAction, sIdent); sprintf(sIdent2, "PO_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, sAction, sIdent2); SCR_fn_v_SvL1_RegisterNotify(sSection, MLT_vSavePhy, p_stGeometric, SCR_EA_Ntfy_AddOrModifySection); } // save ZOO if(bZoo) { SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sName, sFile, sAction, sIdent2); SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sPhysicalSection, sFile, sAction, sIdent); if (strcmp(sIdent, sIdent2)) bTest = TRUE; else bTest = FALSE; sprintf(sFile2, "%s.zoo", g_sFileIn); SCR_fn_v_RdL0_ComputeSectionName(sFile, sFile2, M_AllCollideSets, ""); sprintf(sFile2, "%s", sFile, SCR_CC_sz_Cfg_SectionIdMark); sprintf(sIdent2, "CS_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile2, M_CS, sIdent2); SCR_fn_v_SvL1_RegisterNotify(sFile, MLT_vSaveAllCollideSetsSection, NULL, SCR_EA_Ntfy_AddOrModifySection); SCR_fn_v_SvL1_RegisterNotify(sSection, MLT_vSaveZoo, p_stGeometric, SCR_EA_Ntfy_AddOrModifySection); } // save VSE if(bVse) { SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sPhysicalSection, sFile, sAction, sIdent); sprintf(sFile, "%s.vse", g_sFileIn); MLT_vSplitModuleSectionName(sIdent, sForme, sHabillage, &lNoPhy, &lNoLod, sName); MLT_vComputeVisualSetSectionName(sIdent, sForme, sHabillage, sName); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, M_VS, sIdent); p_stGeometric->lNbLod = MLT_lSaveLodInFile(sSection); sprintf(sIdent2, "VSE_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, M_VS, sIdent2); SCR_fn_v_SvL1_RegisterNotify(sSection, MLT_vSaveVisualSet, p_stGeometric, SCR_EA_Ntfy_AddOrModifySection); } } sprintf(sFileOut, "%s.mod", g_sFileIn); SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sName, sFile, sAction, sIdent); // find object in lib p_stObjOrg = MLT_pFindAlmostInLib(p_stGeometric->sName); if (p_stObjOrg == NULL) { MLT_vOutput( C_ComRes_cErrorLine, "\nError : Can't find %s", p_stGeometric->sName); } // check coherence if ((p_stObjOrg != p_stGeometric)&&(!bTest)) { if( (p_stObjOrg->xNbPoints != p_stGeometric->xNbPoints) ) { MLT_vOutput( C_ComRes_cWarningLine, "\nWarning : Not the same object %s : %s", p_stObjOrg->sName, p_stGeometric->sName); } else { sprintf(p_stGeometric->sPointsOf, "%s", p_stObjOrg->sName); } } // check if this object is an instance if((p_char=strstr(sIdent, "=")) != NULL) { strcpy(p_char, "\0"); for (i=0; isName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stGeometric->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stGeometric->sName)); if((p_char=strstr(sName1, "=")) != NULL) strcpy(p_char, "\0"); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else { sName1 = MLT_p_cGetSectionName(p_stGeometric->sName); if((p_char=strstr(sName1, "=")) != NULL) strcpy(p_char, "\0"); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } // test altimap structure if (p_stGeometric->iFlags & ~IS_NOT_ALTIMAP & MAYBE_ALTIMAP) { p_stAltimap = (MLT_tdstElementAltimap*)malloc(sizeof(MLT_tdstElementAltimap)); MLT_vCompleteAltimapStructure(p_stGeometric, p_stAltimap); bAltimap = FALSE; } if (p_stGeometric->iFlags & IS_NOT_ALTIMAP) { MLT_vOutput( C_ComRes_cWarningLine, "\nWarning : %s is not an altimap, even if its name contains #ALT or #alt suffix.", p_stGeometric->sName); bAltimap = TRUE; } // normal object if (!bAltimap) { SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%d,%d",0,0,1); if(strlen(p_stGeometric->sComment) != 0) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionComment, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, p_stGeometric->sComment); } if(strlen(p_stGeometric->sComment) == 0) { if (MLT_bTestSymmetry(p_stGeometric) && (p_stGeometric->iFlags & MAYBE_SYM)) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionComment, SCR_CC_C_Cfg_NoChar); sprintf(sComment, "#Sym(%c,%.0f)", p_stGeometric->cGeom, p_stGeometric->fGeom); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, sComment); } if (!MLT_bTestSymmetry(p_stGeometric) && (p_stGeometric->iFlags & MAYBE_SYM)) MLT_vOutput( C_ComRes_cWarningLine, "\nWarning : %s is not symmetric with the given plane.", p_stGeometric->sName); if (p_stGeometric->iFlags & IS_LOOKAT) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionLookAt, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, "FALSE"); } if (p_stGeometric->iFlags & IS_SEMI_LA) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionLookAt, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, "TRUE"); } } SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sName, sFile, sAction, sIdent); if(stricmp(sFile, sFileOut)==0) sprintf(sFile, "*"); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, M_ElementAltimap, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddElement, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%s,%s", 0, M_Altimap, sSection); SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); SCR_fn_v_RdL0_ComputeSectionName(p_stAltimap->sName, sFileOut, M_ElementAltimap, sIdent); MLT_vSaveElementAltimap(p_stFile, p_stAltimap); MLT_vFreeAltimap(p_stAltimap); } // altimap object else { SCR_fn_v_SvL0_SaveParameters_MP (p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%d,%d", p_stGeometric->xNbPoints, 0, p_stGeometric->xNbElements); if(strlen(p_stGeometric->sComment) != 0) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionComment, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, p_stGeometric->sComment); } if(strlen(p_stGeometric->sComment) == 0) { if (MLT_bTestSymmetry(p_stGeometric) && (p_stGeometric->iFlags & MAYBE_SYM)) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionComment, SCR_CC_C_Cfg_NoChar); sprintf(sComment, "#Sym(%c,%.0f)", p_stGeometric->cGeom, p_stGeometric->fGeom); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, sComment); } if (!MLT_bTestSymmetry(p_stGeometric) && (p_stGeometric->iFlags & MAYBE_SYM)) MLT_vOutput( C_ComRes_cWarningLine, "\nWarning : %s is not symmetric with the given plane.", p_stGeometric->sName); if (p_stGeometric->iFlags & IS_LOOKAT) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionLookAt, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, "FALSE"); } if (p_stGeometric->iFlags & IS_SEMI_LA) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionLookAt, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, "TRUE"); } } if(strlen(p_stGeometric->sPointsOf) != 0) { SCR_fn_v_RdL0_SplitSectionName(p_stGeometric->sPointsOf, sFile, sAction, sIdent); if(stricmp(sFile, sFileOut)==0) sprintf(sFile, "*"); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, sAction, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionGetVertices, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, sSection); } else { for(i=0; ixNbPoints; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddVertex, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 11, "%d,%.6f,%.6f,%.6f,%.6f,%.6f,%.6f,%.1f,%.1f,%.1f", i, p_stGeometric->d_stListOfPoints[i].xX, p_stGeometric->d_stListOfPoints[i].xY, p_stGeometric->d_stListOfPoints[i].xZ, 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); } } for(i=0; ixNbElements; i++) { typedef struct MLT_tdstElementBidon_ { xString sName; ACP_tdxIndex xIndexOfParallelBox; } MLT_tdstElementBidon; if(p_stGeometric->d_xListOfElementsTypes[i] == -1) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionGetElement, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP ( p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%s,%d", i, p_stGeometric->sElementOf[i], p_stGeometric->sIndexOf[i] ); } else { SCR_fn_v_RdL0_SplitSectionName ( ((MLT_tdstElementBidon*)(p_stGeometric->d_stListOfElements[i]))->sName, sFile, sAction, sIdent ); if(stricmp(sFile, sFileOut)==0) sprintf(sFile, "*"); if (strstr(sIdent, "!nocol") || strstr(sIdent, "!NOCOL")) { sName1 = MLT_vRemoveFromName(sIdent); strcpy(sIdent, sName1); } p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, sAction, sIdent); xIndexOfParallelBox = ((MLT_tdstElementBidon*)(p_stGeometric->d_stListOfElements[i]))->xIndexOfParallelBox; SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddElement, SCR_CC_C_Cfg_NoChar); if (xIndexOfParallelBox == -1) { SCR_fn_v_SvL0_SaveParameters_MP ( p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%s,%s", i, gs_a_szElementTypeName[p_stGeometric->d_xListOfElementsTypes[i]], sSection ); } else { SCR_fn_v_SvL0_SaveParameters_MP ( p_stFile, SCR_EF_SvL0_Scanf, 5, "%d,%s,%s,%d", i, gs_a_szElementTypeName[p_stGeometric->d_xListOfElementsTypes[i]], sSection, xIndexOfParallelBox ); } } } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); for(i=0; ixNbElements; i++) { switch(p_stGeometric->d_xListOfElementsTypes[i]) { case MLT_C_xElementIndexedTriangles: MLT_vSaveElementIndexedTriangle(p_stFile, (MLT_tdstElementIndexedTriangles*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementFaceMapDescriptors: MLT_vSaveElementFaceMapDescriptors(p_stFile, (MLT_tdstElementFaceMapDescriptors*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementSprites: MLT_vSaveElementSprites(p_stFile, (MLT_tdstElementSprite*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementTMeshes: MLT_vSaveElementTMeshes(p_stFile, (MLT_tdstElementTMeshes*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementPoints: MLT_vSaveElementPoints(p_stFile, (MLT_tdstElementPoints*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementLines: MLT_vSaveElementLines(p_stFile, (MLT_tdstElementLines*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementSpheres: MLT_vSaveElementSpheres(p_stFile, (MLT_tdstElementSpheres*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementAlignedBoxes: MLT_vSaveElementAlignedBox(p_stFile, (MLT_tdstElementAlignedBoxes*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementCones: MLT_vSaveElementCones(p_stFile, (MLT_tdstElementCones*)(p_stGeometric->d_stListOfElements[i])); break; case MLT_C_xElementMegaFace: MLT_vSaveElementMegaFace(p_stFile, (MLT_tdstElementMegaFace*)(p_stGeometric->d_stListOfElements[i])); break; } } } } /**************************************************************************** * Description: save indexed triangle element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementIndexedTriangle (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementIndexedTriangles *p_stElement) { xString mes, sFile, sAction, sIdent, sIdent2; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 3, "%d,%d", p_stElement->xNbFaces, p_stElement->xNbElementUV); if(strlen(p_stElement->sMaterial) != 0) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s%s.gmt", g_sDirectorySave, g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_GameMaterial, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionMaterial, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); SCR_fn_v_RdL0_SplitSectionName(p_stElement->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s.gmt", g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_GameMaterial, sIdent); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveGameMaterial, p_stElement->hMaterial, SCR_EA_Ntfy_AddOrModifySection); SCR_fn_v_RdL0_SplitSectionName(p_stElement->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s.vmt", g_sFileMaterial); sprintf(sIdent2, "MAT_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Material, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveVisualMaterial, p_stElement->hMaterial, SCR_EA_Ntfy_AddOrModifySection); for(i=0;ihMaterial->lTexture;i++) { p_stElement->hMaterial->lCurTexture = 0; sprintf(sFile, "%s.tex", g_sFileMaterial); sprintf(sIdent2, "TEX_%s", MLT_p_cEraseSpace(MLT_p_cGetFileNameWithoutExt(MLT_p_cGetFileNameWithoutPath(p_stElement->hMaterial->sTexture[i])))); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, p_stElement->hMaterial, SCR_EA_Ntfy_AddOrModifySection); } // multitextures for(i=0;ihMaterial->lMultiTexture;i++) { p_stElement->hMaterial->lCurTexture = 0; if (!g_bExistTex) //the .tex file doesn't exist sprintf(sFile, "%s.tex", g_sFileMaterial); else { if (g_bIgnoreTex) { if (g_bLevelConversion) sprintf(sFile, "%s\\World\\levels\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bBankConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\banks\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bClassConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\classes\\%stemp.tex", g_sGameData, g_sDirectorySave); } else sprintf(sFile, "%s.tex", g_sFileMaterial); } sprintf(sIdent2, "%s", p_stElement->hMaterial->stMultiTexture[i].sTexture); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, p_stElement->hMaterial, SCR_EA_Ntfy_AddOrModifySection); } } if(strlen(p_stElement->sSectorName) != 0) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->sSectorName, sFile, sAction, sIdent); sprintf(sFile, "%s%s.spo", g_sDirectorySave, g_sFileIn); sprintf(sAction, M_SuperObject); sprintf(sIdent2, "SPO_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, sAction, sIdent2); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionPointedSector, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } if(strlen(p_stElement->sFacesOf) != 0) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionGetFaces, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, p_stElement->sFacesOf); } else { for(i=0; ixNbFaces; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddFaceUV, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 11, "%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]); } } if(strlen(p_stElement->sUVsOf) != 0) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionGetUVs, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, p_stElement->sUVsOf); } else { for(i=0; ixNbElementUV; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddUV, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%.6f,%.6f", i, p_stElement->d_stListOfElementUV[i].xU, p_stElement->d_stListOfElementUV[i].xV); } } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save face map descriptor element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementFaceMapDescriptors(SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementFaceMapDescriptors *p_stElement) { xString sSection, sFile, sAction, sIdent, sFileOut; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); sprintf(sFileOut, "%s.mod", g_sFileIn); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbFaces); for(i=0; ixNbFaces; i++) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_stListOfFacesQuadrupled[i].hFaceMapDescriptor->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); if (strstr(sIdent, "!nocol") || strstr(sIdent, "!NOCOL")) { sName1 = MLT_vRemoveFromName(sIdent); strcpy(sIdent, sName1); } if(stricmp(sFile, sFileOut)==0) sprintf(sFile, "*"); else sprintf(sFile, "%s%s.mod", g_sDirectorySave, g_sFileIn); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, sAction, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddFaceFMD, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 9, "%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, sSection); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); for(i=0; ixNbFaces; i++) { MLT_vSaveFaceMapDescriptor(p_stFile, p_stElement->d_stListOfFacesQuadrupled[i].hFaceMapDescriptor); } } /**************************************************************************** * Description: save sprite element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementSprites(SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementSprite *p_stElement) { xString sSection, sFile, sAction, sIdent, sFileOut; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); sprintf(sFileOut, "%s.mod", g_sFileIn); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbSprites); for(i=0; ixNbSprites; i++) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_stListOfSprites[i].hSprite->sName, sFile, sAction, sIdent); if(stricmp(sFile, sFileOut)==0) sprintf(sFile, "*"); else sprintf(sFile, "%s%s.mod", g_sDirectorySave, g_sFileIn); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); if (strstr(sIdent, "!nocol") || strstr(sIdent, "!NOCOL")) { sName1 = MLT_vRemoveFromName(sIdent); strcpy(sIdent, sName1); } SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, sAction, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddSprite, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 6, "%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, sSection); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); for(i=0; ixNbSprites; i++) { MLT_vSaveSprite(p_stFile, p_stElement->d_stListOfSprites[i].hSprite); } } /**************************************************************************** * Description: save line element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementLines(SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementLines *p_stElement) { xString sFile, sAction, sIdent; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbLines); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionThickness, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%.6f", p_stElement->xThickness); for(i=0; ixNbLines; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddLine, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%d,%d", i, p_stElement->d_stListOfLineIndex[i].a2_xIndex[0], p_stElement->d_stListOfLineIndex[i].a2_xIndex[1]); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save sphere element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementSpheres (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementSpheres *p_stElement) { xString sFile, sAction, sIdent; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbSpheres); for(i=0; ixNbSpheres; i++) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_stListOfSpheres[i].sMaterial, sFile, sAction, sIdent); sprintf(sFile, "Ed.gmt"); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->d_stListOfSpheres[i].sMaterial, sFile, M_GameMaterial, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddSphere, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 5, "%d,%d,%.6f,%s", i, p_stElement->d_stListOfSpheres[i].xCenterPoint, p_stElement->d_stListOfSpheres[i].xRadius, p_stElement->d_stListOfSpheres[i].sMaterial); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save aligned box element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementAlignedBox(SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementAlignedBoxes *p_stElement) { xString mes, sFile, sAction, sIdent, sSection, sIdent2; char *sName1, *p_Char1; long i, j; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbAlignedBoxes); for(i=0; ixNbAlignedBoxes; i++) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_stListOfAlignedBoxes[i].sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s%s.gmt", g_sDirectorySave, g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, M_GameMaterial, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddAlignedBox, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 5, "%d,%d,%d,%s", i, p_stElement->d_stListOfAlignedBoxes[i].xMinPoint, p_stElement->d_stListOfAlignedBoxes[i].xMaxPoint, sSection); SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_stListOfAlignedBoxes[i].sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s.gmt", g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_GameMaterial, sIdent); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveGameMaterial, p_stElement->d_stListOfAlignedBoxes[i].hMaterial, SCR_EA_Ntfy_AddOrModifySection); SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_stListOfAlignedBoxes[i].sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s.vmt", g_sFileMaterial); sprintf(sIdent2, "MAT_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Material, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveVisualMaterial, p_stElement->d_stListOfAlignedBoxes[i].hMaterial, SCR_EA_Ntfy_AddOrModifySection); for(j=0;jd_stListOfAlignedBoxes[i].hMaterial->lTexture;j++) { p_stElement->d_stListOfAlignedBoxes[i].hMaterial->lCurTexture = 0; sprintf(sFile, "%s.tex", g_sFileMaterial); sprintf(sIdent2, "TEX_%s", MLT_p_cEraseSpace(MLT_p_cGetFileNameWithoutExt(MLT_p_cGetFileNameWithoutPath(p_stElement->d_stListOfAlignedBoxes[i].hMaterial->sTexture[j])))); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, p_stElement->d_stListOfAlignedBoxes[i].hMaterial, SCR_EA_Ntfy_AddOrModifySection); } // multitextures for(j=0;jd_stListOfAlignedBoxes[i].hMaterial->lMultiTexture;j++) { p_stElement->d_stListOfAlignedBoxes[i].hMaterial->lCurTexture = 0; if (!g_bExistTex) //the .tex file doesn't exist sprintf(sFile, "%s.tex", g_sFileMaterial); else { if (g_bIgnoreTex) { if (g_bLevelConversion) sprintf(sFile, "%s\\World\\levels\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bBankConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\banks\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bClassConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\classes\\%stemp.tex", g_sGameData, g_sDirectorySave); } else sprintf(sFile, "%s.tex", g_sFileMaterial); } sprintf(sIdent2, "%s", p_stElement->d_stListOfAlignedBoxes[i].hMaterial->stMultiTexture[j].sTexture); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, p_stElement->d_stListOfAlignedBoxes[i].hMaterial, SCR_EA_Ntfy_AddOrModifySection); } } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save cone element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementCones(SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementCones *p_stElement) { xString sFile, sAction, sIdent; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbCones); for(i=0; ixNbCones; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddCone, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 5, "%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_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save point element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementPoints (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementPoints *p_stElement) { xString mes, sFile, sAction, sIdent; char *sName1, *p_Char1; long i; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->xNbPoints); sprintf(mes, "%.6f", p_stElement->xFatness); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionFatness, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 3, "%.6f", p_stElement->xFatness); for(i=0; ixNbPoints; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddPoint, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 3, "%d,%d", i, p_stElement->d_xListOfPointIndex[i]); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save Mesh element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementTMeshes (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementTMeshes *p_stElement) { } /**************************************************************************** * Description: save Altimap element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementAltimap (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementAltimap *p_stElement) { int i, j, k; char *sName1, *p_Char1; xString szMes; xString sFile, sAction, sIdent; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); // save the parameters for the altimap if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 5, "%d,%d,%d,%d", p_stElement->xNbVertexes, p_stElement->xNbSquares, p_stElement->xNbFaces, p_stElement->xNbElementUV); //save the origin parameters SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionOrigin, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%.6f,%.6f,%.6f", p_stElement->stOrigin.xX, p_stElement->stOrigin.xY, p_stElement->stOrigin.xZ); //save the Width, Height, DeltaX, DeltaY for the square SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionSquarePattern, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 5, "%d,%.6f,%d,%.6f", p_stElement->xWidth, p_stElement->xDeltaX, p_stElement->xDepth, p_stElement->xDeltaY); //for all vertexes save the Z and normals for(i=0; ixNbVertexes; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionSetVertex, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 6, "%d,%.6f,%.6f,%.6f,%.6f", i, p_stElement->d_xHeight[i], p_stElement->d_stPointNormals[i].xX, p_stElement->d_stPointNormals[i].xY, p_stElement->d_stPointNormals[i].xZ); } k=0; //for every square save the type and the first index triangle for it for(i=0; ixNbSquares; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionSetSquare, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%d,%d", i, p_stElement->d_stSquare[i].ucType, p_stElement->d_stSquare[i].xFaceIndex); //for each triangle of the current square save the index, the normals to faces //and three indexes for the UV for (j=0; j< p_stElement->d_stSquare[i].sNbFacesForSquare; j++) { SCR_fn_v_RdL0_SplitSectionName(p_stElement->d_hFMD[p_stElement->d_stSquare[i].xFaceIndex+j]->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s%s.gmt", g_sDirectorySave, g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(szMes, sFile, M_GameMaterial, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionSetTriangle, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 9, "%d,%.6f,%.6f,%.6f,%s,%d,%d,%d", p_stElement->d_stSquare[i].xFaceIndex+j, p_stElement->d_stFaceNormals[k].xX, p_stElement->d_stFaceNormals[k].xY, p_stElement->d_stFaceNormals[k].xZ, szMes, p_stElement->d_hFMD[p_stElement->d_stSquare[i].xFaceIndex+j]->stTrianglesIndexUVValues.a3_xIndex[0], p_stElement->d_hFMD[p_stElement->d_stSquare[i].xFaceIndex+j]->stTrianglesIndexUVValues.a3_xIndex[1], p_stElement->d_hFMD[p_stElement->d_stSquare[i].xFaceIndex+j]->stTrianglesIndexUVValues.a3_xIndex[2] ); k++; } } //save the UVs for(i=0; ixNbElementUV; i++) { SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddUV, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 4, "%d,%.6f,%.6f", i, p_stElement->d_stUVValues[i].xU, p_stElement->d_stUVValues[i].xV); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save mega face element * * Parameters: p_stFile : script file pointer * p_stElement : element *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveElementMegaFace (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstElementMegaFace *p_stElement) { xString sFile, sAction, sIdent; char *sName1, *p_Char1; long i, j; SCR_fn_v_RdL0_SplitSectionName(p_stElement->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(p_stElement->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(p_stElement->sName), "!nocol") || strstr(MLT_p_cGetSectionName(p_stElement->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(p_stElement->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(p_stElement->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", p_stElement->lNbMegaFaces); for(i=0; ilNbMegaFaces; i++) { char szParam[256]; char szFace[10]; MLT_tdstMegaFace *p_stMegaFace = &p_stElement->d_stListOfMegaFaces[i]; SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddMegaFace, SCR_CC_C_Cfg_NoChar); sprintf(szParam, "%d", i); for (j=0; jlNbFaces; j++) { strcat(szParam, ","); strcat(szParam, itoa(p_stMegaFace->d_stListOfFaces[j], szFace, 10)); } SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 1, "%s", szParam); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } /**************************************************************************** * Description: save face map descriptor * * Parameters: p_stFile : script file pointer * hFMD : face map descriptor *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveFaceMapDescriptor (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstFaceMapDescriptor *hFMD) { xString mes, sFile, sAction, sIdent, sIdent2; char *sName1, *p_Char1; long i; if(hFMD->AlreadySave == TRUE) return; SCR_fn_v_RdL0_SplitSectionName(hFMD->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(hFMD->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(hFMD->sName), "!nocol") || strstr(MLT_p_cGetSectionName(hFMD->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(hFMD->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(hFMD->sName), SCR_CC_C_Cfg_NoChar); if(strlen(hFMD->sMaterial) != 0) { SCR_fn_v_RdL0_SplitSectionName(hFMD->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s%s.gmt", g_sDirectorySave, g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_GameMaterial, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionMaterial, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); SCR_fn_v_RdL0_SplitSectionName(hFMD->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s.gmt", g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_GameMaterial, sIdent); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveGameMaterial, hFMD->hMaterial, SCR_EA_Ntfy_AddOrModifySection); SCR_fn_v_RdL0_SplitSectionName(hFMD->sMaterial, sFile, sAction, sIdent); sprintf(sFile, "%s.vmt", g_sFileMaterial); sprintf(sIdent2, "MAT_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Material, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveVisualMaterial, hFMD->hMaterial, SCR_EA_Ntfy_AddOrModifySection); for(i=0;ihMaterial->lTexture;i++) { hFMD->hMaterial->lCurTexture = 0; sprintf(sFile, "%s.tex", g_sFileMaterial); sprintf(sIdent2, "TEX_%s", MLT_p_cEraseSpace(MLT_p_cGetFileNameWithoutExt(MLT_p_cGetFileNameWithoutPath(hFMD->hMaterial->sTexture[i])))); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, hFMD->hMaterial, SCR_EA_Ntfy_AddOrModifySection); } // multitextures for(i=0;ihMaterial->lMultiTexture;i++) { hFMD->hMaterial->lCurTexture = 0; if (!g_bExistTex) //the .tex file doesn't exist sprintf(sFile, "%s.tex", g_sFileMaterial); else { if (g_bIgnoreTex) { if (g_bLevelConversion) sprintf(sFile, "%s\\World\\levels\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bBankConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\banks\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bClassConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\classes\\%stemp.tex", g_sGameData, g_sDirectorySave); } else sprintf(sFile, "%s.tex", g_sFileMaterial); } sprintf(sIdent2, "%s", hFMD->hMaterial->stMultiTexture[i].sTexture); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, hFMD->hMaterial, SCR_EA_Ntfy_AddOrModifySection); } } if(strlen(hFMD->sSprObjName) != 0) { SCR_fn_v_RdL0_SplitSectionName(hFMD->sSprObjName, sFile, sAction, sIdent); sprintf(sFile, "%s%s.spo", g_sDirectorySave, g_sFileIn); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, sAction, sIdent); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionPointedSector, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Normal, 1, mes); } SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionTripledUV, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 7, "%.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_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); hFMD->AlreadySave = TRUE; } /**************************************************************************** * Description: save sprite * * Parameters: p_stFile : script file pointer * hSprite : sprite *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ void MLT_vSaveSprite (SCRIPT_tdstSaveFile *p_stFile, MLT_tdstSprite *hSprite) { xString sSection, sFile, sAction, sIdent, mes, sTypeSprite, sIdent2; char *sName1, *p_Char1; long i,j; if(hSprite->AlreadySave == TRUE) return; SCR_fn_v_RdL0_SplitSectionName(hSprite->sName, sFile, sAction, sIdent); p_Char1=sIdent; MLT_vRemoveFlags(&p_Char1); strcpy(sIdent, p_Char1); p_Char1=sIdent; MLT_vRemoveGeomProp(&p_Char1); strcpy(sIdent, p_Char1); SCR_fn_v_RdL0_ComputeSectionName(hSprite->sName, sFile, sAction, sIdent); if (strstr(MLT_p_cGetSectionName(hSprite->sName), "!nocol") || strstr(MLT_p_cGetSectionName(hSprite->sName), "!NOCOL")) { sName1 = MLT_vRemoveFromName(MLT_p_cGetSectionName(hSprite->sName)); SCR_M_SvL0_SaveBeginSection(p_stFile, sName1, SCR_CC_C_Cfg_NoChar); } else SCR_M_SvL0_SaveBeginSection(p_stFile, MLT_p_cGetSectionName(hSprite->sName), SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 2, "%d", hSprite->xNbSprites); for(i=0; ixNbSprites; i++) { SCR_fn_v_RdL0_SplitSectionName(hSprite->d_sMaterial[i], sFile, sAction, sIdent); sprintf(sFile, "%s%s.gmt", g_sDirectorySave, g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(sSection, sFile, M_GameMaterial, sIdent); sprintf(mes, "%d,%s", i, sSection); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddMaterial, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 3, "%d,%s", i, sSection); if(hSprite->d_xSpriteDrawMode[i] == MLT_C_lSpriteDrawMode2DScaled) sprintf(sTypeSprite, M_2DScaled); else if(hSprite->d_xSpriteDrawMode[i] == 0) sprintf(sTypeSprite, M_2DNonScaled); else sprintf(sTypeSprite, M_2DNonScaled); SCR_M_SvL0_SaveEntry(p_stFile, M_MODActionAddInfo, SCR_CC_C_Cfg_NoChar); SCR_fn_v_SvL0_SaveParameters_MP(p_stFile, SCR_EF_SvL0_Scanf, 8, "%d,%s,%.6f,%.6f,%.6f,%.6f,%.6f", i, sTypeSprite, 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_fn_v_RdL0_SplitSectionName(hSprite->d_sMaterial[i], sFile, sAction, sIdent); sprintf(sFile, "%s.gmt", g_sFileMaterial); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_GameMaterial, sIdent); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveGameMaterial, hSprite->d_hMaterial[i], SCR_EA_Ntfy_AddOrModifySection); SCR_fn_v_RdL0_SplitSectionName(hSprite->d_sMaterial[i], sFile, sAction, sIdent); sprintf(sFile, "%s.vmt", g_sFileMaterial); sprintf(sIdent2, "MAT_%s", sIdent); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Material, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveVisualMaterial, hSprite->d_hMaterial[i], SCR_EA_Ntfy_AddOrModifySection); for(j=0;jd_hMaterial[i]->lTexture;j++) { hSprite->d_hMaterial[i]->lCurTexture = 0; sprintf(sFile, "%s.tex", g_sFileMaterial); sprintf(sIdent2, "TEX_%s", MLT_p_cEraseSpace(MLT_p_cGetFileNameWithoutExt(MLT_p_cGetFileNameWithoutPath(hSprite->d_hMaterial[i]->sTexture[j])))); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, hSprite->d_hMaterial[i], SCR_EA_Ntfy_AddOrModifySection); } // multitextures for(j=0;jd_hMaterial[i]->lMultiTexture;j++) { hSprite->d_hMaterial[i]->lCurTexture = 0; if (!g_bExistTex) //the .tex file doesn't exist sprintf(sFile, "%s.tex", g_sFileMaterial); else { if (g_bIgnoreTex) { if (g_bLevelConversion) sprintf(sFile, "%s\\World\\levels\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bBankConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\banks\\%stemp.tex", g_sGameData, g_sDirectorySave); if (g_bClassConversion) sprintf(sFile, "%s\\World\\graphics\\objects\\classes\\%stemp.tex", g_sGameData, g_sDirectorySave); } else sprintf(sFile, "%s.tex", g_sFileMaterial); } sprintf(sIdent2, "%s", hSprite->d_hMaterial[i]->stMultiTexture[j].sTexture); SCR_fn_v_RdL0_ComputeSectionName(mes, sFile, M_Texture, sIdent2); SCR_fn_v_SvL1_RegisterNotify(mes, MLT_vSaveTexture, hSprite->d_hMaterial[i], SCR_EA_Ntfy_AddOrModifySection); } SCR_M_SvL0_SaveEndSection(p_stFile, SCR_CC_C_Cfg_EOL); } hSprite->AlreadySave = TRUE; } /**************************************************************************** * Description: test if the vertexes from a geometric object are symmetric with a plane * * Parameters: p_stGeometric : geometric object *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ BOOL MLT_bTestSymmetry(MLT_tdstGeometricObject *p_stGeometric) { long i; MTH3D_tdstVector stValues; for (i=0; ixNbPoints; i++) { //symetric with plane yoz if ((p_stGeometric->cGeom == 'x') || (p_stGeometric->cGeom == 'X')) { stValues.xX = (float)(2*p_stGeometric->fGeom) - p_stGeometric->d_stListOfPoints[i].xX; stValues.xY = p_stGeometric->d_stListOfPoints[i].xY; stValues.xZ = p_stGeometric->d_stListOfPoints[i].xZ; } //symetric with plane xoz if ((p_stGeometric->cGeom == 'y') || (p_stGeometric->cGeom == 'Y')) { stValues.xX = p_stGeometric->d_stListOfPoints[i].xX; stValues.xY = (float)(2*p_stGeometric->fGeom) - p_stGeometric->d_stListOfPoints[i].xY; stValues.xZ = p_stGeometric->d_stListOfPoints[i].xZ; } //symetric with plane xoy if ((p_stGeometric->cGeom == 'z') || (p_stGeometric->cGeom == 'Z')) { stValues.xX = p_stGeometric->d_stListOfPoints[i].xX; stValues.xY = p_stGeometric->d_stListOfPoints[i].xY; stValues.xZ = (float)(2*p_stGeometric->fGeom) - p_stGeometric->d_stListOfPoints[i].xZ; } if (!MLT_bFindVertex(p_stGeometric, stValues)) return FALSE; } return TRUE; } /**************************************************************************** * Description: check if the vertex belong to the object * * Parameters: p_stGeometric : geometric object * stValues : vertex *--------------------------------------------------------------------------- * Revision date: Author: *****************************************************************************/ BOOL MLT_bFindVertex (MLT_tdstGeometricObject *p_stGeometric, MTH3D_tdstVector stValues) { long i; for (i=0; ixNbPoints; i++) { //for all the points for the geometric object if ((fabs(stValues.xX - p_stGeometric->d_stListOfPoints[i].xX )<=g_fLimit2) &&(fabs(stValues.xY- p_stGeometric->d_stListOfPoints[i].xY )<=g_fLimit2) &&(fabs(stValues.xZ - p_stGeometric->d_stListOfPoints[i].xZ )<=g_fLimit2)) return TRUE; } return FALSE; }