Beispiel #1
0
        private async Task <bool> DoExport()
        {
            Loader.SetBoolProperty(chkCopyTexturesProperty, chkCopyTextures.Checked);
            Loader.SetBoolProperty(chkHiddenProperty, chkHidden.Checked);
            Loader.SetBoolProperty(chkOnlySelectedProperty, chkOnlySelected.Checked);
            Loader.SetBoolProperty(chkManifestProperty, chkManifest.Checked);
            Loader.SetBoolProperty(chkAutoSaveProperty, chkAutoSave.Checked);
            Loader.SetBoolProperty(chkOptimizeVerticesProperty, chkOptimizeVertices.Checked);
            Loader.SetBoolProperty(chkExportTangentsProperty, chkExportTangents.Checked);
            //Loader.SetBoolProperty(chkDracoCompressionProperty, chkDracoCompression.Checked);
            Loader.SetBoolProperty(chkExportSkinProperty, chkExportSkin.Checked);
            Loader.SetBoolProperty(chkExportMorphNormalProperty, chkExportMorphNormal.Checked);
            Loader.SetBoolProperty(chkExportMorphTangentProperty, chkExportMorphTangent.Checked);
            Loader.SetBoolProperty(chkExportKHRLightsPunctualProperty, chkExportKHRLightsPunctual.Checked);
            Loader.SetBoolProperty(chkExportKHRTextureTransformProperty, chkExportKHRTextureTransform.Checked);
            Loader.SetBoolProperty(chkBakeAnimationFramesProperty, chkBakeAnimationFrames.Checked);

            Loader.SetBoolProperty(PBRFullPropertyName, chkFullPBR.Checked);
            Loader.SetBoolProperty(PBRNoLightPropertyName, chkNoAutoLight.Checked);
            Loader.SetBoolProperty(PBRDefaultSkyboxName, chkDefaultSkybox.Checked);

            /*Tools.UpdateComboBox(comboOutputFormat, Loader.Core.RootNode, "babylonjs_outputFormat");
             *
             * Loader.Core.RootNode.SetLocalData(txtFilename.Text);*/

            exporter = new BabylonExporter();

            treeView.Nodes.Clear();

            exporter.OnExportProgressChanged += progress =>
            {
                progressBar.Value = progress;
                Application.DoEvents();
            };

            exporter.OnWarning += (warning, rank) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, warning, Color.DarkOrange);
                    currentNode.EnsureVisible();
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnError += (error, rank) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, error, Color.Red);
                    currentNode.EnsureVisible();
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnMessage += (message, color, rank, emphasis) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, message, color);

                    if (emphasis)
                    {
                        currentNode.EnsureVisible();
                    }
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnVerbose += (message, color, rank, emphasis) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, message, color);

                    if (emphasis)
                    {
                        currentNode.EnsureVisible();
                    }
                }
                catch
                {
                }
                Application.DoEvents();
            };

            butExport.Enabled       = false;
            butExportAndRun.Enabled = false;
            butCancel.Enabled       = true;

            bool success = true;

            try
            {
                var scaleFactorParsed    = 1.0f;
                var textureQualityParsed = 100L;
                var exportParameters     = new ExportParameters
                {
                    outputPath                = txtFilename.Text,
                    outputFormat              = comboOutputFormat.SelectedItem.ToString(),
                    generateManifest          = chkManifest.Checked,
                    exportOnlySelected        = chkOnlySelected.Checked,
                    autoSaveSceneFile         = chkAutoSave.Checked,
                    exportHiddenObjects       = chkHidden.Checked,
                    writeTextures             = chkCopyTextures.Checked,
                    overwriteTextures         = chkCopyTextures.Checked,
                    optimizeVertices          = chkOptimizeVertices.Checked,
                    exportTangents            = chkExportTangents.Checked,
                    scaleFactor               = float.TryParse(txtScaleFactor.Text, out scaleFactorParsed) ? scaleFactorParsed : 1.0f,
                    exportSkins               = chkExportSkin.Checked,
                    txtQuality                = long.TryParse(txtQuality.Text, out textureQualityParsed) ? textureQualityParsed : 100,
                    dracoCompression          = chkDracoCompression.Checked,
                    exportMorphNormals        = chkExportMorphNormal.Checked,
                    exportMorphTangents       = chkExportMorphTangent.Checked,
                    enableKHRLightsPunctual   = chkExportKHRLightsPunctual.Checked,
                    enableKHRTextureTransform = chkExportKHRTextureTransform.Checked,
                    bakeAnimationFrames       = chkBakeAnimationFrames.Checked,
                    pbrFull             = chkFullPBR.Checked,
                    pbrNoLight          = chkNoAutoLight.Checked,
                    createDefaultSkybox = chkDefaultSkybox.Checked,
                    pbrEnvironment      = txtEnvironmentName.Text
                };
                exporter.Export(exportParameters);
            }
            catch (OperationCanceledException)
            {
                progressBar.Value = 0;
                success           = false;
            }
            catch (Exception ex)
            {
                currentNode = CreateTreeNode(0, "Export cancelled: " + ex.Message + " " + ex.StackTrace, Color.Red);

                currentNode.EnsureVisible();
                progressBar.Value = 0;
                success           = false;
            }

            butCancel.Enabled       = false;
            butExport.Enabled       = true;
            butExportAndRun.Enabled = WebServer.IsSupported;

            BringToFront();

            return(success);
        }
Beispiel #2
0
        private async Task <bool> DoExport()
        {
            /*Tools.UpdateCheckBox(chkManifest, Loader.Core.RootNode, "babylonjs_generatemanifest");
             * Tools.UpdateCheckBox(chkCopyTextures, Loader.Core.RootNode, "babylonjs_copytextures");
             * Tools.UpdateCheckBox(chkHidden, Loader.Core.RootNode, "babylonjs_exporthidden");
             * Tools.UpdateCheckBox(chkAutoSave, Loader.Core.RootNode, "babylonjs_autosave");
             * Tools.UpdateCheckBox(chkOnlySelected, Loader.Core.RootNode, "babylonjs_onlySelected");
             * Tools.UpdateComboBox(comboOutputFormat, Loader.Core.RootNode, "babylonjs_outputFormat");
             *
             * Loader.Core.RootNode.SetLocalData(txtFilename.Text);*/

            exporter = new BabylonExporter();

            treeView.Nodes.Clear();

            exporter.OnImportProgressChanged += progress =>
            {
                progressBar.Value = progress;
                Application.DoEvents();
            };

            exporter.OnWarning += (warning, rank) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, warning, Color.DarkOrange);
                    currentNode.EnsureVisible();
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnError += (error, rank) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, error, Color.Red);
                    currentNode.EnsureVisible();
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnMessage += (message, color, rank, emphasis) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, message, color);

                    if (emphasis)
                    {
                        currentNode.EnsureVisible();
                    }
                }
                catch
                {
                }
                Application.DoEvents();
            };

            butExport.Enabled       = false;
            butExportAndRun.Enabled = false;
            butCancel.Enabled       = true;

            bool success = true;

            try
            {
                exporter.AutoSaveMayaFile     = chkAutoSave.Checked;
                exporter.ExportHiddenObjects  = chkHidden.Checked;
                exporter.CopyTexturesToOutput = chkCopyTextures.Checked;
                var directoryName = Path.GetDirectoryName(txtFilename.Text);
                var fileName      = Path.GetFileName(txtFilename.Text);
                exporter.Export(directoryName, fileName, comboOutputFormat.SelectedItem.ToString(), chkManifest.Checked, chkOnlySelected.Checked, chkAutoSave.Checked, chkHidden.Checked, chkCopyTextures.Checked);
            }
            catch (OperationCanceledException)
            {
                progressBar.Value = 0;
                success           = false;
            }
            catch (Exception ex)
            {
                currentNode = CreateTreeNode(0, "Exportation cancelled: " + ex.Message, Color.Red);

                currentNode.EnsureVisible();
                progressBar.Value = 0;
                success           = false;
            }

            butCancel.Enabled       = false;
            butExport.Enabled       = true;
            butExportAndRun.Enabled = WebServer.IsSupported;

            BringToFront();

            return(success);
        }
Beispiel #3
0
        private async Task <bool> DoExport()
        {
            Loader.SetBoolProperty(chkCopyTexturesProperty, chkCopyTextures.Checked);
            Loader.SetBoolProperty(chkHiddenProperty, chkHidden.Checked);
            Loader.SetBoolProperty(chkOnlySelectedProperty, chkOnlySelected.Checked);
            Loader.SetBoolProperty(chkManifestProperty, chkManifest.Checked);
            Loader.SetBoolProperty(chkAutoSaveProperty, chkAutoSave.Checked);
            Loader.SetBoolProperty(chkOptimizeVerticesProperty, chkOptimizeVertices.Checked);
            Loader.SetBoolProperty(chkExportTangentsProperty, chkExportTangents.Checked);
            //Loader.SetBoolProperty(chkDracoCompressionProperty, chkDracoCompression.Checked);
            Loader.SetBoolProperty(chkExportSkinProperty, chkExportSkin.Checked);
            Loader.SetBoolProperty(chkExportMorphNormalProperty, chkExportMorphNormal.Checked);
            Loader.SetBoolProperty(chkExportMorphTangentProperty, chkExportMorphTangent.Checked);
            Loader.SetBoolProperty(chkExportKHRLightsPunctualProperty, chkExportKHRLightsPunctual.Checked);
            Loader.SetBoolProperty(chkExportKHRTextureTransformProperty, chkExportKHRTextureTransform.Checked);
            Loader.SetBoolProperty(chkBakeAnimationFramesProperty, chkBakeAnimationFrames.Checked);

            /*Tools.UpdateComboBox(comboOutputFormat, Loader.Core.RootNode, "babylonjs_outputFormat");
             *
             * Loader.Core.RootNode.SetLocalData(txtFilename.Text);*/

            exporter = new BabylonExporter();

            treeView.Nodes.Clear();

            exporter.OnExportProgressChanged += progress =>
            {
                progressBar.Value = progress;
                Application.DoEvents();
            };

            exporter.OnWarning += (warning, rank) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, warning, Color.DarkOrange);
                    currentNode.EnsureVisible();
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnError += (error, rank) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, error, Color.Red);
                    currentNode.EnsureVisible();
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnMessage += (message, color, rank, emphasis) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, message, color);

                    if (emphasis)
                    {
                        currentNode.EnsureVisible();
                    }
                }
                catch
                {
                }
                Application.DoEvents();
            };

            exporter.OnVerbose += (message, color, rank, emphasis) =>
            {
                try
                {
                    currentNode = CreateTreeNode(rank, message, color);

                    if (emphasis)
                    {
                        currentNode.EnsureVisible();
                    }
                }
                catch
                {
                }
                Application.DoEvents();
            };

            butExport.Enabled       = false;
            butExportAndRun.Enabled = false;
            butCancel.Enabled       = true;

            bool success = true;

            try
            {
                var directoryName = Path.GetDirectoryName(txtFilename.Text);
                var fileName      = Path.GetFileName(txtFilename.Text);
                exporter.Export(outputDirectory: directoryName, outputFileName: fileName, outputFormat: comboOutputFormat.SelectedItem.ToString(), generateManifest: chkManifest.Checked,
                                onlySelected: chkOnlySelected.Checked, autoSaveMayaFile: chkAutoSave.Checked, exportHiddenObjects: chkHidden.Checked, copyTexturesToOutput: chkCopyTextures.Checked,
                                optimizeVertices: chkOptimizeVertices.Checked, exportTangents: chkExportTangents.Checked, scaleFactor: txtScaleFactor.Text, exportSkin: chkExportSkin.Checked,
                                quality: txtQuality.Text, dracoCompression: chkDracoCompression.Checked, exportMorphNormal: chkExportMorphNormal.Checked, exportMorphTangent: chkExportMorphTangent.Checked,
                                exportKHRLightsPunctual: chkExportKHRLightsPunctual.Checked, exportKHRTextureTransform: chkExportKHRTextureTransform.Checked, bakeAnimationFrames: chkBakeAnimationFrames.Checked);
            }
            catch (OperationCanceledException)
            {
                progressBar.Value = 0;
                success           = false;
            }
            catch (Exception ex)
            {
                currentNode = CreateTreeNode(0, "Export cancelled: " + ex.Message + " " + ex.StackTrace, Color.Red);

                currentNode.EnsureVisible();
                progressBar.Value = 0;
                success           = false;
            }

            butCancel.Enabled       = false;
            butExport.Enabled       = true;
            butExportAndRun.Enabled = WebServer.IsSupported;

            BringToFront();

            return(success);
        }