Example #1
0
        public void AfterLoadScene()
        {
            CreateGizmo();
            GizmoMode = EditorTools.Select;
            ViewportEditor.ResetCommonValues();

            if (ActiveViewport == null)
            {
                Mogre.NameValuePairList parameters = new Mogre.NameValuePairList();
                parameters.Clear();
                parameters["Name"]   = "Viewport1";
                parameters["Colour"] = "0 0 0";
                parameters["Index"]  = "1";
                ActiveViewport       = CreateEditorObject(null, "Viewport Object", parameters, false, false) as ViewportEditor;
            }

            system.UpdateLoadProgress(60, "Loading scene objects");

            this.rootEditor.Load();
            this.rootEditor.LoadAllChildren();

            if (SceneUpdated != null)
            {
                SceneUpdated(this, new SceneUpdatedEventArgs(SceneManager, ActiveViewport.CameraEditor.Camera, RenderTarget));
            }
            SceneUpdated = null;

            FillTreeView();

            system.UpdateLoadProgress(100, "Rendering...");

            IsSceneLoaded   = true;
            IsSceneModified = false;

            if (SceneLoaded != null)
            {
                SceneLoaded(this, EventArgs.Empty);
            }
        }
Example #2
0
        public override SceneFileResult Import(string importFile)
        {
            MogitorsRoot   mogRoot = MogitorsRoot.Instance;
            MogitorsSystem system  = MogitorsSystem.Instance;

            if (importFile == "")
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName   = "";
                dlg.DefaultExt = ".mogscene";
                dlg.Filter     = "Mogitor Scene File (.mogscene)|*.mogscene";
                Nullable <bool> result = dlg.ShowDialog();
                if (result != true)
                {
                    return(SceneFileResult.Cancel);
                }
                importFile = dlg.FileName;
            }

            string filePath = system.ExtractFilePath(importFile);
            string fileName = system.ExtractFileName(importFile);

            XmlTextReader textReader = new XmlTextReader(importFile);

            system.UpdateLoadProgress(5, "Loading scene objects");

            if (!textReader.ReadToFollowing("MogitorScene"))
            {
                return(SceneFileResult.ErrParse);
            }

            // Check version
            string fileVersion = textReader.GetAttribute("Version");

            if (fileVersion != null)
            {
                if (int.Parse(fileVersion) != 1)
                {
                    return(SceneFileResult.ErrParse);
                }
            }

            // Read project options
            if (textReader.ReadToFollowing("ProjectOptions") == true)
            {
                system.UpdateLoadProgress(15, "Parsing project options");
                mogRoot.LoadProjectOptions(textReader);

                mogRoot.ProjectOptions.ProjectDir  = filePath;
                mogRoot.ProjectOptions.ProjectName = fileName;

                mogRoot.PrepareProjectResources();
            }

            //// Moves the reader back to the "MogitorScene" element node.
            //textReader.MoveToElement();

            system.UpdateLoadProgress(30, "Creating scene objects");

            // Load objects
            Mogre.NameValuePairList param = new Mogre.NameValuePairList();
            while (textReader.ReadToNextSibling("Object"))
            {
                string objectType = textReader.GetAttribute("Type");
                if (objectType == "")
                {
                    continue;
                }

                param.Clear();
                while (textReader.MoveToNextAttribute())
                {
                    param.Insert(textReader.Name, textReader.Value);
                }

                BaseEditor result = MogitorsRoot.Instance.CreateEditorObject(null, objectType, param, false, false);
            }

            mogRoot.AfterLoadScene();

            return(SceneFileResult.Ok);
        }