コード例 #1
0
ファイル: ObjectsView.cs プロジェクト: andyhebear/likeleon
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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
ファイル: EntityView.cs プロジェクト: andyhebear/likeleon
        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
ファイル: EntityView.cs プロジェクト: andyhebear/likeleon
        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;
        }
コード例 #7
0
        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));
        }
コード例 #8
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);
        }
コード例 #9
0
ファイル: ObjectsView.cs プロジェクト: andyhebear/likeleon
        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
ファイル: ObjectsView.cs プロジェクト: andyhebear/likeleon
        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
ファイル: ObjectsView.cs プロジェクト: andyhebear/likeleon
        void MogitorsRoot.IDragDropHandler.OnDragLeave(DragData dragData)
        {
            if (dragData.Object != null)
                dragData.Object.Destroy(false);

            dragData.Object = null;
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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
ファイル: EntityView.cs プロジェクト: andyhebear/likeleon
        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
ファイル: EntityView.cs プロジェクト: andyhebear/likeleon
        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;
        }