Make gmx models exportable

This commit is contained in:
KillzXGaming 2019-10-21 17:38:21 -04:00
parent e4654f8dff
commit 54b6790afe

View file

@ -12,7 +12,7 @@ using Toolbox.Library.Forms;
namespace FirstPlugin
{
public class GMX : TreeNodeFile, IFileFormat
public class GMX : TreeNodeFile, IFileFormat, IContextMenuNode
{
public FileType FileType { get; set; } = FileType.Model;
@ -78,6 +78,35 @@ namespace FirstPlugin
}
}
public ToolStripItem[] GetContextMenuItems()
{
List<ToolStripItem> Items = new List<ToolStripItem>();
Items.Add(new ToolStripMenuItem("Export", null, ExportAction, Keys.Control | Keys.E));
return Items.ToArray();
}
private void ExportAction(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Supported Formats|*.dae;";
if (sfd.ShowDialog() == DialogResult.OK)
{
ExportModel(sfd.FileName);
}
}
private void ExportModel(string FileName)
{
AssimpSaver assimp = new AssimpSaver();
ExportModelSettings settings = new ExportModelSettings();
var model = new STGenericModel();
model.Materials = new List<STGenericMaterial>();
model.Objects = Renderer.Meshes;
assimp.SaveFromModel(model, FileName, new List<STGenericTexture>(), new STSkeleton());
}
public Header GMXHeader;
public GMX_Renderer Renderer;