public override uint MouseLeave(int inObjectIndex, GL_ControlBase control) { if (SelectionTransformAction != NoAction || CurrentAction != null) { return(0); } foreach (IEditableObject obj in GetObjects()) { if (!obj.Visible) { continue; } int span = obj.GetPickableSpan(); if (inObjectIndex >= 0 && inObjectIndex < span) { return(obj.MouseLeave(inObjectIndex, control)); } inObjectIndex -= span; } foreach (AbstractGlDrawable obj in StaticObjects) { int span = obj.GetPickableSpan(); if (inObjectIndex >= 0 && inObjectIndex < span) { return(obj.MouseLeave(inObjectIndex, control)); } inObjectIndex -= span; } return(0); }
public ScaleActionIndividual(GL_ControlBase control, Point mousePos, EditableObject.LocalOrientation orientation) { this.control = control; startMousePos = mousePos; this.orientation = orientation; centerPoint = control.ScreenCoordFor(orientation.Origin); }
public override uint MouseWheel(MouseEventArgs e, GL_ControlBase control) { uint var = 0; foreach (IEditableObject obj in GetObjects()) { var |= obj.MouseWheel(e, control); } foreach (AbstractGlDrawable obj in StaticObjects) { var |= obj.MouseWheel(e, control); } if (CurrentAction != NoAction || ExclusiveAction != NoAction) { CurrentAction.ApplyScrolling(e.Location, e.Delta); ExclusiveAction.ApplyScrolling(e.Location, e.Delta); var |= REDRAW | NO_CAMERA_ACTION; var &= ~REPICK; } return(var); }
public CameraStateSave(GL_ControlBase control) { Target = control.CameraTarget; RotX = control.CamRotX; RotY = control.CamRotY; Distance = control.CameraDistance; }
public override uint MouseMove(MouseEventArgs e, Point lastMousePos, GL_ControlBase control) { uint var = 0; foreach (IEditableObject obj in GetObjects()) { var |= obj.MouseMove(e, lastMousePos, control); } foreach (AbstractGlDrawable obj in StaticObjects) { var |= obj.MouseMove(e, lastMousePos, control); } if (CurrentAction != NoAction || ExclusiveAction != NoAction) { CurrentAction.UpdateMousePos(e.Location); ExclusiveAction.UpdateMousePos(e.Location); var |= REDRAW | NO_CAMERA_ACTION; var &= ~REPICK; } else { var |= REPICK; } return(var); }
public ScaleAction(GL_ControlBase control, Point mousePos, Vector3 center) { this.control = control; startMousePos = mousePos; this.center = center; centerPoint = control.ScreenCoordFor(center); }
public override void Disconnect(GL_ControlBase control) { foreach (AbstractGlDrawable obj in GetDrawables()) { obj.Disconnect(control); } }
public override uint MouseWheel(MouseEventArgs e, GL_ControlBase control) { uint var = 0; foreach (IEditableObject obj in GetObjects()) { var |= obj.MouseWheel(e, control); } foreach (AbstractGlDrawable obj in StaticObjects) { var |= obj.MouseWheel(e, control); } if ((SelectionTransformAction != NoAction || CurrentAction != null)) { if (WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftCtrl)) { SelectionTransformAction.UpdateMousePos(e.Location); CurrentAction?.UpdateMousePos(e.Location); var |= REDRAW; } else { SelectionTransformAction.ApplyScrolling(e.Location, e.Delta); CurrentAction?.ApplyScrolling(e.Location, e.Delta); var |= REDRAW | NO_CAMERA_ACTION; var &= ~REPICK; } } return(var); }
public override uint MouseClick(MouseEventArgs e, GL_ControlBase control) { if (e.Button == MouseButtons.Right) { linkDragMode = LinkDragMode.None; return(REDRAW); } if (linkManager.hoveredConnection != null) { SelectedConnection = linkManager.hoveredConnection; UpdateSelection(REDRAW); return(REDRAW); } else { if (SelectedConnection != null) { SelectedConnection = null; return(REDRAW); } return(0); } }
public void CenterCamera(GL_ControlBase control, List <DrawableContainer> Drawables) { if (!Runtime.FrameCamera) { return; } var spheres = new List <Vector4>(); for (int i = 0; i < Drawables.Count; i++) { foreach (var drawable in Drawables[i].Drawables) { if (drawable is IMeshContainer) { for (int m = 0; m < ((IMeshContainer)drawable).Meshes.Count; m++) { var mesh = ((IMeshContainer)drawable).Meshes[m]; var vertexPositions = mesh.vertices.Select(x => x.pos).Distinct(); spheres.Add(control.GenerateBoundingSphere(vertexPositions)); } } } } if (spheres.Count > 0) { control.FrameSelect(spheres); } }
public override void DrawMesh(GL_ControlBase control, GenericPickableMesh mesh) { foreach (var group in mesh.Mesh.PolygonGroups) { Render.OnMeshDraw(mesh.Render, group); } }
public void ApplyTo(GL_ControlBase control) { control.CameraTarget = Target; control.CamRotX = RotX; control.CamRotY = RotY; control.CameraDistance = Distance; }
public override uint Update(GL_ControlBase control, float deltaTime) { if (control.MainDrawable == null || !control.Focused || WinInput.Keyboard.Modifiers != WinInput.ModifierKeys.None) { return(0); } float speed = deltaTime * 0.01f; Vector3 vec = Vector3.Zero; if (WinInput.Keyboard.IsKeyDown(WinInput.Key.W)) { vec.Z -= speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.A)) { vec.X -= speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.S)) { vec.Z += speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.D)) { vec.X += speed; } Point mousePos = control.GetMousePos(); Vector2 normCoords = control.NormMouseCoords(mousePos.X, mousePos.Y); vec.X += (-normCoords.X * vec.Z) * control.FactorX; vec.Y += (normCoords.Y * vec.Z) * control.FactorY; float up = 0; if (WinInput.Keyboard.IsKeyDown(WinInput.Key.Q)) { up -= speed; } if (WinInput.Keyboard.IsKeyDown(WinInput.Key.E)) { up += speed; } if (vec == Vector3.Zero && up == 0) { return(0); } control.CameraTarget += Vector3.Transform(control.InvertedRotationMatrix, vec) + Vector3.UnitY * up; (control.MainDrawable as EditorDrawables.EditorSceneBase)?.CurrentAction?.UpdateMousePos(mousePos); (control.MainDrawable as EditorDrawables.EditorSceneBase)?.SelectionTransformAction.UpdateMousePos(mousePos); return(UPDATE_CAMERA); }
public override uint Deselect(int partIndex, GL_ControlBase control) { if (PickingSelection == PickingMode.Mesh) { bool noPointsSelected = true; for (int i = 0; i < PickableMeshes.Count; i++) { int span = PickableMeshes[i].GetPickableSpan(); if (partIndex >= 0 && partIndex < span) { PickableMeshes[i].Deselect(partIndex, control); } partIndex -= span; noPointsSelected &= !PickableMeshes[i].IsSelected(); } return(REDRAW); } if (PickableMeshes != null) { //Force deselection on meshes if previously selected for (int i = 0; i < PickableMeshes.Count; i++) { PickableMeshes[i].DeselectAll(control); } } return(base.Deselect(partIndex, control)); }
public override uint MouseLeave(int inObjectIndex, GL_ControlBase control) { if (CurrentAction != NoAction || ExclusiveAction != NoAction) { return(0); } ObjectRenderState.ShouldBeDrawn = ShouldBeDrawn; foreach (IEditableObject obj in GetObjects()) { int span = obj.GetPickableSpan(); if (inObjectIndex >= 0 && inObjectIndex < span) { return(obj.MouseLeave(inObjectIndex, control)); } inObjectIndex -= span; } foreach (AbstractGlDrawable obj in StaticObjects) { int span = obj.GetPickableSpan(); if (inObjectIndex >= 0 && inObjectIndex < span) { return(obj.MouseLeave(inObjectIndex, control)); } inObjectIndex -= span; } ObjectRenderState.ShouldBeDrawn = ObjectRenderState.ShouldBeDrawn_Default; return(0); }
public TranslateAction(GL_ControlBase control, Point mousePos, Vector3 center, float draggingDepth) { this.control = control; startMousePos = mousePos; this.draggingDepth = draggingDepth; planeOrigin = control.CoordFor(mousePos.X, mousePos.Y, draggingDepth); origin = center; }
public override void RenderMaterial(GL_ControlBase control, Pass pass, GenericPickableMesh mesh, GL_EditorFramework.GL_Core.ShaderProgram shader, Vector4 highlight_color) { foreach (var group in mesh.Mesh.PolygonGroups) { Render.RenderMaterials(Render.ActiveShader, mesh.Mesh, group, group.Material, highlight_color); } }
public override uint DeselectAll(GL_ControlBase control) { if (Selected) { Selected = false; } return(0); }
public RotateAction(GL_ControlBase control, Point mousePos, Vector3 center, float draggingDepth) { this.control = control; startMousePos = mousePos; this.center = center; planeOrigin = control.CoordFor(mousePos.X, mousePos.Y, draggingDepth); centerPoint = control.ScreenCoordFor(center); }
public override uint SelectAll(GL_ControlBase control) { if (!Selected) { Selected = true; } return(0); }
public override uint SelectDefault(GL_ControlBase control) { foreach (RenderablePathPoint point in PathPoints) { point.SelectDefault(control); } return(REDRAW); }
public override uint DeselectAll(GL_ControlBase control) { for (int i = 0; i < PickableMeshes.Count; i++) { PickableMeshes[i].DeselectAll(control); } return(base.DeselectAll(control)); }
public override void MarginScroll(MarginScrollEventArgs e, GL_ControlBase control) { if (SelectionTransformAction != NoAction || CurrentAction != null) { SelectionTransformAction.ApplyMarginScrolling(e.Location, e.AmountX, e.AmountY); CurrentAction?.ApplyMarginScrolling(e.Location, e.AmountX, e.AmountY); } }
public override uint DeselectAll(GL_ControlBase control) { Selected = false; if (Mesh != null) { Mesh.AferDeselect(); } return(REDRAW); }
public override uint Select(int partIndex, GL_ControlBase control) { Selected = true; if (Mesh != null) { Mesh.AferSelect(); } return(REDRAW); }
public override uint SelectDefault(GL_ControlBase control) { Selected = true; if (Mesh != null) { Mesh.AferSelect(); } return(REDRAW); }
public override uint DeselectAll(GL_ControlBase control) { if (Selected) { Selected = false; control.DetachPickingRedrawer(); } return(0); }
public override uint SelectAll(GL_ControlBase control) { if (!Selected) { Selected = true; control.AttachPickingRedrawer(); } return(0); }
public override uint DeselectAll(GL_ControlBase control) { foreach (RenderablePathPoint point in PathPoints) { point.DeselectAll(control); } return(REDRAW); }
public override uint MouseMove(MouseEventArgs e, Point lastMouseLoc, GL_ControlBase control) { float deltaX = e.Location.X - lastMouseLoc.X; float deltaY = e.Location.Y - lastMouseLoc.Y; if (e.Button == MouseButtons.Right) { if (WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftCtrl)) { control.CameraDistance *= 1f - deltaY * -5 * 0.001f; } else { if (!WinInput.Keyboard.IsKeyDown(WinInput.Key.Y)) { control.RotateCameraX(deltaX * rotFactorX); } if (!WinInput.Keyboard.IsKeyDown(WinInput.Key.X)) { control.CamRotY += deltaY * rotFactorY; } } return(UPDATE_CAMERA); } else if (e.Button == MouseButtons.Left) { base.MouseMove(e, lastMouseLoc, control); //code from Whitehole Vector3 vec; if (!WinInput.Keyboard.IsKeyDown(WinInput.Key.Y)) { vec.X = deltaX * Math.Min(maxCamMoveSpeed, depth * control.FactorX); } else { vec.X = 0; } if (!WinInput.Keyboard.IsKeyDown(WinInput.Key.X)) { vec.Y = -deltaY *Math.Min(maxCamMoveSpeed, depth *control.FactorY); } else { vec.Y = 0; } vec.Z = 0; control.CameraTarget -= Vector3.Transform(control.InvertedRotationMatrix, vec); return(UPDATE_CAMERA); } return(0); }