Example #1
0
 /// <summary>
 /// Exports to obj.
 /// </summary>
 /// <param name="view">
 /// The view.
 /// </param>
 /// <param name="fileName">
 /// Name of the file.
 /// </param>
 private static void ExportObj(Viewport3D view, string fileName)
 {
     using (var e = new ObjExporter(fileName))
     {
         e.Export(view);
     }
 }
 public void Export_SimpleModel_ValidOutput()
 {
     string path = "temp.obj";
     using (var e = new ObjExporter(path))
     {
         ExportSimpleModel(e);
     }
 }
Example #3
0
        private void ExportModel(string fileName = "model.obj")
        {
            using (var exporter = new ObjExporter(fileName))
            {
                exporter.Export(this.Model);
            }

            Process.Start("explorer.exe", "/select,\"" + fileName + "\"");
        }
 public void Export_BoxWithGradientTexture_TextureExportedAsJpg()
 {
     var path = "box_gradient_jpg.obj";
     var e = new ObjExporter { TextureExtension = ".jpg" };
     using (var stream = File.Create(path))
     {
         this.ExportModel(e, stream, () => new BoxVisual3D { Material = Materials.Rainbow });
     }
 }
 public void Export_SimpleModel_ValidOutput()
 {
     string path = "temp.obj";
     var e = new ObjExporter();
     using (var stream = File.Create(path))
     {
         this.ExportSimpleModel(e, stream);
     }
 }
 public void Export_BoxWithGradientTexture_TextureExportedAsPng()
 {
     var path = "box_gradient_png.obj";
     var e = new ObjExporter { MaterialsFile = Path.ChangeExtension(path, ".mtl") };
     using (var stream = File.Create(path))
     {
         this.ExportModel(e, stream, () => new BoxVisual3D { Material = Materials.Rainbow });
     }
 }
 public void Export_SimpleModel_ValidOutput()
 {
     string path = "temp.obj";
     var e = new ObjExporter { MaterialsFile = Path.ChangeExtension(path, ".mtl") };
     using (var stream = File.Create(path))
     {
         this.ExportSimpleModel(e, stream);
     }
 }
 public void ShouldThrowExceptionIfMaterialsFileIsNotSpecified()
 {
     string path = "temp.obj";
     var e = new ObjExporter();
     using (var stream = File.Create(path))
     {
         Assert.Throws<InvalidOperationException>(() => this.ExportSimpleModel(e, stream));
     }
 }
Example #9
0
        /// <summary>
        /// Exports to an obj file.
        /// </summary>
        /// <param name="view">
        /// The viewport.
        /// </param>
        /// <param name="fileName">
        /// Name of the file.
        /// </param>
        private static void ExportObj(this Viewport3D view, string fileName)
        {
            var e = new ObjExporter {
                TextureFolder = System.IO.Path.GetDirectoryName(fileName)
            };

            using (var stream = File.Create(fileName))
            {
                e.Export(view, stream);
            }
        }
Example #10
0
        /// <summary>
        /// Exports to an obj file.
        /// </summary>
        /// <param name="view">
        /// The viewport.
        /// </param>
        /// <param name="path">
        /// Name of the file.
        /// </param>
        private static void ExportObj(this Viewport3D view, string path)
        {
            var dir      = System.IO.Path.GetDirectoryName(path) ?? ".";
            var filename = System.IO.Path.GetFileName(path);
            var e        = new ObjExporter
            {
                TextureFolder = dir,
                FileCreator   = f => File.Create(System.IO.Path.Combine(dir, f))
            };

            using (var stream = File.Create(path))
            {
                e.MaterialsFile = System.IO.Path.ChangeExtension(filename, ".mtl");
                e.Export(view, stream);
            }
        }
        private void FileExportRaw()
        {
            var path = FileDialogService.SaveFileDialog(null, null, Exporters.Filter, ".png");
            if (path == null)
                return;
            //HelixView.Export(path);
            ///*
            Stopwatch stopWatch = new Stopwatch();
            stopWatch.Start();

            var ext = Path.GetExtension(path).ToLowerInvariant();
            switch (ext)
            {
                case ".png":
                case ".jpg":
                    HelixView.Export(path);
                    break;
                case ".xaml":
                    {
                        var e = new XamlExporter(path);
                        e.Export(CurrentModel);
                        e.Close();
                        break;
                    }

                case ".xml":
                    {
                        var e = new KerkytheaExporter(path);
                        e.Export(HelixView.Viewport);
                        e.Close();
                        break;
                    }
                case ".obj":
                    {
                        var patient = new Patient();
                        var e = new SmileObjExporter(path);
                        //e.Export(CurrentModel);
                            ((SmileObjExporter)e).rawVisual = RawVisual;
                            ((SmileObjExporter)e).Export(RawVisual, patient);
                        e.Close();
                        break;
                    }
                case ".objz":
                    {
                        var tmpPath = Path.ChangeExtension(path, ".obj");
                        var e = new ObjExporter(tmpPath);
                        e.Export(CurrentModel);
                        e.Close();
                        GZipHelper.Compress(tmpPath);
                        break;
                    }
                case ".x3d":
                    {
                        var e = new X3DExporter(path);
                        e.Export(CurrentModel);
                        e.Close();
                        break;
                    }
            }
            showStatus(stopWatch, "Exported");
            //*/
        }
        /// <summary>
        /// Export the completed mesh to a .obj file
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event arguments</param>
        private void Export_Model_Click(object sender, RoutedEventArgs e)
        {
            //function from Helix Toolkit
            string fileName = Model_Name.Text + ".obj";

            using (var exporter = new ObjExporter(fileName))
            {
                exporter.Export(this.modelGroup);
            }

            // test code for seeing depth frame values
            Process.Start("explorer.exe", "/select,\"" + fileName + "\"");

            string fileName2 = "depth.txt";

            using (System.IO.StreamWriter file = new System.IO.StreamWriter(fileName2))
            {
                //file.Write(string.Join(",", this.Depth));
                file.Write(greatestDepth);
            }
        }