Beispiel #1
0
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);
            if (DesignView.Context == null)
            {
                return;
            }

            if (m_ghosts.Count > 0)
            {
                foreach (DomNode ghost in m_ghosts)
                {
                    ghost.RemoveFromParent();
                }

                var dragDropTarget = TargetGame();
                ApplicationUtil.Insert(
                    dragDropTarget,
                    dragDropTarget,
                    m_ghosts,
                    "Drag and Drop",
                    null);

                m_ghosts.Clear();
                DesignView.InvalidateViews();
            }
        }
Beispiel #2
0
        protected override void OnDragOver(DragEventArgs drgevent)
        {
            base.OnDragOver(drgevent);
            if (DesignView.Context == null || m_ghosts.Count == 0)
            {
                return;
            }

            //  Just do an intersection against the terrain to
            //  calculate basic insertion position
            Vec3F terrainHit;

            if (GetTerrainCollision(out terrainHit, PointToClient(new Point(drgevent.X, drgevent.Y))))
            {
                foreach (var ghost in m_ghosts)
                {
                    var gameObject = ghost.As <ITransformable>();
                    if (gameObject != null)
                    {
                        gameObject.Translation = terrainHit;
                    }
                }

                DesignView.InvalidateViews();
            }
        }
        protected override void OnDragLeave(EventArgs e)
        {
            base.OnDragLeave(e);
            if (DesignView.Context == null)
            {
                return;
            }

            if (m_ghosts.Count > 0)
            {
                IGame             dragDropTarget = TargetGame();
                IGameObjectFolder rootFolder     = dragDropTarget.RootGameObjectFolder;
                foreach (DomNode ghost in m_ghosts)
                {
                    // reset translation.
                    ITransformable xformnode = ghost.As <ITransformable>();
                    xformnode.Translation = new Vec3F(0, 0, 0);

                    rootFolder.GameObjects.Remove(ghost.As <IGameObject>());
                }

                m_ghosts.Clear();
                DesignView.InvalidateViews();
            }
        }
        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);
            if (DesignView.Context == null)
            {
                return;
            }

            if (m_ghosts.Count > 0)
            {
                IGame             dragDropTarget = TargetGame();
                IGameObjectFolder rootFolder     = dragDropTarget.RootGameObjectFolder;

                foreach (DomNode ghost in m_ghosts)
                {
                    rootFolder.GameObjects.Remove(ghost.As <IGameObject>());
                }
                ApplicationUtil.Insert(
                    dragDropTarget,
                    rootFolder.Cast <DomNode>(),
                    m_ghosts,
                    "Drag and Drop",
                    null);

                m_ghosts.Clear();
                DesignView.InvalidateViews();
            }
        }
        protected override void OnDragOver(DragEventArgs drgevent)
        {
            base.OnDragOver(drgevent);
            if (DesignView.Context == null || m_ghosts.Count == 0)
            {
                return;
            }

            //  Just do an intersection against the terrain to
            //  calculate basic insertion position
            Vec3F terrainHit;

            if (GetInsertionPosition(out terrainHit, PointToClient(new Point(drgevent.X, drgevent.Y))))
            {
                ISnapSettings snapSettings = (ISnapSettings)DesignView;
                foreach (var ghost in m_ghosts)
                {
                    var gameObject = ghost.As <ITransformable>();
                    if (gameObject != null)
                    {
                        gameObject.Translation = terrainHit;

                        // When if terrain alignment mode, we need to query the terrain collision model
                        // for a terrain normal associated with this point. The
                        if (snapSettings.TerrainAlignment == TerrainAlignmentMode.TerrainUp)
                        {
                            using (var intersectionScene = GameEngine.GetEditorSceneManager().GetIntersectionScene())
                            {
                                float            terrainHeight;
                                GUILayer.Vector3 terrainNormal;
                                if (GUILayer.EditorInterfaceUtils.GetTerrainHeightAndNormal(
                                        out terrainHeight, out terrainNormal,
                                        intersectionScene, terrainHit.X, terrainHit.Y))
                                {
                                    gameObject.Rotation = TransformUtils.RotateToVector(
                                        gameObject.Rotation, new Vec3F(terrainNormal.X, terrainNormal.Y, terrainNormal.Z),
                                        Sce.Atf.Rendering.Dom.AxisSystemType.ZIsUp);
                                }
                            }
                        }
                    }
                }

                DesignView.InvalidateViews();
            }
        }
Beispiel #6
0
        protected override void OnDragLeave(EventArgs e)
        {
            base.OnDragLeave(e);
            if (DesignView.Context == null)
            {
                return;
            }

            if (m_ghosts.Count > 0)
            {
                foreach (DomNode ghost in m_ghosts)
                {
                    ghost.RemoveFromParent();
                }
                m_ghosts.Clear();
                DesignView.InvalidateViews();
            }
        }