コード例 #1
0
ファイル: Actions_Scene.cs プロジェクト: tomleetv/Cotangent
        public static async void DoFileOpen(string sFilename, bool bInteractive, Action <string> onCompletedF = null)
        {
            if (string.IsNullOrEmpty(sFilename))
            {
                return;
            }
            if (File.Exists(sFilename) == false)
            {
                CotangentUI.ShowModalMessageDialog("File Does Not Exist",
                                                   "File " + sFilename + " does not exist",
                                                   "Ok", null, null);
                return;
            }

            HaveOpenedOrImportedFile = true;

            if (sFilename.EndsWith(".cota", StringComparison.OrdinalIgnoreCase))
            {
                // [TODO] make this multi threaded?
                OpenSceneFile(sFilename);
                FPlatform.SetPrefsString("LastImportPath", sFilename);
            }
            else
            {
                ClearScene();
                MeshImporter importer = new MeshImporter();
                CCStatus.BeginOperation("reading");
                await importer.ImportInteractive(sFilename, onCompletedF);

                CCStatus.EndOperation("reading");
            }
        }
コード例 #2
0
ファイル: Actions_Scene.cs プロジェクト: tomleetv/Cotangent
        public static async void run_arguments_imports(List <string> filenames)
        {
            int             count        = 0;
            Action <string> onCompletedF = (filename) => {
                count++;
            };

            CCStatus.BeginOperation("reading");

            foreach (string filename in filenames)
            {
                if (filename.Length > 0 && File.Exists(filename))
                {
                    MeshImporter importer = new MeshImporter();
                    await importer.ImportInteractive(filename, onCompletedF);
                }
            }

            CCStatus.EndOperation("reading");

            if (count > 0)
            {
                // discard history
                CC.ActiveScene.History.Clear();
            }
            else
            {
                // show an error message or something...
            }
        }
コード例 #3
0
ファイル: Actions_Scene.cs プロジェクト: tomleetv/Cotangent
        public static async void DoDragDropImport(List <string> filenames)
        {
            List <string> meshFiles, sceneFiles;

            get_valid_filenames(filenames, out meshFiles, out sceneFiles);

            if (sceneFiles.Count > 0)
            {
                HaveOpenedOrImportedFile = true;
                DoDragDropOpen(sceneFiles);
            }

            int             count        = 0;
            Action <string> onCompletedF = (filename) => {
                count++;
            };

            if (CurrentSceneIsStartupScene)
            {
                ClearScene();
            }
            HaveOpenedOrImportedFile = true;

            CC.Slicer.InvalidateSlicing();

            CCStatus.BeginOperation("reading");

            foreach (string filename in filenames)
            {
                if (filename.Length > 0 && File.Exists(filename))
                {
                    MeshImporter importer = new MeshImporter();
                    await importer.ImportInteractive(filename, onCompletedF);
                }
            }

            CCStatus.EndOperation("reading");

            if (count > 0)
            {
                CC.ActiveScene.History.PushInteractionCheckpoint();
                CCActions.UpdateViewClippingBounds();
            }
            else
            {
                // show an error message or something...
            }
        }
コード例 #4
0
ファイル: Actions_Tool.cs プロジェクト: tomleetv/Cotangent
        public static void CancelCurrentTool()
        {
            if (InTool == false)
            {
                return;
            }

            if (CCStatus.InOperation)
            {
                CCStatus.EndOperation("working...");
            }
            CC.ActiveContext.ToolManager.DeactivateTool(ToolSide.Right);

            // run gc
            FPlatform.SuggestGarbageCollection();
        }
コード例 #5
0
ファイル: Actions_Tool.cs プロジェクト: tomleetv/Cotangent
        public static void UpdateCurrentToolStatus()
        {
            // [RMS] this is a quick-and-dirty way to give some feedback when computing ops.
            // todo: improve in future!
            ITool active = CC.ActiveContext.ToolManager.GetActiveTool(ToolSide.Right);

            if (active != null && active.Parameters.HasParameter("computing"))
            {
                bool computing = active.Parameters.GetValueBool("computing");
                if (CCStatus.InOperation == false && computing)
                {
                    CCStatus.BeginOperation("working...");
                }
                else if (CCStatus.InOperation == true && computing == false)
                {
                    CCStatus.EndOperation("working...");
                }
            }
        }
コード例 #6
0
ファイル: MeshImporter.cs プロジェクト: tomleetv/Cotangent
        async Task process_and_complete_import(string sFilename, DMesh3Builder builder,
                                               double targetHeight, int reduceToCount,
                                               Action <string> onCompletedF)
        {
            CCStatus.BeginOperation("processing");

            await Task.Run(() => {
                if (targetHeight > 0.001 && Math.Abs(targetHeight - Bounds.Height) > 0.001)
                {
                    double scaleH = targetHeight / Bounds.Height;
                    Vector3d o    = Bounds.Center - Bounds.Extents.y *Vector3d.AxisY;
                    foreach (var mesh in builder.Meshes)
                    {
                        MeshTransforms.Scale(mesh, scaleH *Vector3d.One, o);
                    }
                }
            });

            await Task.Run(() => {
                if (reduceToCount != -1 && reduceToCount < TriCount)
                {
                    foreach (var mesh in builder.Meshes)
                    {
                        if (mesh.TriangleCount < 10)
                        {
                            continue;
                        }
                        double tri_fraction = (double)mesh.TriangleCount / (double)TriCount;
                        int NT = (int)(tri_fraction *reduceToCount);
                        if (NT < 10)
                        {
                            NT = 10;
                        }
                        Reducer r = new Reducer(mesh);
                        r.ReduceToTriangleCount(NT);
                    }
                }
            });

            CCStatus.EndOperation("processing");

            await complete_import(sFilename, builder, onCompletedF);
        }