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); }
public async Task OnDragEnterViewport(ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e) { if (mPreviewActor != null) { await mPreviewActor.AwaitLoad(); } else { mPreviewActor = new ViewPort.PreviewActorContainer(); var item = System.Activator.CreateInstance(ItemType) as EngineNS.Editor.IPlantable; if (item == null) { throw new InvalidOperationException("使用 EngineNS.Editor.Editor_PlantAbleActor 需要继承自 EngineNS.Editor.IPlantable "); } var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y)); var pos = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y); var param = new EngineNS.Editor.PlantableItemCreateActorParam() { View = viewport.RPolicy.BaseSceneView, Location = pos, }; mPreviewActor.mPreviewActor = await item.CreateActor(param); mPreviewActor.mPreviewActor.Placement.Location = pos; mPreviewActor.ReleaseWaitContext(); } viewport.World.AddActor(mPreviewActor.mPreviewActor); viewport.World.DefaultScene.AddActor(mPreviewActor.mPreviewActor); }
public async System.Threading.Tasks.Task OnDragEnterViewport(ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e) { if (mPreviewActor != null) { await mPreviewActor.AwaitLoad(); } else { mPreviewActor = new EditorCommon.ViewPort.PreviewActorContainer(); mPreviewActor.mPreviewActor = await EngineNS.GamePlay.Actor.GActor.NewPrefabActorAsync(this.ResourceName); var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y)); var pos = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y); mPreviewActor.mPreviewActor.Placement.Location = pos; mPreviewActor.ReleaseWaitContext(); } mPreviewActor.mPreviewActor.Tag = new Controls.Outliner.InvisibleInOutliner(); viewport.World.AddEditorActor(mPreviewActor.mPreviewActor); //foreach (var actor in mPreviewActor.mPreviewActor.Children) //{ // actor.SetParent(mPreviewActor.mPreviewActor); // viewport.World.AddActor(actor); // viewport.World.DefaultScene.AddActor(actor); //} }
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); // } //} }
public async Task OnDragLeaveViewport(ViewPort.ViewPortControl viewport, System.EventArgs e) { if (mPreviewActor != null) { await mPreviewActor.AwaitLoad(); } viewport.World.RemoveActor(mPreviewActor.mPreviewActor.ActorId); viewport.World.DefaultScene.RemoveActor(mPreviewActor.mPreviewActor.ActorId); }
public async Task OnDragOverViewport(ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e) { if (mPreviewActor != null) { await mPreviewActor.AwaitLoad(); } var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y)); var pos = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y); mPreviewActor.mPreviewActor.Placement.Location = pos; }
private void ShowVPActors(ViewPort.ViewPortControl viewport) { if (viewport.World == null) { return; } foreach (var listactor in viewport.World.Actors) { EngineNS.GamePlay.Actor.GActor actor = listactor.Value as EngineNS.GamePlay.Actor.GActor; if (actor.Parent == null) { AddActorToItem(TreeViewItemsNodes, actor); } } }
public async System.Threading.Tasks.Task OnDragLeaveViewport(ViewPort.ViewPortControl viewport, EventArgs e) { if (mPreviewActor != null) { await mPreviewActor.AwaitLoad(); } viewport.World.RemoveEditorActor(mPreviewActor.mPreviewActor.ActorId); //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); //} }
public async Task OnDragDropViewport(ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e) { var item = System.Activator.CreateInstance(ItemType) as EngineNS.Editor.IPlantable; var viewPortPos = viewport.PointFromScreen(new System.Windows.Point(e.X, e.Y)); var pos = viewport.GetPickRayLineCheckPosition((float)viewPortPos.X, (float)viewPortPos.Y); var param = new EngineNS.Editor.PlantableItemCreateActorParam() { View = viewport.RPolicy.BaseSceneView, Location = pos, }; var dropActor = await item.CreateActor(param); if (string.IsNullOrEmpty(dropActor.SpecialName)) { dropActor.SpecialName = EngineNS.GamePlay.SceneGraph.GSceneGraph.GeneratorActorSpecialNameInEditor(ItemName, viewport.World); } viewport.AddActor(dropActor); }
//TODO.. //Dictionary<Guid, TreeListView.ObservableCollectionAdv<TreeListView.ITreeModel>> ActorDatas = new Dictionary<Guid, TreeListView.ObservableCollectionAdv<TreeListView.ITreeModel>>(); public void BindViewPort(ViewPort.ViewPortControl viewport) { vp = viewport; vp.DRefreshActors -= new ViewPort.ViewPortControl.DelegateRefreshActors(RefreshActors); vp.DRefreshActors += new ViewPort.ViewPortControl.DelegateRefreshActors(RefreshActors); vp.DAddActor -= new ViewPort.ViewPortControl.DelegateOperationActor(AddActor); vp.DAddActor += new ViewPort.ViewPortControl.DelegateOperationActor(AddActor); vp.DRemoveActor -= new ViewPort.ViewPortControl.DelegateOperationActor(RemoveActor); vp.DRemoveActor += new ViewPort.ViewPortControl.DelegateOperationActor(RemoveActor); //vp.DSelectActor -= new ViewPort.ViewPortControl.DelegateOperationActor(FocusActorItem); //vp.DSelectActor += new ViewPort.ViewPortControl.DelegateOperationActor(FocusActorItem); //vp.DSelectActors -= new ViewPort.ViewPortControl.DelegateSelectActors(FocusActorItems); //vp.DSelectActors += new ViewPort.ViewPortControl.DelegateSelectActors(FocusActorItems); }