public static ModelPack ConvertAssimpModel() { using (var dialog = new OpenFileDialog()) { dialog.AutoUpgradeEnabled = true; dialog.CheckPathExists = true; dialog.CheckFileExists = true; dialog.Filter = ModuleFilterGenerator.GenerateFilter(FormatModuleUsageFlags.ImportForEditing, typeof(Assimp.Scene)).Filter; dialog.Multiselect = false; dialog.SupportMultiDottedExtensions = true; dialog.Title = "Select an Assimp model."; dialog.ValidateNames = true; if (dialog.ShowDialog() != DialogResult.OK) { return(null); } return(ConvertAssimpModel(dialog.FileName)); } }
public void OpenFile() { using (var dialog = new OpenFileDialog()) { dialog.AutoUpgradeEnabled = true; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.Filter = ModuleFilterGenerator.GenerateFilter( FormatModuleRegistry.ModelTypes.Where(x => typeof(IBinaryFile).IsAssignableFrom(x) && x.IsClass && !x.IsAbstract && NodeFactory.NodeTypes.ContainsKey(x)), FormatExtensionFlags.Import); dialog.Title = "Select a file to open."; dialog.ValidateNames = true; dialog.AddExtension = true; if (dialog.ShowDialog() == DialogResult.OK) { OpenFile(dialog.FileName); } } }
private void HandleAnimationLoadExternalToolStripMenuItemClick(object sender, EventArgs e) { var filePath = SelectFileToOpen(ModuleFilterGenerator.GenerateFilter(FormatModuleUsageFlags.Import, typeof(AnimationPack), typeof(Animation)).Filter); if (filePath == null) { return; } if (!DataViewNodeFactory.TryCreate(filePath, out var node)) { MessageBox.Show("Hee file could not be loaded, ho.", "Error", MessageBoxButtons.OK); return; } if (node.DataType == typeof(Animation)) { ModelViewControl.Instance.LoadAnimation(( Animation )node.Data); } else if (node.DataType == typeof(AnimationPack)) { var animationPack = ( AnimationPack )node.Data; var animation = animationPack.Animations.FirstOrDefault(); if (animation != null) { ModelViewControl.Instance.LoadAnimation(animation); } } else { MessageBox.Show("Not a support animation file.", "Error", MessageBoxButtons.OK); return; } mAnimationListTreeView.SetTopNode(node); }