public static (bool, Vector4, Operation) GetColor() { ApplyVertexColors edit = new ApplyVertexColors(); edit.ShowDialog(); return(edit.OK, new Vector4((float)edit.numericUpDownX.Value, (float)edit.numericUpDownY.Value, (float)edit.numericUpDownZ.Value, (float)edit.numericUpDownW.Value), (Operation)edit.comboBoxOperation.SelectedItem); }
private void SetupForModel(AssetRenderWareModel asset) { AddRow(); AddRow(); AddRow(); AddRow(); Button buttonSetVertexColors = new Button() { Dock = DockStyle.Fill, Text = "Set Vertex Colors", AutoSize = true }; buttonSetVertexColors.Click += (object sender, EventArgs e) => { var(color, operation) = ApplyVertexColors.GetColor(); if (color.HasValue) { asset.SetVertexColors(color.Value, operation); archive.UnsavedChanges = true; } }; buttonSetVertexColors.Enabled = !asset.IsNativeData; tableLayoutPanel1.Controls.Add(buttonSetVertexColors, 0, 2); CheckBox ignoreMeshColors = new CheckBox() { Dock = DockStyle.Fill, Text = "Ignore Mesh Colors", AutoSize = true }; ignoreMeshColors.Checked = true; tableLayoutPanel1.Controls.Add(ignoreMeshColors, 0, 3); CheckBox flipUVs = new CheckBox() { Dock = DockStyle.Fill, Text = "Flip UVs", AutoSize = true }; tableLayoutPanel1.Controls.Add(flipUVs, 0, 4); Button buttonImport = new Button() { Dock = DockStyle.Fill, Text = "Import", AutoSize = true }; buttonImport.Click += (object sender, EventArgs e) => { OpenFileDialog openFile = new OpenFileDialog() { Filter = GetImportFilter(), // "All supported types|*.dae;*.obj;*.bsp|DAE Files|*.dae|OBJ Files|*.obj|BSP Files|*.bsp|All files|*.*", }; if (openFile.ShowDialog() == DialogResult.OK) { if (asset.AHDR.assetType == HipHopFile.AssetType.MODL) { asset.Data = Path.GetExtension(openFile.FileName).ToLower().Equals(".dff") ? File.ReadAllBytes(openFile.FileName) : ReadFileMethods.ExportRenderWareFile(CreateDFFFromAssimp(openFile.FileName, flipUVs.Checked, ignoreMeshColors.Checked), modelRenderWareVersion(asset.game)); } if (asset.AHDR.assetType == HipHopFile.AssetType.BSP) { asset.Data = Path.GetExtension(openFile.FileName).ToLower().Equals(".bsp") ? File.ReadAllBytes(openFile.FileName) : ReadFileMethods.ExportRenderWareFile(CreateBSPFromAssimp(openFile.FileName, flipUVs.Checked, ignoreMeshColors.Checked), modelRenderWareVersion(asset.game)); } asset.Setup(Program.MainForm.renderer); archive.UnsavedChanges = true; } }; tableLayoutPanel1.Controls.Add(buttonImport, 0, 5); CheckBox exportTextures = new CheckBox() { Dock = DockStyle.Fill, Text = "Export Textures", AutoSize = true }; tableLayoutPanel1.Controls.Add(exportTextures, 1, 4); Button buttonExport = new Button() { Dock = DockStyle.Fill, Text = "Export", AutoSize = true }; buttonExport.Click += (object sender, EventArgs e) => { (Assimp.ExportFormatDescription format, string textureExtension) = ChooseTarget.GetTarget(); if (format != null) { SaveFileDialog a = new SaveFileDialog() { Filter = format == null ? "RenderWare BSP|*.bsp" : format.Description + "|*." + format.FileExtension, }; if (a.ShowDialog() == DialogResult.OK) { if (format == null) { File.WriteAllBytes(a.FileName, asset.Data); } else if (format.FileExtension.ToLower().Equals("obj") && asset.AHDR.assetType == HipHopFile.AssetType.BSP) { ConvertBSPtoOBJ(a.FileName, ReadFileMethods.ReadRenderWareFile(asset.Data), true); } else { ExportAssimp(Path.ChangeExtension(a.FileName, format.FileExtension), ReadFileMethods.ReadRenderWareFile(asset.Data), true, format, textureExtension, Matrix.Identity); } if (exportTextures.Checked) { string folderName = Path.GetDirectoryName(a.FileName); var bitmaps = archive.GetTexturesAsBitmaps(asset.Textures); ReadFileMethods.treatStuffAsByteArray = false; foreach (string textureName in bitmaps.Keys) { bitmaps[textureName].Save(folderName + "/" + textureName + ".png", System.Drawing.Imaging.ImageFormat.Png); } } } } }; tableLayoutPanel1.Controls.Add(buttonExport, 1, 5); }