public AssimpWpfImporterSample() { InitializeComponent(); // Use helper class (defined in this sample project) to load the native assimp libraries. // IMPORTANT: See commend in the AssimpLoader class for details on how to prepare your project to use assimp library. AssimpLoader.LoadAssimpNativeLibrary(); var assimpWpfImporter = new AssimpWpfImporter(); string[] supportedImportFormats = assimpWpfImporter.SupportedImportFormats; var assimpWpfExporter = new AssimpWpfExporter(); string[] supportedExportFormats = assimpWpfExporter.ExportFormatDescriptions.Select(f => f.FileExtension).ToArray(); FileFormatsTextBlock.Text = string.Format("Using native Assimp library version {0}.\r\n\r\nSupported import formats:\r\n{1}\r\n\r\nSupported export formats:\r\n{2}", assimpWpfImporter.AssimpVersion, string.Join(", ", supportedImportFormats), string.Join(", ", supportedExportFormats)); var dragAndDropHelper = new DragAndDropHelper(this, ".*"); dragAndDropHelper.FileDropped += (sender, args) => LoadModel(args.FileName); string startUpFileName = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\Collada\duck.dae"); LoadModel(startUpFileName); }
public PropertiesView() { InitializeComponent(); Helpers.LoadAssimpNativeLibrary(); var assimpWpfImporter = new AssimpWpfImporter(); string[] supportedImportFormats = assimpWpfImporter.SupportedImportFormats; var assimpWpfExporter = new AssimpWpfExporter(); string[] supportedExportFormats = assimpWpfExporter.ExportFormatDescriptions.Select(f => f.FileExtension).ToArray(); StaticReferences.GlobalPropertiesView = this; var themeResources = Application.LoadComponent(new Uri("Resources/Styles/ExpressionDark.xaml", UriKind.Relative)) as ResourceDictionary; Resources.MergedDictionaries.Add(themeResources); spectrumAnalyzer.RegisterSoundPlayer(NAudioSimpleEngine.Instance); waveformTimeline.RegisterSoundPlayer(NAudioSimpleEngine.Instance); //appControl.ExeName = "binkpl64.exe"; //appControl.Args = "test2.bk2 /J /I2 /P"; //this.Unloaded += new RoutedEventHandler((s, e) => { appControl.Dispose(); }); }
public PropertiesView() { InitializeComponent(); ViewModel = Locator.Current.GetService <PropertiesViewModel>(); DataContext = ViewModel; AssimpHelper.LoadAssimpNativeLibrary(); var assimpWpfImporter = new AssimpWpfImporter(); var supportedImportFormats = assimpWpfImporter.SupportedImportFormats; var assimpWpfExporter = new AssimpWpfExporter(); var supportedExportFormats = assimpWpfExporter.ExportFormatDescriptions.Select(f => f.FileExtension).ToArray(); //var themeResources = Application.LoadComponent(new Uri("Resources/Styles/ExpressionDark.xaml", UriKind.Relative)) as ResourceDictionary; //Resources.MergedDictionaries.Add(themeResources); spectrumAnalyzer.RegisterSoundPlayer(NAudioSimpleEngine.Instance); waveformTimeline.RegisterSoundPlayer(NAudioSimpleEngine.Instance); nAudioSimple = NAudioSimpleEngine.Instance; NAudioSimpleEngine.Instance.PropertyChanged += NAudioEngine_PropertyChanged; //appControl.ExeName = "binkpl64.exe"; //appControl.Args = "test2.bk2 /J /I2 /P"; //this.Unloaded += new RoutedEventHandler((s, e) => { appControl.Dispose(); }); this.WhenActivated(disposables => { ViewModel.WhenAnyValue(x => x.LoadedBitmapFrame).Subscribe(source => { if (source is { } frame) { LoadImage(frame); } }); ViewModel.WhenAnyValue(x => x.LoadedModelPath).Subscribe(source => { if (source is { } modelpath) { LoadModel(modelpath); } }); ViewModel.PreviewAudioCommand.Subscribe(path => { TempConvertToWemWav(path); }); }); }
public AssimpWpfExporterSample() { InitializeComponent(); AssimpWpfImporter.LoadAssimpNativeLibrary(AppDomain.CurrentDomain.BaseDirectory); var assimpWpfExporter = new AssimpWpfExporter(); _exportFormatDescriptions = assimpWpfExporter.ExportFormatDescriptions; for (int i = 0; i < _exportFormatDescriptions.Length; i++) { var comboBoxItem = new ComboBoxItem() { Content = string.Format("{0} (.{1})", _exportFormatDescriptions[i].Description, _exportFormatDescriptions[i].FileExtension), Tag = _exportFormatDescriptions[i].FormatId }; ExportTypeComboBox.Items.Add(comboBoxItem); } ExportTypeComboBox.SelectedIndex = 0; // Use Collada file format by default _selectedExportFormatId = _exportFormatDescriptions[ExportTypeComboBox.SelectedIndex].FormatId; // Use helper class (defined in this sample project) to load the native assimp libraries // IMPORTANT: See commend in the AssimpLoader class for details on how to prepare your project to use assimp library. AssimpLoader.LoadAssimpNativeLibrary(); _assimpWpfImporter = new AssimpWpfImporter(); _assimpWpfImporter.AssimpPostProcessSteps = PostProcessSteps.Triangulate; CreateTestScene(); // Set initial output file name OutputFileName.Text = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "AssimpExport.dae"); // Add drag and drop handler for all file extensions var dragAndDropHelper = new DragAndDropHelper(ViewportBorder, "*"); dragAndDropHelper.FileDroped += (sender, e) => LoadModel(e.FileName); }
// Export specified model3D (we could also export Visual3D or entire Viewport3D - see commented code below) private bool ExportViewport3D(string fileName, string exportFormatId, Viewport3D viewport3D, Dictionary <string, object> namedObjects) { // First create an instance of AssimpWpfExporter var assimpWpfExporter = new AssimpWpfExporter(); // To export objects with names, we can use one of the following methods: // 1) Set object names with SetName extension method that is added by Ab3d.PowerToys (for example: boxVisual3D.SetName("BoxVisual1"); or // 2) Set assimpWpfExporter.NamedObjects to a Dictionary<string, object> dictionary with set names as keys and objects as values or // 3) Set assimpWpfExporter.ObjectNames to a Dictionary<object, string> dictionary with set objects as keys and names as values // Here we use NamedObjects because NamedObjects dictionary is also set when the 3D models are read from file assimpWpfExporter.NamedObjects = _namedObjects; // We can export Model3D, Visual3D or entire Viewport3D: //assimpWpfExporter.AddModel(model3D); //assimpWpfExporter.AddVisual3D(ContentModelVisual3D); //assimpWpfExporter.AddViewport3D(MainViewport); // Here we export Viewport3D: assimpWpfExporter.AddViewport3D(viewport3D); bool isExported; try { isExported = assimpWpfExporter.Export(fileName, exportFormatId); if (!isExported) { MessageBox.Show("Not exported"); } } catch (Exception ex) { MessageBox.Show("Error exporting:\r\n" + ex.Message); isExported = false; } return(isExported); }