private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) { assetType = (AssetType)comboBoxAssetTypes.SelectedItem; AHDRflags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType); label1.Visible = AHDRflags == 0; }
public Asset(string assetName, AssetType assetType) { game = Game.Unknown; endianness = Endianness.Unknown; this.assetType = assetType; this.assetName = assetName; assetID = new AssetID(assetName); assetFileName = ""; flags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType); }
private void comboBoxAssetTypes_SelectedIndexChanged(object sender, EventArgs e) { assetType = (AssetType)comboBoxAssetTypes.SelectedItem; AHDRFlags flags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType); checkSourceFile.Checked = (flags & AHDRFlags.SOURCE_FILE) != 0; checkSourceVirtual.Checked = (flags & AHDRFlags.SOURCE_VIRTUAL) != 0; checkReadT.Checked = (flags & AHDRFlags.READ_TRANSFORM) != 0; checkWriteT.Checked = (flags & AHDRFlags.WRITE_TRANSFORM) != 0; label1.Visible = flags == 0; }
private void buttonCopy_Click(object sender, EventArgs e) { if (listBoxTemplates.SelectedIndex < 0) { return; } // Generating Asset AHDR string assetName = listBoxTemplates.SelectedItem.ToString().Substring(listBoxTemplates.SelectedItem.ToString().IndexOf(']') + 2); string assetTypeName = listBoxTemplates.SelectedItem.ToString().Substring(listBoxTemplates.SelectedItem.ToString().IndexOf('[') + 1, listBoxTemplates.SelectedItem.ToString().IndexOf(']') - listBoxTemplates.SelectedItem.ToString().IndexOf('[') - 1); AssetType assetType = AssetType.Null; foreach (AssetType o in Enum.GetValues(typeof(AssetType))) { if (o.ToString() == assetTypeName.Trim().ToUpper()) { assetType = o; break; } } if (assetType == AssetType.Null) { throw new Exception("Unknown asset type: " + assetType); } Section_AHDR newAsset = new Section_AHDR { assetID = Functions.BKDRHash(assetName), assetType = assetType, flags = ArchiveEditorFunctions.AHDRFlagsFromAssetType(assetType), data = File.ReadAllBytes(Path.Combine(Program.MainForm.userTemplatesFolder, listBoxTemplates.SelectedItem.ToString())) }; newAsset.ADBG = new Section_ADBG(0, assetName, "", 0); // Asset AHDR is done Clipboard.SetText(JsonConvert.SerializeObject(new List <Section_AHDR> { newAsset })); }
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(Game game, Platform platform, out bool success, out bool overwrite) { ImportTextures a = new ImportTextures(); if (a.ShowDialog() == DialogResult.OK) { ReadFileMethods.treatStuffAsByteArray = true; List <Section_AHDR> AHDRs = new List <Section_AHDR>(); List <string> forBitmap = new List <string>(); for (int i = 0; i < a.filePaths.Count; i++) { if (Path.GetExtension(a.filePaths[i]).ToLower().Equals(".rwtex")) { byte[] data = ReadFileMethods.ExportRenderWareFile(new TextureDictionary_0016() { textureDictionaryStruct = new TextureDictionaryStruct_0001() { textureCount = 1, unknown = 0 }, textureNativeList = new List <TextureNative_0015>() { new TextureNative_0015().FromBytes(File.ReadAllBytes(a.filePaths[i])) }, textureDictionaryExtension = new Extension_0003() }, currentTextureVersion(game)); string assetName = Path.GetFileNameWithoutExtension(a.filePaths[i]) + (a.checkBoxRW3.Checked ? ".RW3" : ""); Section_ADBG ADBG = new Section_ADBG(0, assetName, "", 0); Section_AHDR AHDR = new Section_AHDR(Functions.BKDRHash(assetName), AssetType.RWTX, ArchiveEditorFunctions.AHDRFlagsFromAssetType(AssetType.RWTX), ADBG, data); AHDRs.Add(AHDR); } else { forBitmap.Add(a.filePaths[i]); } } AHDRs.AddRange(CreateRWTXsFromBitmaps(game, platform, forBitmap, a.checkBoxRW3.Checked, a.checkBoxFlipTextures.Checked, a.checkBoxMipmaps.Checked, a.checkBoxCompress.Checked)); ReadFileMethods.treatStuffAsByteArray = false; if (game == Game.Scooby) { for (int i = 0; i < AHDRs.Count; i++) { byte[] data = AHDRs[i].data; FixTextureForScooby(ref data); AHDRs[i].data = data; } } success = true; overwrite = a.checkBoxOverwrite.Checked; return(AHDRs); } else { success = false; overwrite = false; return(null); } }
public static List <Section_AHDR> CreateRWTXsFromBitmaps (Game game, Platform platform, List <string> fileNames, bool appendRW3, bool flip, bool mipmaps, bool compress, bool transFix) { lock (locker) { if (transFix) { compress = false; } List <TextureNative_0015> textureNativeList = new List <TextureNative_0015>(); foreach (string fileName in fileNames) { string textureName = Path.GetFileNameWithoutExtension(fileName); Bitmap bitmap = new Bitmap(fileName); List <byte> bitmapData = new List <byte>(bitmap.Width * bitmap.Height * 4); if (flip) { bitmap.RotateFlip(RotateFlipType.RotateNoneFlipY); } for (int j = 0; j < bitmap.Height; j++) { for (int i = 0; i < bitmap.Width; i++) { bitmapData.Add(bitmap.GetPixel(i, j).B); bitmapData.Add(bitmap.GetPixel(i, j).G); bitmapData.Add(bitmap.GetPixel(i, j).R); bitmapData.Add(bitmap.GetPixel(i, j).A); } } textureNativeList.Add( new TextureNative_0015() { textureNativeStruct = new TextureNativeStruct_0001() { textureName = textureName + (appendRW3 ? ".RW3" : ""), alphaName = "", height = (short)bitmap.Height, width = (short)bitmap.Width, mipMapCount = 1, addressModeU = TextureAddressMode.TEXTUREADDRESSWRAP, addressModeV = TextureAddressMode.TEXTUREADDRESSWRAP, filterMode = TextureFilterMode.FILTERLINEAR, bitDepth = 32, platformType = 8, compression = 0, hasAlpha = false, rasterFormatFlags = TextureRasterFormat.RASTER_C8888, type = 4, mipMaps = new MipMapEntry[] { new MipMapEntry(bitmapData.Count, bitmapData.ToArray()) }, }, textureNativeExtension = new Extension_0003() } ); bitmap.Dispose(); } if (!Directory.Exists(tempPcTxdsDir)) { Directory.CreateDirectory(tempPcTxdsDir); } if (!Directory.Exists(tempGcTxdsDir)) { Directory.CreateDirectory(tempGcTxdsDir); } File.WriteAllBytes(pathToPcTXD, ReadFileMethods.ExportRenderWareFile(new TextureDictionary_0016() { textureDictionaryStruct = new TextureDictionaryStruct_0001() { textureCount = (short)textureNativeList.Count, unknown = 0 }, textureNativeList = textureNativeList, textureDictionaryExtension = new Extension_0003() }, currentTextureVersion(game))); PerformTXDConversionExternal(platform, false, compress, mipmaps); ReadFileMethods.treatStuffAsByteArray = true; List <Section_AHDR> AHDRs = new List <Section_AHDR>(); foreach (TextureNative_0015 texture in ((TextureDictionary_0016)ReadFileMethods.ReadRenderWareFile(pathToGcTXD)[0]).textureNativeList) { AHDRs.Add(new Section_AHDR(BKDRHash(texture.textureNativeStruct.textureName), AssetType.RWTX, ArchiveEditorFunctions.AHDRFlagsFromAssetType(AssetType.RWTX), new Section_ADBG(0, texture.textureNativeStruct.textureName, "", 0), ReadFileMethods.ExportRenderWareFile(new TextureDictionary_0016() { textureDictionaryStruct = new TextureDictionaryStruct_0001() { textureCount = 1, unknown = 0 }, textureNativeList = new List <TextureNative_0015>() { texture }, textureDictionaryExtension = new Extension_0003() }, currentTextureVersion(game)))); } // fix for apparent transparency issue if (transFix && platform == Platform.GameCube) { foreach (var AHDR in AHDRs) { AHDR.data[0x9B] = 0x01; } } ReadFileMethods.treatStuffAsByteArray = false; File.Delete(pathToGcTXD); File.Delete(pathToPcTXD); return(AHDRs); } }
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); } }