Пример #1
0
        protected override void DisplayOptionsDialog(IntPtr parent, string description, string extension)
        {
            ExportOptionsDialog exportOptionsDialog = new ExportOptionsDialog();

            exportOptionsDialog.RestorePosition();
            exportOptionsDialog.ShowModal(Rhino.UI.RhinoEtoApp.MainWindow);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
        protected override void DisplayOptionsDialog(IntPtr parent, string description, string extension)
        {
            ExportOptionsDialog exportOptionsDialog = new ExportOptionsDialog();

            exportOptionsDialog.ShowModal();
        }
Пример #6
0
        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);
            }
        }