Пример #1
0
        public override void DestroyObject(BaseEditor _object)
        {
            ViewportEditor editor = _object as ViewportEditor;

            MogitorsRoot.Instance.IsClearScreenNeeded = true;

            editor.DestroyAllChildren();
            editor.UnLoad();

            if (editor.Name != "")
            {
                MogitorsRoot.Instance.UnRegisterObjectName(editor.Name, editor);
            }

            InstanceCount--;

            NameObjectPairList viewports = MogitorsRoot.Instance.GetObjectsByType(EditorType.Viewport);

            lastZOrder = 0;
            foreach (ViewportEditor viewport in viewports.Values)
            {
                if (viewport.ViewportIndex > lastZOrder)
                {
                    lastZOrder = viewport.ViewportIndex;
                }
            }
        }
Пример #2
0
        public override BaseEditor CreateObject(ref BaseEditor parent, NameValuePairList parameters)
        {
            ViewportEditor obj = new ViewportEditor();

            Mogre.NameValuePairList.Iterator ni;
            if ((ni = parameters.Find("ViewportIndex")) != parameters.End())
            {
                obj.ViewportIndex = (uint)Mogre.StringConverter.ParseInt(ni.Value);
                if (lastZOrder < obj.ViewportIndex)
                {
                    lastZOrder = obj.ViewportIndex;
                }
            }
            else
            {
                obj.ViewportIndex = ++lastZOrder;
            }

            if (obj.ViewportIndex == 1)
            {
                MogitorsRoot.Instance.ActiveViewport = obj;
            }

            parent     = MogitorsRoot.Instance.RootEditor;
            obj.Parent = parent;
            obj.ProcessParameters(parameters);
            obj.Load();

            InstanceCount++;
            return(obj);
        }
Пример #3
0
        public void OnMouseMiddleDown(Mogre.Vector2 point, MouseDevice mouseDevice)
        {
            ViewportEditor vp = GetViewportEditorFromPoint(point);

            if (vp != null)
            {
                ActiveViewport = vp;

                Mogre.Vector4 rect = new Mogre.Vector4();
                ActiveViewport.GetRect(ref rect);
                ActiveViewport.OnMouseMiddleDown(point - new Mogre.Vector2(rect.x, rect.y), mouseDevice);
            }
        }
        public void DestroyEditorObject(BaseEditor obj, bool removeFromTreeList)
        {
            // Index0 Viewport can not be deleted
            if (obj.EditorType == EditorType.Viewport)
            {
                ViewportEditor viewport = obj as ViewportEditor;

                if (viewport.ViewportIndex == 1)
                {
                    MogitorsSystem.Instance.DisplayMessageDialog("Can not delete the main viewport!!", System.Windows.MessageBoxButton.OK);
                    return;
                }

                if (ActiveViewport == viewport)
                {
                    foreach (var vt in this.namesByType[(int)EditorType.Viewport])
                    {
                        if (vt.Value == obj)
                        {
                            continue;
                        }

                        ActiveViewport = vt.Value as ViewportEditor;
                        break;
                    }
                }
            }

            if (this.selectedEditor == obj)
            {
                obj.IsSelected    = false;
                obj.IsHighLighted = false;
            }

            if (removeFromTreeList)
            {
                this.system.DeleteTreeItem(obj.TreeItemHandle);
            }

            if (obj.Parent != null)
            {
                obj.Parent.RemoveChild(obj.Name);
            }

            obj.FactoryDynamic.DestroyObject(obj);

            IsSceneModified = true;
        }
Пример #5
0
        private ViewportEditor GetViewportEditorFromPoint(Mogre.Vector2 point)
        {
            Mogre.Vector4 rect = new Mogre.Vector4();

            ViewportEditor vp     = null;
            int            zOrder = -1000;

            foreach (var it in this.namesByType[(int)EditorType.Viewport])
            {
                int order = (it.Value as ViewportEditor).GetRect(ref rect);
                if (PointIsInRect(point, rect) && (order > zOrder))
                {
                    zOrder = order;
                    vp     = it.Value as ViewportEditor;
                }
            }
            return(vp);
        }
Пример #6
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);
            }
        }
Пример #7
0
        public bool OnDragOver(IDataObject data, Point pt)
        {
            Mogre.Vector4  rect = new Mogre.Vector4();
            ViewportEditor vp   = null;

            int ZOrder = -1000;

            foreach (KeyValuePair <string, BaseEditor> it in GetObjectsByType(EditorType.Viewport))
            {
                int order = ((it.Value) as ViewportEditor).GetRect(ref rect);
                if ((rect.x <= pt.X) && (rect.y <= pt.Y) && ((rect.y + rect.w) >= pt.Y) && (order > ZOrder))
                {
                    ZOrder = order;
                    vp     = (it.Value) as ViewportEditor;
                }
            }

            if (vp != null)
            {
                ActiveViewport = vp;
                ActiveViewport.GetRect(ref rect);

                DragData dragData = data.GetData(typeof(DragData)) as DragData;

                foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers)
                {
                    if (handler.Key == dragData.Source)
                    {
                        Mogre.Vector2 point = new Mogre.Vector2((float)(pt.X - rect.x) / rect.z, (float)(pt.Y - rect.y) / rect.w);
                        return(handler.Value.OnDragOver(dragData, ActiveViewport.Handle as Mogre.Viewport, point));
                    }
                }
                return(true);
            }
            return(false);
        }
Пример #8
0
        public override BaseEditor CreateObject(ref BaseEditor parent, NameValuePairList parameters)
        {
            ViewportEditor obj = new ViewportEditor();

            Mogre.NameValuePairList.Iterator ni;
            if ((ni = parameters.Find("ViewportIndex")) != parameters.End())
            {
                obj.ViewportIndex = (uint)Mogre.StringConverter.ParseInt(ni.Value);
                if (lastZOrder < obj.ViewportIndex)
                    lastZOrder = obj.ViewportIndex;
            }
            else
            {
                obj.ViewportIndex = ++lastZOrder;
            }

            if (obj.ViewportIndex == 1)
                MogitorsRoot.Instance.ActiveViewport = obj;

            parent = MogitorsRoot.Instance.RootEditor;
            obj.Parent = parent;
            obj.ProcessParameters(parameters);
            obj.Load();

            InstanceCount++;
            return obj;
        }