Пример #1
0
        public async System.Threading.Tasks.Task OnDragDropViewport(ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e)
        {
            var dropActor = await EngineNS.GamePlay.Actor.GActor.NewMeshActorAsync(this.ResourceName);

            dropActor.SpecialName = EngineNS.GamePlay.SceneGraph.GSceneGraph.GeneratorActorSpecialNameInEditor(this.ResourceName.PureName(), viewport.World);
            EngineNS.CEngine.Instance.HitProxyManager.MapActor(dropActor);
            var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y));
            var pos         = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y);

            dropActor.Placement.Location = pos;
            var selActors = new List <ViewPort.ViewPortControl.SelectActorData>(viewport.GetSelectedActors());

            var redoAction = new Action <object>((obj) =>
            {
                viewport.World.AddActor(dropActor);
                viewport.World.DefaultScene.AddActor(dropActor);
                viewport.SelectActor(dropActor);
            });

            redoAction.Invoke(null);
            EditorCommon.UndoRedo.UndoRedoManager.Instance.AddCommand("WorldEditOperation", null, redoAction, null, (obj) =>
            {
                viewport.World.RemoveActor(dropActor.ActorId);
                viewport.World.DefaultScene.RemoveActor(dropActor.ActorId);
                dropActor.Selected = false;
                viewport.SelectActors(selActors.ToArray());
            }, "添加对象");

            if (mPreviewActor != null)
            {
                await mPreviewActor.AwaitLoad();
            }
            viewport.World.RemoveActor(mPreviewActor.mPreviewActor.ActorId);
            viewport.World.DefaultScene.RemoveActor(mPreviewActor.mPreviewActor.ActorId);
        }
Пример #2
0
        public async System.Threading.Tasks.Task OnDragDropViewport(ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e)
        {
            var dropActor = await EngineNS.GamePlay.Actor.GActor.NewPrefabActorAsync(this.ResourceName);

            string sname = this.ResourceName.GetFileName();

            //dropActor.SpecialName = sname;
            MapPrefabActor(dropActor);
            var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y));
            var pos         = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y);

            dropActor.Placement.Location = pos;
            var selActors = new List <ViewPort.ViewPortControl.SelectActorData>(viewport.GetSelectedActors());

            var redoAction = new Action <object>((obj) =>
            {
                viewport.AddActor(dropActor);
            });

            redoAction.Invoke(null);
            EditorCommon.UndoRedo.UndoRedoManager.Instance.AddCommand("WorldEditOperation", null, redoAction, null, (obj) =>
            {
                viewport.World.RemoveActor(dropActor.ActorId);
                viewport.World.DefaultScene.RemoveActor(dropActor.ActorId);

                //for (int i = dropActor.Children.Count - 1; i >= 0; i--)
                //{
                //    EngineNS.GamePlay.Actor.GActor actor = dropActor.Children[i];
                //    actor.Parent.SetParent(null);
                //    viewport.World.RemoveActor(actor.ActorId);
                //    viewport.World.DefaultScene.RemoveActor(actor.ActorId);
                //}


                dropActor.Selected = false;
                viewport.SelectActors(selActors.ToArray());
            }, "添加对象");

            if (mPreviewActor == null || mPreviewActor.mPreviewActor == null)
            {
                return;
            }

            await mPreviewActor.AwaitLoad();

            viewport.World.RemoveEditorActor(mPreviewActor.mPreviewActor.ActorId);

            //if (mPreviewActor.mPreviewActor.Children.Count > 0)
            //{
            //    for (int i = mPreviewActor.mPreviewActor.Children.Count - 1; i >= 0; i --)
            //    {
            //        EngineNS.GamePlay.Actor.GActor actor = mPreviewActor.mPreviewActor.Children[i];
            //        actor.Parent.SetParent(null);
            //        viewport.World.RemoveActor(actor.ActorId);
            //        viewport.World.DefaultScene.RemoveActor(actor.ActorId);
            //    }
            //}
        }
Пример #3
0
        private void SelectionChanged()
        {
            if (TreeViewActors.SelectedItem == null)
            {
                return;
            }

            SelectActors.Clear();

            if (TreeViewActors.TreeListItemsSource.Count <= 0)
            {
                return;
            }

            if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift))
            {
                for (int i = 0; i < TreeViewActors.Items.Count; i++)
                {
                    var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[i]) as TreeListView.TreeListItem;

                    if (item != null && item.IsSelected)
                    {
                        ActorData ad = item.Content as ActorData;
                        if (ad != null)
                        {
                            SelectActors.Add(i, new EditorCommon.ViewPort.ViewPortControl.SelectActorData()
                            {
                                Actor            = ad.Actor,
                                StartTransMatrix = ad.Actor.Placement.WorldMatrix,
                            });
                        }
                    }
                }

                vp.SelectActors(SelectActors.Values.ToArray());
            }
            else
            {
                var item = TreeViewActors.ItemContainerGenerator.ContainerFromItem(TreeViewActors.Items[TreeViewActors.SelectedIndex]) as TreeListView.TreeListItem;
                if (item != null)
                {
                    ActorData ad = item.Content as ActorData;
                    if (ad != null)
                    {
                        SelectActors.Add(TreeViewActors.SelectedIndex, new EditorCommon.ViewPort.ViewPortControl.SelectActorData()
                        {
                            Actor            = ad.Actor,
                            StartTransMatrix = ad.Actor.Placement.WorldMatrix,
                        });
                        vp.SelectActor(ad.Actor);
                    }
                }
            }
        }