示例#1
0
        bool MogitorsRoot.IDragDropHandler.OnDrageEnter(DragData dragData)
        {
            IconTextItem item = dragData.SourceObject as IconTextItem;
            if (item == null)
                return false;

            BaseEditorFactory factory = MogitorsRoot.Instance.GetEditorObjectFactory(item.Name + " Object");

            if (factory == null)
                return false;

            dragData.ObjectType = factory.TypeName;

            string placeHolder = "";

            if (factory.RequirePlacement)
                placeHolder = factory.PlaceHolderName;

            if (placeHolder == "")
                return true;

            dragData.Parameters["Init"] = "true";
            dragData.Parameters["MeshFile"] = placeHolder;
            dragData.Parameters["Position"] = "999999 999999 999999";

            BaseEditor parent = MogitorsRoot.Instance.SceneManagerEditor;
            dragData.Object = EntityEditor.Factory.CreateObject(ref parent, dragData.Parameters);
            dragData.Object.Load();

            (dragData.Object.Handle as Mogre.Entity).SetMaterialName("scbMATWIREFRAME");
            (dragData.Object.Handle as Mogre.Entity).QueryFlags = 0;

            return true;
        }
        public void OnDragDrop(IDataObject data, Point pt)
        {
            Mogre.Vector4 drect = new Mogre.Vector4();
            ActiveViewport.GetRect(ref drect);
            Mogre.Vector2 dropPos = new Mogre.Vector2((float)(pt.X - drect.x) / drect.z, (float)(pt.Y - drect.y) / drect.w);

            DragData dragData = data.GetData(typeof(DragData)) as DragData;
            foreach (KeyValuePair<object, IDragDropHandler> handler in this.dragDropHandlers)
            {
                if (handler.Key == dragData.Source)
                {
                    handler.Value.OnDragDrop(dragData, ActiveViewport.Handle as Mogre.Viewport, dropPos);
                    break;
                }
            }
            this.activeDragData = null;
        }
        public void OnDragLeave(IDataObject data)
        {
            if (!data.GetDataPresent(typeof(DragData)))
            {
                return;
            }

            DragData         dragData = data.GetData(typeof(DragData)) as DragData;
            IDragDropHandler handler  = this.dragDropHandlers[dragData.Source];

            if (handler == null)
            {
                return;
            }

            handler.OnDragLeave(dragData);
            this.activeDragData = null;
        }
        public void OnDragDrop(IDataObject data, Point pt)
        {
            Mogre.Vector4 drect = new Mogre.Vector4();
            ActiveViewport.GetRect(ref drect);
            Mogre.Vector2 dropPos = new Mogre.Vector2((float)(pt.X - drect.x) / drect.z, (float)(pt.Y - drect.y) / drect.w);

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

            foreach (KeyValuePair <object, IDragDropHandler> handler in this.dragDropHandlers)
            {
                if (handler.Key == dragData.Source)
                {
                    handler.Value.OnDragDrop(dragData, ActiveViewport.Handle as Mogre.Viewport, dropPos);
                    break;
                }
            }
            this.activeDragData = null;
        }
示例#5
0
        void MogitorsRoot.IDragDropHandler.OnDragDrop(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.Object != null)
            {
                Mogre.NameValuePairList parameters = new Mogre.NameValuePairList();
                dragData.Object.GetObjectProperties(parameters);
                dragData.Object.Destroy(false);
                dragData.Object = null;

                dragData.Parameters["Position"] = parameters["Position"];

                MogitorsRoot.Instance.CreateEditorObject(null, dragData.ObjectType, dragData.Parameters, true, true);
            }

            dragData.Parameters.Clear();
            dragData.ObjectType = "";
            dragData.Object = null;
        }
示例#6
0
        bool MogitorsRoot.IDragDropHandler.OnDrageEnter(DragData dragData)
        {
            IconTextItem item = dragData.SourceObject as IconTextItem;
            if (item == null)
                return false;

            dragData.ObjectType = "Entity Object";
            dragData.Parameters["Init"] = "true";
            dragData.Parameters["MeshFile"] = item.Name + ".mesh";
            dragData.Parameters["Position"] = "999999 999999 999999";

            BaseEditor parent = MogitorsRoot.Instance.SceneManagerEditor;
            dragData.Object = EntityEditor.Factory.CreateObject(ref parent, dragData.Parameters);
            dragData.Object.Load();

            ((dragData.Object.Handle) as Mogre.Entity).SetMaterialName("scbMATWIREFRAME");
            ((dragData.Object.Handle) as Mogre.Entity).QueryFlags = 0;

            return true;
        }
        public bool OnDragEnter(IDataObject data)
        {
            if (!IsSceneLoaded)
            {
                return(false);
            }

            if (!data.GetDataPresent(typeof(DragData)))
            {
                return(false);
            }

            DragData         dragData = data.GetData(typeof(DragData)) as DragData;
            IDragDropHandler handler  = this.dragDropHandlers[dragData.Source];

            if (handler == null)
            {
                return(false);
            }

            this.activeDragData = dragData;
            return(handler.OnDrageEnter(dragData));
        }
        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);
        }
示例#9
0
        void MogitorsRoot.IDragDropHandler.OnDragWheel(DragData dragData, Mogre.Viewport vp, float delta)
        {
            if (dragData.Object == null)
                return;

            Mogre.Vector3 vPos = Mogre.Vector3.ZERO;

            PropertyInfo prop = dragData.Object.GetType().GetProperty("Position");
            if (prop != null)
                vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null);
            float distance = (vPos - vp.Camera.DerivedPosition).Length + (delta / 120.0f);

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
                return;
            else
                vPos = vp.Camera.DerivedPosition + ((vPos - vp.Camera.DerivedPosition).NormalisedCopy * distance);

            prop.SetValue(dragData.ObjectType, vPos, null);
        }
示例#10
0
        bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.ObjectType == "")
                return false;

            if (dragData.Object == null)
                return true;

            Mogre.Ray mouseRay;
            mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y);

            Mogre.Vector3 vPos = Mogre.Vector3.ZERO;
            PropertyInfo prop = dragData.Object.GetType().GetProperty("Position");
            if (prop != null)
                vPos = (Mogre.Vector3)prop.GetValue(dragData.Object, null);

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
                vPos = mouseRay.Origin + (mouseRay.Direction * 40.0f);
            else
                vPos = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(dragData.Object, mouseRay);

            if (prop != null)
                prop.SetValue(dragData.Object, vPos, null);

            return true;
        }
示例#11
0
        void MogitorsRoot.IDragDropHandler.OnDragLeave(DragData dragData)
        {
            if (dragData.Object != null)
                dragData.Object.Destroy(false);

            dragData.Object = null;
        }
        public bool OnDragEnter(IDataObject data)
        {
            if (!IsSceneLoaded)
                return false;

            if (!data.GetDataPresent(typeof(DragData)))
                return false;

            DragData dragData = data.GetData(typeof(DragData)) as DragData;
            IDragDropHandler handler = this.dragDropHandlers[dragData.Source];
            if (handler == null)
                return false;

            this.activeDragData = dragData;
            return handler.OnDrageEnter(dragData);
        }
        public void OnDragLeave(IDataObject data)
        {
            if (!data.GetDataPresent(typeof(DragData)))
                return;

            DragData dragData = data.GetData(typeof(DragData)) as DragData;
            IDragDropHandler handler = this.dragDropHandlers[dragData.Source];
            if (handler == null)
                return;

            handler.OnDragLeave(dragData);
            this.activeDragData = null;
        }
示例#14
0
        void MogitorsRoot.IDragDropHandler.OnDragWheel(DragData dragData, Mogre.Viewport vp, float delta)
        {
            if (dragData.Object == null)
                return;

            EntityEditor entity = dragData.Object as EntityEditor;
            Mogre.Vector3 vPos = entity.Position;
            float distance = (vPos - vp.Camera.DerivedPosition).Length + (delta / 120.0f);

            if (vPos.x == 999999 && vPos.y == 999999 && vPos.z == 999999)
                return;
            else
                vPos = vp.Camera.DerivedPosition + ((vPos - vp.Camera.DerivedPosition).NormalisedCopy * distance);

            entity.Position = vPos;
        }
示例#15
0
        bool MogitorsRoot.IDragDropHandler.OnDragOver(DragData dragData, Mogre.Viewport vp, Mogre.Vector2 position)
        {
            if (dragData.Object == null)
                return false;

            Mogre.Ray mouseRay = vp.Camera.GetCameraToViewportRay(position.x, position.y);

            EntityEditor entity = dragData.Object as EntityEditor;

            bool hitFound = false;
            if (!hitFound)
            {
                if (entity.Position.x == 999999 && entity.Position.y == 999999 && entity.Position.z == 999999)
                    entity.Position = mouseRay.Origin + mouseRay.Direction * 40.0f;
                else
                    entity.Position = MogitorsRoot.Instance.GetGizmoIntersectCameraPlane(entity, mouseRay);
            }

            return true;
        }