public RhinoDocGltfConverter(glTFExportOptions options, bool binary, IEnumerable <RhinoObject> objects, LinearWorkflow workflow) { this.options = options; this.binary = binary; this.objects = objects; this.workflow = workflow; }
public RhinoDocGltfConverter(glTFExportOptions options, bool binary, RhinoDoc doc, LinearWorkflow workflow) { this.options = options; this.binary = binary; this.objects = doc.Objects; this.workflow = null; }
public static bool DoExport(string fileName, glTFExportOptions opts, IEnumerable <Rhino.DocObjects.RhinoObject> rhinoObjects, Rhino.Render.LinearWorkflow workflow) { try { RhinoDocGltfConverter converter = new RhinoDocGltfConverter(opts, rhinoObjects, workflow); glTFLoader.Schema.Gltf gltf = converter.ConvertToGltf(); if (opts.UseBinary) { byte[] bytes = converter.GetBinaryBuffer(); glTFLoader.Interface.SaveBinaryModel(gltf, bytes.Length == 0 ? null : bytes, fileName); } else { glTFLoader.Interface.SaveModel(gltf, fileName); } RhinoApp.WriteLine("Successfully exported selected geometry to glTF(Binary)."); return(true); } catch (Exception e) { RhinoApp.WriteLine("ERROR: Failed exporting selected geometry to file."); System.Diagnostics.Debug.WriteLine(e.Message); return(false); } }
protected override WriteFileResult WriteFile(string filename, int index, RhinoDoc doc, FileWriteOptions options) { bool binary = GlTFUtils.IsFileGltfBinary(filename); if (!UseSavedSettingsDontShowDialog) { ExportOptionsDialog optionsDlg = new ExportOptionsDialog(); optionsDlg.RestorePosition(); Eto.Forms.DialogResult result = optionsDlg.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); if (result != Eto.Forms.DialogResult.Ok) { return(WriteFileResult.Cancel); } } glTFExportOptions exportOptions = glTFBinExporterPlugin.GetSavedOptions(); IEnumerable <Rhino.DocObjects.RhinoObject> objects = GetObjectsToExport(doc, options); if (!GlTFExporterCommand.DoExport(filename, exportOptions, binary, doc, objects, doc.RenderSettings.LinearWorkflow)) { return(WriteFileResult.Failure); } return(WriteFileResult.Success); }
public RhinoMaterialGltfConverter(glTFExportOptions options, gltfSchemaDummy dummy, List <byte> binaryBuffer, Rhino.DocObjects.Material rhinoMaterial, LinearWorkflow workflow) { this.options = options; this.dummy = dummy; this.binaryBuffer = binaryBuffer; this.rhinoMaterial = rhinoMaterial; this.workflow = workflow; }
protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode) { GetObject go = Selection.GetValidExportObjects("Select objects to export."); var dialog = GetSaveFileDialog(); var fileSelected = dialog.ShowSaveDialog(); if (!fileSelected) { return(Result.Cancel); } bool binary = GlTFUtils.IsFileGltfBinary(dialog.FileName); var opts = new glTFExportOptions() { UseDracoCompression = false, DracoCompressionLevel = 10, DracoQuantizationBitsPosition = 11, DracoQuantizationBitsNormal = 8, DracoQuantizationBitsTexture = 10, UseBinary = binary }; if (mode == RunMode.Scripted) { Rhino.Input.RhinoGet.GetBool("Compression", true, "None", "Draco", ref opts.UseDracoCompression); if (opts.UseDracoCompression) { Rhino.Input.RhinoGet.GetInteger("Draco Compression Level (max=10)", true, ref opts.DracoCompressionLevel, 1, 10); Rhino.Input.RhinoGet.GetInteger("Quantization Position", true, ref opts.DracoQuantizationBitsPosition, 8, 32); Rhino.Input.RhinoGet.GetInteger("Quantization Normal", true, ref opts.DracoQuantizationBitsNormal, 8, 32); Rhino.Input.RhinoGet.GetInteger("Quantization Texture", true, ref opts.DracoQuantizationBitsTexture, 8, 32); } Rhino.Input.RhinoGet.GetBool("Map Rhino Z to glTF Y", true, "No", "Yes", ref opts.MapRhinoZToGltfY); } else { ExportOptionsDialog optionsDlg = new ExportOptionsDialog(opts); if (optionsDlg.ShowModal() == null) { return(Result.Cancel); } } var rhinoObjects = go .Objects() .Select(o => o.Object()) .ToArray(); if (!DoExport(dialog.FileName, opts, rhinoObjects, doc.RenderSettings.LinearWorkflow)) { return(Result.Failure); } return(Result.Success); }
public RhinoMaterialGltfConverter(glTFExportOptions options, bool binary, gltfSchemaDummy dummy, List <byte> binaryBuffer, RenderMaterial renderMaterial, LinearWorkflow workflow) { this.options = options; this.binary = binary; this.dummy = dummy; this.binaryBuffer = binaryBuffer; this.rhinoMaterial = renderMaterial.SimulatedMaterial(RenderTexture.TextureGeneration.Allow); this.renderMaterial = renderMaterial; this.workflow = workflow; }
public static bool DoExport(string fileName, glTFExportOptions options, bool binary, RhinoDoc doc, IEnumerable <Rhino.DocObjects.RhinoObject> rhinoObjects, Rhino.Render.LinearWorkflow workflow) { RhinoDocGltfConverter converter = new RhinoDocGltfConverter(options, binary, doc, rhinoObjects, workflow); glTFLoader.Schema.Gltf gltf = converter.ConvertToGltf(); if (binary) { byte[] bytes = converter.GetBinaryBuffer(); glTFLoader.Interface.SaveBinaryModel(gltf, bytes.Length == 0 ? null : bytes, fileName); } else { glTFLoader.Interface.SaveModel(gltf, fileName); } RhinoApp.WriteLine("Successfully exported selected geometry to glTF(Binary)."); return(true); }
protected override WriteFileResult WriteFile(string filename, int index, RhinoDoc doc, FileWriteOptions options) { bool binary = GlTFUtils.IsFileGltfBinary(filename); glTFExportOptions gltfOptions = new glTFExportOptions(); gltfOptions.UseBinary = binary; ExportOptionsDialog optionsDlg = new ExportOptionsDialog(gltfOptions); if (optionsDlg.ShowModal() == null) { return(WriteFileResult.Cancel); } IEnumerable <Rhino.DocObjects.RhinoObject> objects = GetObjectsToExport(doc, options); GlTFExporterCommand.DoExport(filename, gltfOptions, objects, doc.RenderSettings.LinearWorkflow); return(WriteFileResult.Success); }
public RhinoMeshGltfConverter(ObjectExportData exportData, int?materialIndex, glTFExportOptions options, bool binary, gltfSchemaDummy dummy, List <byte> binaryBuffer) { this.exportData = exportData; this.materialIndex = materialIndex; this.options = options; this.binary = binary; this.dummy = dummy; this.binaryBuffer = binaryBuffer; }
private bool GetExportOptions(RunMode mode, out glTFExportOptions options) { if (mode == RunMode.Scripted) { options = new glTFExportOptions(); if (Rhino.Input.RhinoGet.GetBool("Compression", true, "None", "Draco", ref options.UseDracoCompression) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetBool("Export Materials", true, "No", "Yes", ref options.ExportMaterials) != Result.Success) { return(false); } if (options.ExportMaterials) { if (Rhino.Input.RhinoGet.GetBool("Use display color for objects with unset material", true, "No", "Yes", ref options.UseDisplayColorForUnsetMaterials) != Result.Success) { return(false); } } if (options.UseDracoCompression) { if (Rhino.Input.RhinoGet.GetInteger("Draco Compression Level (max=10)", true, ref options.DracoCompressionLevel, 1, 10) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetInteger("Quantization Position", true, ref options.DracoQuantizationBitsPosition, 8, 32) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetInteger("Quantization Normal", true, ref options.DracoQuantizationBitsNormal, 8, 32) != Result.Success) { return(false); } if (Rhino.Input.RhinoGet.GetInteger("Quantization Texture", true, ref options.DracoQuantizationBitsTexture, 8, 32) != Result.Success) { return(false); } } if (Rhino.Input.RhinoGet.GetBool("Map Rhino Z to glTF Y", true, "No", "Yes", ref options.MapRhinoZToGltfY) != Result.Success) { return(false); } return(true); } else { ExportOptionsDialog optionsDlg = new ExportOptionsDialog(); optionsDlg.RestorePosition(); Eto.Forms.DialogResult result = optionsDlg.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow); options = glTFBinExporterPlugin.GetSavedOptions(); return(result == Eto.Forms.DialogResult.Ok); } }