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); if (!GetExportOptions(mode, out glTFExportOptions opts)) { return(Result.Cancel); } Rhino.DocObjects.RhinoObject[] rhinoObjects = go.Objects().Select(o => o.Object()).ToArray(); if (!DoExport(dialog.FileName, opts, binary, doc, rhinoObjects, doc.RenderSettings.LinearWorkflow)) { return(Result.Failure); } return(Result.Success); }
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 Gltf ConvertToGltf() { dummy.Scene = 0; dummy.Scenes.Add(new gltfSchemaSceneDummy()); dummy.Asset = new Asset() { Version = "2.0", }; dummy.Samplers.Add(new Sampler() { MinFilter = Sampler.MinFilterEnum.LINEAR, MagFilter = Sampler.MagFilterEnum.LINEAR, WrapS = Sampler.WrapSEnum.REPEAT, WrapT = Sampler.WrapTEnum.REPEAT, }); if (options.UseDracoCompression) { dummy.ExtensionsUsed.Add(Constants.DracoMeshCompressionExtensionTag); dummy.ExtensionsRequired.Add(Constants.DracoMeshCompressionExtensionTag); } var sanitized = GlTFUtils.SanitizeRhinoObjects(objects); foreach (ObjectExportData exportData in sanitized) { if (options.UseDracoCompression) { AddRhinoObjectDraco(exportData); } else { if (binary) { AddRhinoObjectBinary(exportData); } else { AddRhinoObjectText(exportData); } } } if (binary && binaryBuffer.Count > 0) { //have to add the empty buffer for the binary file header dummy.Buffers.Add(new glTFLoader.Schema.Buffer() { ByteLength = (int)binaryBuffer.Count, Uri = null, }); } return(dummy.ToSchemaGltf()); }
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); }
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); }