Beispiel #1
0
        MogitorsRoot()
        {
            this.system = MogitorsSystem.Instance;
            this.namesByType = new NameObjectPairList[(int)EditorType.LastEditor];
            for (int i = 0; i < this.namesByType.Count(); ++i)
            {
                this.namesByType[i] = new NameObjectPairList();
            }
            this.namesByTypeID = new NameObjectPairList[MogitorSettings.Instance.MaxObjectType];
            for (int i = 0; i < this.namesByTypeID.Count(); ++i)
            {
                this.namesByTypeID[i] = new NameObjectPairList();
            }

            IsSceneLoaded = false;
            IsSceneModified = false;

            RegisterAllEditorObjects();
            BaseEditor nullParent = null;
            this.rootEditor = BaseEditor.Factory.CreateObject(ref nullParent, null);

            this.objectDisplayOrder.Clear();
            this.objectDisplayOrder.Add(EditorType.Viewport);
            this.objectDisplayOrder.Add(EditorType.SceneManager);
            this.objectDisplayOrder.Add(EditorType.CustomNamanger);
            this.objectDisplayOrder.Add(EditorType.Light);
            this.objectDisplayOrder.Add(EditorType.Camera);
            for (EditorType type = EditorType.Camera + 1; type < EditorType.LastEditor; ++type)
                this.objectDisplayOrder.Add(type);
            this.objectDisplayOrder.Add(EditorType.Node);

            IsClearScreenNeeded = false;

            ProjectOptions = new ProjectOptions();
        }
        public SettingsDialog(ProjectOptions options)
        {
            InitializeComponent();

            ShowInTaskbar = false;

            Options = options;

            foreach (string value in Options.ResourceDirectories)
            {
                if (value.Contains("FS:") == true)
                {
                    lbResources.Items.Add(value.Remove(0, 3));
                    resourceFileTypes.Add(1);
                }
                else if (value.Contains("ZP:") == true)
                {
                    lbResources.Items.Add(value.Remove(0, 3));
                    resourceFileTypes.Add(2);
                }
            }
        }
Beispiel #3
0
        private void CreateViewport()
        {
            Mogre.NameValuePairList parameters = new Mogre.NameValuePairList();

            parameters["Name"]         = "intViewCamera" + Mogre.StringConverter.ToString(ViewportIndex);
            parameters["ClipDistance"] = "0.1 40000";

            BaseEditor scnMgr = MogitorsRoot.Instance.SceneManagerEditor;

            ViewCamera = CameraEditor.Factory.CreateObject(ref scnMgr, parameters) as CameraEditor;
            ViewCamera.Load();

            this.handle = MogitorsRoot.Instance.RenderTarget.AddViewport(ViewCamera.Camera, (int)ViewportIndex,
                                                                         dimensions.x, dimensions.y, dimensions.z, dimensions.w);

            if (Name == "")
            {
                this.name = "Viewport" + Mogre.StringConverter.ToString(ViewportIndex);
            }

            ViewCamera.Camera.AspectRatio = (float)this.handle.ActualWidth / (float)this.handle.ActualHeight;
            ViewCamera.ShowHelper         = false;

            ActiveCamera = ViewCamera;
            this.handle.BackgroundColour = this.colour;

            PopCompositors();

            ProjectOptions opt = MogitorsRoot.Instance.ProjectOptions;

            if (opt.Cameras.Count > 0)
            {
                ViewCamera.Position    = opt.Cameras[opt.Cameras.Count - 1].Position;
                ViewCamera.Orientation = opt.Cameras[opt.Cameras.Count - 1].Orientation;
            }

            LoadEditorObjects();
        }
Beispiel #4
0
        MogitorsRoot()
        {
            this.system      = MogitorsSystem.Instance;
            this.namesByType = new NameObjectPairList[(int)EditorType.LastEditor];
            for (int i = 0; i < this.namesByType.Count(); ++i)
            {
                this.namesByType[i] = new NameObjectPairList();
            }
            this.namesByTypeID = new NameObjectPairList[MogitorSettings.Instance.MaxObjectType];
            for (int i = 0; i < this.namesByTypeID.Count(); ++i)
            {
                this.namesByTypeID[i] = new NameObjectPairList();
            }

            IsSceneLoaded   = false;
            IsSceneModified = false;

            RegisterAllEditorObjects();
            BaseEditor nullParent = null;

            this.rootEditor = BaseEditor.Factory.CreateObject(ref nullParent, null);

            this.objectDisplayOrder.Clear();
            this.objectDisplayOrder.Add(EditorType.Viewport);
            this.objectDisplayOrder.Add(EditorType.SceneManager);
            this.objectDisplayOrder.Add(EditorType.CustomNamanger);
            this.objectDisplayOrder.Add(EditorType.Light);
            this.objectDisplayOrder.Add(EditorType.Camera);
            for (EditorType type = EditorType.Camera + 1; type < EditorType.LastEditor; ++type)
            {
                this.objectDisplayOrder.Add(type);
            }
            this.objectDisplayOrder.Add(EditorType.Node);

            IsClearScreenNeeded = false;

            ProjectOptions = new ProjectOptions();
        }
Beispiel #5
0
        public override SceneFileResult Export(bool saveAs)
        {
            MogitorsRoot   mogRoot = MogitorsRoot.Instance;
            MogitorsSystem system  = MogitorsSystem.Instance;

            ProjectOptions opt      = mogRoot.ProjectOptions;
            string         fileName = system.CombinePath(opt.ProjectDir, opt.ProjectName + ".mogscene");

            // If saveAs is true, use the MogitorsSystem Function to retrieve
            // a FileName and also copy the contents of current scene to the new location
            if (saveAs)
            {
                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);
                }

                fileName = dlg.FileName;

                string oldProjDir  = opt.ProjectDir;
                string oldProjName = opt.ProjectName;

                opt.ProjectName = system.ExtractFileName(fileName);
                opt.ProjectDir  = system.ExtractFilePath(fileName);

                mogRoot.AdjustUserResourceDirectories(oldProjDir);

                string newDir = opt.ProjectDir;

                system.MakeDirectory(newDir);
                system.CopyFilesEx(oldProjDir, newDir);

                string delFileStr = system.GetFullPath(system.CombinePath(opt.ProjectDir, oldProjName + ".mogscene"));
                system.DeleteFile(delFileStr);
            }

            XmlTextWriter textWriter = new XmlTextWriter(fileName, System.Text.Encoding.Unicode);

            textWriter.Formatting = Formatting.Indented;
            textWriter.WriteStartDocument();
            textWriter.WriteStartElement("MogitorScene");
            mogRoot.WriteProjectOptions(textWriter, true);

            ObjectVector objectList = new ObjectVector();

            for (EditorType type = 0; type < EditorType.LastEditor; ++type)
            {
                mogRoot.GetObjectList(type, objectList);
                foreach (BaseEditor obj in objectList)
                {
                    // If object does not have a parent, then it is not part of the scene
                    if (obj.Parent == null)
                    {
                        continue;
                    }

                    if (obj.IsSerializable)
                    {
                        textWriter.WriteStartElement("Object");
                        textWriter.WriteStartAttribute("Type");
                        textWriter.WriteValue(obj.ObjectTypeName);
                        textWriter.WriteEndAttribute();

                        // If obj's parent name is "" then the parent is this.rootEditor
                        if (obj.Parent.Name != "")
                        {
                            textWriter.WriteStartAttribute("ParentNode");
                            textWriter.WriteValue(obj.Parent.Name);
                            textWriter.WriteEndAttribute();
                        }
                        Mogre.NameValuePairList theList = new Mogre.NameValuePairList();
                        obj.GetObjectProperties(theList);
                        foreach (KeyValuePair <string, string> it in theList)
                        {
                            textWriter.WriteStartAttribute(it.Key);
                            textWriter.WriteValue(it.Value);
                            textWriter.WriteEndAttribute();
                        }
                        textWriter.WriteEndElement();
                    }
                    obj.OnSave();
                }
            }

            textWriter.WriteEndElement();
            textWriter.WriteEndDocument();
            textWriter.Close();

            mogRoot.IsSceneModified = false;

            if (saveAs)
            {
                mogRoot.TerminateScene();
                mogRoot.LoadScene(fileName);
            }
            return(SceneFileResult.Ok);
        }