public static (List <Section_AHDR> AHDRs, bool overwrite, bool simps, bool ledgeGrab, bool piptVColors) GetModels(Game game) { using (ImportModel a = new ImportModel()) if (a.ShowDialog() == DialogResult.OK) { List <Section_AHDR> AHDRs = new List <Section_AHDR>(); AssetType assetType = (AssetType)a.comboBoxAssetTypes.SelectedItem; bool simps = false, ledgeGrab = false, piptVColors = false; if (assetType == AssetType.MODL) { piptVColors = a.checkBoxEnableVcolors.Checked; simps = a.checkBoxGenSimps.Checked; ledgeGrab = a.checkBoxLedgeGrab.Checked; if (simps) { MessageBox.Show("a SIMP for each imported MODL will be generated and placed on a new DEFAULT layer."); } } foreach (string filePath in a.filePaths) { string assetName; byte[] assetData; ReadFileMethods.treatStuffAsByteArray = false; if (assetType == AssetType.MODL) { assetName = Path.GetFileNameWithoutExtension(filePath) + ".dff"; assetData = Path.GetExtension(filePath).ToLower().Equals(".dff") ? File.ReadAllBytes(filePath) : ReadFileMethods.ExportRenderWareFile( CreateDFFFromAssimp(filePath, a.checkBoxFlipUVs.Checked, a.checkBoxIgnoreMeshColors.Checked), modelRenderWareVersion(game)); } else if (assetType == AssetType.BSP) { assetName = Path.GetFileNameWithoutExtension(filePath) + ".bsp"; assetData = Path.GetExtension(filePath).ToLower().Equals(".bsp") ? File.ReadAllBytes(filePath) : ReadFileMethods.ExportRenderWareFile( CreateBSPFromAssimp(filePath, a.checkBoxFlipUVs.Checked, a.checkBoxIgnoreMeshColors.Checked), modelRenderWareVersion(game)); } else { throw new ArgumentException(); } AHDRs.Add(new Section_AHDR( Functions.BKDRHash(assetName), assetType, ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType), new Section_ADBG(0, assetName, "", 0), assetData)); } return(AHDRs, a.checkBoxOverwrite.Checked, simps, ledgeGrab, piptVColors); } return(null, false, false, false, false); }
public static List <Section_AHDR> GetAssets(out bool success) { ImportModel a = new ImportModel(); if (a.ShowDialog() == DialogResult.OK) { List <Section_AHDR> AHDRs = new List <Section_AHDR>(); for (int i = 0; i < a.filePaths.Count; i++) { ModelConverterData m; if (Path.GetExtension(a.filePaths[i]).ToLower().Equals(".obj")) { m = ReadOBJFile(a.filePaths[i]); } else if (Path.GetExtension(a.filePaths[i]).ToLower().Equals(".dae")) { m = ConvertDataFromDAEObject(ReadDAEFile(a.filePaths[i]), false); } else { MessageBox.Show("Unknown file format for " + a.filePaths[i] + ", skipping"); continue; } byte[] data; AssetType assetType; string assetName = Path.GetFileNameWithoutExtension(a.filePaths[i]); // + ".dff"; //switch (a.comboBoxAssetTypes.SelectedIndex) //{ // case 0: // assetType = AssetType.BSP; // data = ReadFileMethods.ExportRenderWareFile(CreateBSPFile(m, a.checkBoxFlipUVs.Checked), scoobyRenderWareVersion); // break; // case 1: // assetType = AssetType.MODL; // scooby // data = ReadFileMethods.ExportRenderWareFile(CreateDFFFile(m, a.checkBoxFlipUVs.Checked), scoobyRenderWareVersion); // break; // case 2: // assetType = AssetType.MODL; // bfbb // data = ReadFileMethods.ExportRenderWareFile(CreateDFFFile(m, a.checkBoxFlipUVs.Checked), bfbbRenderWareVersion); // break; // default: // assetType = AssetType.MODL; // movie // data = ReadFileMethods.ExportRenderWareFile(CreateDFFFile(m, a.checkBoxFlipUVs.Checked), tssmRenderWareVersion); // break; //} assetType = AssetType.MODL; data = ReadFileMethods.ExportRenderWareFile(CreateDFFFile(m, a.checkBoxFlipUVs.Checked), currentRenderWareVersion); Section_ADBG ADBG = new Section_ADBG(0, assetName, "", 0); Section_AHDR AHDR = new Section_AHDR(Functions.BKDRHash(assetName), assetType, ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType), ADBG, data); AHDRs.Add(AHDR); } success = true; return(AHDRs); } else { success = false; return(null); } }