public async System.Threading.Tasks.Task OnDragOverViewport(EditorCommon.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; }
public async System.Threading.Tasks.Task OnDragDropViewport(EditorCommon.ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e) { GParticleComponent component = new GParticleComponent(); var param = new EngineNS.Editor.PlantableItemCreateActorParam() { Location = new EngineNS.Vector3(0, 0, 0), }; var dropActor = await component.CreateActor(param, this.ResourceName); //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 <EditorCommon.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 System.Threading.Tasks.Task OnDragEnterViewport(EditorCommon.ViewPort.ViewPortControl viewport, System.Windows.Forms.DragEventArgs e) { if (mPreviewActor != null) { await mPreviewActor.AwaitLoad(); } else { mPreviewActor = new EditorCommon.ViewPort.PreviewActorContainer(); GParticleComponent component = new GParticleComponent(); var param = new EngineNS.Editor.PlantableItemCreateActorParam() { Location = new EngineNS.Vector3(0, 0, 0), }; mPreviewActor.mPreviewActor = await component.CreateActor(param, 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 EditorCommon.Controls.Outliner.InvisibleInOutliner(); viewport.AddActor(mPreviewActor.mPreviewActor); }