public CornerControl(BlendingController bcon, Blending blending, MouseTracker mouseTracker, BlendingController.MousePosition mouseCurr) : base(bcon, blending, mouseTracker, mouseCurr) { fsmOperation = new FSM <OperationEnum>(FSM.TransitionModeEnum.Immediate); FsmActivity.State(ActivityEnum.Inactive); FsmActivity.State(ActivityEnum.Active).Enter(fsm => { mouseTracker.OnSelectionDown += (mt, f) => { switch (f) { case MouseTracker.ButtonFlag.Left: if (mouseCurr.TryInitVertexMode()) { fsmOperation.Goto(OperationEnum.MoveCorner); } break; case MouseTracker.ButtonFlag.Right: break; } }; mouseTracker.OnSelection += (mt, f) => { fsmOperation.Update(); }; mouseTracker.OnSelectionUp += (mt, f) => { fsmOperation.Goto(OperationEnum.None); }; }).Update(fsm => { fsmOperation.Update(); }).Exit(fsm => { fsmOperation.Goto(OperationEnum.None); mouseTracker.Clear(); }); FsmActivity.Init(); fsmOperation.State(OperationEnum.None); fsmOperation.State(OperationEnum.MoveCorner).Update(fsm => { if (bcon.IsOverGUI) { return; } mouseCurr.Update(); var duv = mouseCurr.WorldDuv; var data = blending.BlendingData; var iscreen = mouseCurr.selectedScreen.x + mouseCurr.selectedScreen.y * data.Screens.x; var trap = data.Trapeziums[iscreen]; trap[mouseCurr.selectedVertex] += duv; trap.Clamp01(); data.Trapeziums[iscreen] = trap; data.Invalidate(); }); fsmOperation.Init(); }
public BlendControl(BlendingController bcon, Blending blending, MouseTracker mouseTracker, BlendingController.MousePosition mouseCurr) : base(bcon, blending, mouseTracker, mouseCurr) { fsmOperation = new FSM <OperationEnum>(); FsmActivity.State(ActivityEnum.Inactive); FsmActivity.State(ActivityEnum.Active).Enter(fsm => { mouseTracker.OnSelectionDown += (mt, f) => { switch (f) { case MouseTracker.ButtonFlag.Left: if (mouseCurr.TryInitEdgeMode()) { fsmOperation.Goto(OperationEnum.MoveBlendWidth); } break; case MouseTracker.ButtonFlag.Right: break; } }; mouseTracker.OnSelection += (mt, f) => { fsmOperation.Update(); }; mouseTracker.OnSelectionUp += (mt, f) => { fsmOperation.Goto(OperationEnum.None); }; }).Update(fsm => { fsmOperation.Update(); }).Exit(fsm => { fsmOperation.Goto(OperationEnum.None); mouseTracker.Clear(); }); FsmActivity.Init(); fsmOperation.State(OperationEnum.None); fsmOperation.State(OperationEnum.MoveBlendWidth).Update(fsm => { if (bcon.IsOverGUI) { return; } mouseCurr.Update(); var duv = mouseCurr.WorldDuv; var data = blending.BlendingData; var ej = new EdgeJoint(data, mouseCurr.selectedScreen, mouseCurr.selectedEdge); ej.Bandwidth += duv[ej.axis]; UvMapper.UpdateUv(data.Screens, data.Edges, data.ViewportOffsets); data.Invalidate(); }); fsmOperation.Init(); }
public EdgeControl(BlendingController bcon, Blending blending, MouseTracker mouseTracker, BlendingController.MousePosition mouseCurr) : base(bcon, blending, mouseTracker, mouseCurr) { fsmOperation = new FSM <OperationEnum>(); FsmActivity.State(ActivityEnum.Inactive); FsmActivity.State(ActivityEnum.Active).Enter(fsm => { mouseTracker.OnSelectionDown += (mt, f) => { switch (f) { case MouseTracker.ButtonFlag.Left: if (mouseCurr.TryInitEdgeMode()) { fsmOperation.Goto(OperationEnum.MoveEdge); } break; case MouseTracker.ButtonFlag.Right: break; } }; mouseTracker.OnSelection += (mt, f) => { fsmOperation.Update(); }; mouseTracker.OnSelectionUp += (mt, f) => { fsmOperation.Goto(OperationEnum.None); }; }).Update(fsm => { fsmOperation.Update(); }).Exit(fsm => { fsmOperation.Goto(OperationEnum.None); mouseTracker.Clear(); }); FsmActivity.Init(); fsmOperation.State(OperationEnum.None); fsmOperation.State(OperationEnum.MoveEdge).Update(fsm => { if (bcon.IsOverGUI) { return; } mouseCurr.Update(); var duv = mouseCurr.WorldDuv; var screen = mouseCurr.selectedScreen; var data = blending.BlendingData; var iscreen = screen.x + screen.y * data.Screens.x; var trap = data.Trapeziums[iscreen]; var iv0 = ScreenSelector.PAIR_EDGES[2 * mouseCurr.selectedEdge]; var iv1 = ScreenSelector.PAIR_EDGES[2 * mouseCurr.selectedEdge + 1]; var dx = ScreenSelector.ScreenSize(data.Screens); var worldTrap = ScreenSelector.LocalToWorld(screen.x, screen.y, trap, dx); var tan = (worldTrap[iv1] - worldTrap[iv0]).normalized; duv -= Vector2.Dot(duv, tan) * tan; trap[iv0] += duv; trap[iv1] += duv; trap.Clamp01(); data.Trapeziums[iscreen] = trap; data.Invalidate(); }); fsmOperation.Init(); }