Exemplo n.º 1
0
        public override void SaveFile(string sNewPath)
        {
            try {
                DebugUtil.Log(1, "Saving scene to path " + sNewPath);

                SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;

                if (!sNewPath.EndsWith(".xml", StringComparison.InvariantCultureIgnoreCase))
                {
                    sNewPath += ".xml";
                }

                XMLOutputStream stream = new XMLOutputStream(XmlTextWriter.Create(sNewPath,
                                                                                  new XmlWriterSettings()
                {
                    Indent = true, NewLineOnAttributes = true
                }));
                stream.Writer.WriteStartDocument();
                SceneSerializer serializer = new SceneSerializer();
                serializer.TargetFilePath = sNewPath;
                serializer.Store(stream, ActiveCockpit.Scene);
                stream.Writer.WriteEndDocument();

                stream.Writer.Close();

                ActiveCockpit.Context.PopCockpit(true);
            } catch (Exception e) {
                Debug.Log("[SaveScene] save of " + sNewPath + " failed: " + e.Message);
                HUDUtil.ShowCenteredPopupMessage("Save Failed", "Sorry, could not save to path " + sNewPath, ActiveCockpit);
            }
        }
Exemplo n.º 2
0
        public override void LoadFile(string sNewPath)
        {
            // save this path because it is super-annoying otherwise...
            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;
            FContext controller = ActiveCockpit.Context;

            // read xml
            try {
                DebugUtil.Log(1, "Loading scene from path " + sNewPath);

                XmlDocument doc = new XmlDocument();
                doc.Load(sNewPath);
                XMLInputStream stream = new XMLInputStream()
                {
                    xml = doc
                };
                SceneSerializer serializer = new SceneSerializer();
                serializer.TargetFilePath = sNewPath;
                serializer.SOFactory      = new SOFactory();
                serializer.Restore(stream, ActiveCockpit.Scene);

                // once we have opened file, done with cockpit
                controller.PopCockpit(true);
            } catch (Exception e) {
                Debug.Log("[LoadScene] read failed: " + e.Message);
                HUDUtil.ShowCenteredPopupMessage("Load Failed!", "Sorry could not load scene " + sNewPath, ActiveCockpit);
            }
        }
Exemplo n.º 3
0
        public override void SaveFile(string sNewPath)
        {
            DebugUtil.Log(1, "Exporting scene to path " + sNewPath);

            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;

            string            sSavePath = Path.Combine(ListView.FolderPath, sNewPath);
            SceneMeshExporter export    = new SceneMeshExporter();

            export.WriteInBackgroundThreads = true;
            export.BackgroundWriteCompleteF = (exp, status) => {
                if (status.Ok)
                {
                    ActiveCockpit.Context.RegisterNextFrameAction(() => {
                        ActiveCockpit.Context.PopCockpit(true);
                    });
                }
                else
                {
                    ActiveCockpit.Context.RegisterNextFrameAction(() => {
                        Debug.Log("[ExportScene] save at " + sNewPath + " failed: " + export.LastErrorMessage);
                        HUDUtil.ShowCenteredPopupMessage("Export Failed", "Sorry, could not export to path " + sNewPath, ActiveCockpit);
                    });
                }
            };
            export.Export(ActiveCockpit.Context.Scene, sSavePath);
        }
Exemplo n.º 4
0
        public override void LoadFile(string sNewPath)
        {
            // save this path because it is super-annoying otherwise...
            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;
            if (IsMeshFile(sNewPath))
            {
                FContext controller = ActiveCockpit.Context;

                // read mesh file
                SceneMeshImporter import = new SceneMeshImporter();
                bool bOK = import.ReadFile(sNewPath);
                if (bOK == false && import.LastReadResult.code != IOCode.Ok)
                {
                    Debug.Log("[Import] import failed: " + import.LastReadResult.message);
                    HUDUtil.ShowCenteredPopupMessage("Import Failed!", "Sorry, could not import " + sNewPath, ActiveCockpit);
                    return;
                }
                import.AppendReadMeshesToScene(controller.Scene, true);
                // save undo/redo checkpoint
                controller.Scene.History.PushInteractionCheckpoint();

                // once we have opened file, done with cockpit
                controller.PopCockpit(true);

                // emit this message after we pop cockpit
                if (import.SomeMeshesTooLargeForUnityWarning)
                {
                    Debug.Log("[Import] some meshes too large! ignored!");
                    MessageStream.Get.AddMessage(new Message()
                    {
                        Type = Message.Types.Warning, Code = FileBrowserMessageCodes.MESHES_TOO_LARGE
                    });
                }
            }
        }
Exemplo n.º 5
0
        public override void SaveFile(string sNewPath)
        {
            DebugUtil.Log(1, "Exporting scene to path " + sNewPath);
            SceneGraphConfig.LastFileOpenPath = ListView.FolderPath;

            string sTargetFolder = "";
            bool   use_auto      = sNewPath.EndsWith(GetDefaultFileName());

            if (use_auto == false)
            {
                sTargetFolder = Path.GetFileName(sNewPath);
            }

            string          sSavePath = Path.Combine(ListView.FolderPath, sNewPath);
            JanusVRExporter export    = new JanusVRExporter()
            {
                GlobalTranslation = -20 * Vector3f.AxisZ
            };

            export.WriteInBackgroundThreads = true;
            export.BackgroundWriteCompleteF = (exp, status) => {
                if (status.Ok)
                {
                    ActiveCockpit.Context.RegisterNextFrameAction(() => {
                        FContext context = ActiveCockpit.Context;
                        ActiveCockpit.Context.PopCockpit(true);
                        //HUDUtil.ShowCenteredPopupMessage("Done!", "Exported to subfolder " + export.ExportPath, context.ActiveCockpit);
                        HUDUtil.ShowToastPopupMessage("Exported JanusVR Room to subfolder " + export.ExportPath, context.ActiveCockpit, 1.25f, 0.8f);
                    });
                }
                else
                {
                    ActiveCockpit.Context.RegisterNextFrameAction(() => {
                        Debug.Log("[JanusExportScene] save at " + sNewPath + " failed: " + export.LastErrorMessage);
                        HUDUtil.ShowCenteredPopupMessage("Export Failed", "Sorry, could not export to path " + sNewPath, ActiveCockpit);
                    });
                }
            };
            export.Export(ActiveCockpit.Context.Scene, ListView.FolderPath, sTargetFolder);
        }