Ejemplo n.º 1
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            DrawPrimitivesTool tool =
                (context.ToolManager.ActiveRightTool as DrawPrimitivesTool);
            capture_data cap = data.custom_data as capture_data;

            tool.UpdateDraw_Ray(input.vMouseWorldRay, cap.nStep);

            if (input.bLeftMouseReleased)
            {
                if ((cap.nStep + 1) < tool.Steps)
                {
                    cap.nStep++;
                    return(Capture.Continue);
                }
                else
                {
                    tool.EndDraw();
                    return(Capture.End);
                }
            }
            else
            {
                return(Capture.Continue);
            }
        }
Ejemplo n.º 2
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            if (ContinueF(input))
            {
                // do view manipuluation
                float dx = input.vMouseDelta2D.x;
                float dy = input.vMouseDelta2D.y;

                if (RotationMode == RotateModes.Turntable)
                {
                    Context.ActiveCamera.Manipulator().SceneOrbit(Context.Scene, Context.ActiveCamera,
                                                                  RotateSpeed * dx, RotateSpeed * dy);
                }
                else
                {
                    Context.ActiveCamera.Manipulator().SceneTumble(Context.Scene, Context.ActiveCamera,
                                                                   -RotateSpeed * dx, RotateSpeed * dy);
                }

                return(Capture.Continue);
            }
            else
            {
                Context.ActiveCamera.SetTargetVisible(false);
                return(Capture.End);
            }
        }
Ejemplo n.º 3
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            if (input.bLeftMenuButtonReleased)
            {
                string sDate =
                    DateTime.Now.ToString("yyyy-MM-dd hh.mm.ss"); // + DateTime.Now.ToString("tt").ToLower();

                bool bDone = false;
                int  i     = 0;
                while (!bDone && i < 100)
                {
                    string sPath = ScreenshotPath + ScreenshotPrefix + sDate +
                                   ((i == 0) ? "" : "_" + i.ToString()) + ".png";
                    i++;
                    if (System.IO.File.Exists(sPath))
                    {
                        continue;
                    }

                    ScreenCapture.CaptureScreenshot(sPath, 4);
                    DebugUtil.Log(0, "Wrote screenshot " + sPath);
                    bDone = true;
                }
            }
            return(Capture.Ignore);
        }
 public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bLeftMouseReleased)
     {
         SORayHit rayHit;
         if (selectSO != null && selectSO.FindRayIntersection(input.vMouseWorldRay, out rayHit))
         {
             if ((EnableShiftModifier && input.bShiftKeyDown) ||
                 (EnableControlModifier && input.bCtrlKeyDown))
             {
                 if (scene.Scene.IsSelected(selectSO))
                 {
                     scene.Scene.Deselect(selectSO);
                 }
                 else
                 {
                     scene.Scene.Select(selectSO, false);
                 }
             }
             else
             {
                 scene.Scene.Select(selectSO, true);
             }
         }
         selectSO = null;
         return(Capture.End);
     }
     else
     {
         return(Capture.Continue);
     }
 }
Ejemplo n.º 5
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            if (ContinueF(input))
            {
                // do view manipuluation
                float dx = input.vMouseDelta2D.x;
                float dy = input.vMouseDelta2D.y;
                if (Adaptive)
                {
                    Context.ActiveCamera.Manipulator().SceneAdaptivePan(Context.Scene,
                                                                        Context.ActiveCamera, PanSpeed * dx, PanSpeed * dy);
                }
                else
                {
                    Context.ActiveCamera.Manipulator().ScenePan(Context.Scene,
                                                                Context.ActiveCamera, PanSpeed * dx, PanSpeed * dy);
                }

                return(Capture.Continue);
            }
            else
            {
                Context.ActiveCamera.SetTargetVisible(false);
                return(Capture.End);
            }
        }
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            SceneUIElement uiElem = data.custom_data as SceneUIElement;

            if ((data.which == CaptureSide.Left && input.bLeftTriggerReleased) ||
                (data.which == CaptureSide.Right && input.bRightTriggerReleased))
            {
                if (uiElem != null)
                {
                    uiElem.EndCapture(InputEvent.Spatial(data.which, input));
                }
                return(Capture.End);
            }
            else if ((data.which == CaptureSide.Left && input.bLeftTriggerDown) ||
                     (data.which == CaptureSide.Right && input.bRightTriggerDown))
            {
                if (uiElem != null)
                {
                    uiElem.UpdateCapture(InputEvent.Spatial(data.which, input));
                }
                return(Capture.Continue);
            }
            else
            {
                // [RMS] can end up here sometimes in Gamepad if we do camera controls
                //   while we are capturing...
                return(Capture.End);
            }
        }
Ejemplo n.º 7
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            if (tool == null)
            {
                throw new Exception("SculptCurveTool_MouseBehavior.UpdateCapture: tool is null, how did we get here?");
            }

            if (Released(ref input))
            {
                in_draw = false;
                tool.EndBrushStroke();
                return(Capture.End);
            }
            else
            {
                update_last_hit(tool, WorldRay(ref input));
                tool.UpdateBrushStroke(new Frame3f(lastHitPosW));

                // update draw frame if we are drawing on a target (?)
                if (tool.BrushTarget != null)
                {
                    curDrawFrameW = new Frame3f(lastHitPosW, context.ActiveCamera.Forward());
                }

                return(Capture.Continue);
            }
        }
Ejemplo n.º 8
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            GrabInfo gi = data.custom_data as GrabInfo;


            bool bFinished = false;

            if (data.which == CaptureSide.Left && (input.bLeftShoulderReleased || input.bLeftTriggerReleased))
            {
                bFinished = true;
            }
            else if (data.which == CaptureSide.Right && (input.bRightShoulderReleased || input.bRightTriggerReleased))
            {
                bFinished = true;
            }
            if (bFinished)
            {
                gi.complete();
                Capture result = end_transform(data);
                if (OnEndGrab != null)
                {
                    OnEndGrab(this, gi.so);
                }
                return(result);
            }

            Frame3f handF = (data.which == CaptureSide.Left) ? input.LeftHandFrame : input.RightHandFrame;

            gi.stickDelta += (data.which == CaptureSide.Left) ? input.vLeftStickDelta2D : input.vRightStickDelta2D;
            gi.update(handF);


            // drop-a-copy on X/A button release
            if ((data.which == CaptureSide.Left && input.bXButtonReleased) ||
                (data.which == CaptureSide.Right && input.bAButtonReleased))
            {
                SceneObject copy = gi.so.Duplicate();

                // save an undo-point for the current xform, and start a new one. That way we can
                //  step between drop-a-copy stages
                end_transform(data);
                gi.change = new TransformGizmoChange()
                {
                    parentSO          = new WeakReference(gi.so),
                    parentBefore      = gi.so.GetLocalFrame(CoordSpace.SceneCoords),
                    parentScaleBefore = gi.so.GetLocalScale()
                };

                // if we do this afterwards, and don't push an interaction state, then when
                //   we undo/redo we don't end up sitting on top of a duplicate.
                context.Scene.History.PushChange(
                    new AddSOChange()
                {
                    scene = context.Scene, so = copy, bKeepWorldPosition = false
                });
            }


            return(Capture.Continue);
        }
Ejemplo n.º 9
0
        override public Capture ForceEndCapture(InputState input, CaptureData data)
        {
            SurfaceBrushTool tool = context.ToolManager.GetActiveTool((int)data.which) as SurfaceBrushTool;

            tool.EndBrushStroke();
            return(Capture.End);
        }
Ejemplo n.º 10
0
 public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bLeftTriggerReleased || input.bAButtonReleased)
     {
         SORayHit rayHit;
         if (selectSO != null && selectSO.FindRayIntersection(input.vGamepadWorldRay, out rayHit))
         {
             if (input.bAButtonDown)
             {
                 if (scene.Scene.IsSelected(selectSO))
                 {
                     scene.Scene.Deselect(selectSO);
                 }
                 else
                 {
                     scene.Scene.Select(selectSO, false);
                 }
             }
             else
             {
                 scene.Scene.Select(selectSO, true);
             }
         }
         selectSO = null;
         return(Capture.End);
     }
     else
     {
         return(Capture.Continue);
     }
 }
Ejemplo n.º 11
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            DrawSurfaceCurveTool tool = context.ToolManager.GetActiveTool((int)data.which) as DrawSurfaceCurveTool;
            Ray3f sideRay             = (data.which == CaptureSide.Left) ? input.vLeftSpatialWorldRay : input.vRightSpatialWorldRay;

            // [RMS] this is a hack for trigger+shoulder grab gesture...really need some way
            //   to interrupt captures!!
            if ((data.which == CaptureSide.Left && input.bLeftShoulderPressed) ||
                (data.which == CaptureSide.Right && input.bRightShoulderPressed))
            {
                tool.CancelDraw();
                return(Capture.End);
            }

            tool.UpdateDraw_Ray(sideRay);

            bool bReleased = (data.which == CaptureSide.Left) ? input.bLeftTriggerReleased : input.bRightTriggerReleased;

            if (bReleased)
            {
                tool.EndDraw();
                return(Capture.End);
            }
            else
            {
                return(Capture.Continue);
            }
        }
Ejemplo n.º 12
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            if (input.bLeftShoulderReleased || input.bRightShoulderReleased)
            {
                cockpit.ActiveCamera.SetTargetVisible(false);

                HandInfo hi = (HandInfo)data.custom_data;
                if (hi.eMode == ActionMode.SetWorldScale)
                {
                    hi.CompleteSetWorldScale(cockpit);
                }

                return(Capture.End);
            }
            else
            {
                HandInfo hi = (HandInfo)data.custom_data;
                if (hi.eMode == ActionMode.SetWorldScale)
                {
                    return(Update_SetWorldScale(input, data));
                }
                else
                {
                    return(Update_TransformCamera(input, data));
                }
            }
        }
Ejemplo n.º 13
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            Vector2d vCurPos = ClickPoint(input);

            if (Released(input))
            {
                if (vCurPos.Distance(vClickDown) > MaxClickMoveDelta)
                {
                    return(Capture.End);
                }

                SORayHit rayHit;
                bool     bHit = context.Scene.FindSORayIntersection(WorldRay(input), out rayHit, ObjectFilterF);
                if (bHit == false || rayHit.hitSO != clickSO)
                {
                    return(Capture.End);
                }

                BaseSingleClickTool tool =
                    (context.ToolManager.ActiveRightTool as BaseSingleClickTool);
                tool.OnClicked(clickSO, vCurPos, WorldRay(input));
                return(Capture.End);
            }
            else
            {
                return(Capture.Continue);
            }
        }
Ejemplo n.º 14
0
        override public Capture ForceEndCapture(InputState input, CaptureData data)
        {
            DrawPrimitivesTool tool = context.ToolManager.GetActiveTool((int)data.which) as DrawPrimitivesTool;

            tool.CancelDraw();
            return(Capture.End);
        }
Ejemplo n.º 15
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            DrawSurfaceCurveTool tool = context.ToolManager.GetActiveTool((int)data.which) as DrawSurfaceCurveTool;
            Ray3f worldRay            = (data.which == CaptureSide.Left) ? input.vLeftSpatialWorldRay : input.vRightSpatialWorldRay;

            // [RMS] this is a hack for trigger+shoulder grab gesture...really need some way
            //   to interrupt captures!!
            if ((data.which == CaptureSide.Left && input.bLeftShoulderPressed) ||
                (data.which == CaptureSide.Right && input.bRightShoulderPressed))
            {
                tool.CancelDraw();
                return(Capture.End);
            }


            // this happens if we exit tool while in draw (cts or multi-click). We need to fail gracefully in those cases.
            if (tool == null)
            {
                return(Capture.End);
            }
            // this can happen if we called tool.EndDraw() somewhere else
            if (tool.InDraw == false)
            {
                return(Capture.End);
            }

            bool bReleased = (data.which == CaptureSide.Left) ? input.bLeftTriggerReleased : input.bRightTriggerReleased;

            if (tool.InputMode == DrawSurfaceCurveTool.DrawMode.OnClick)
            {
                if (bReleased)
                {
                    if (tool.UpdateDraw_Ray_MultiClick(worldRay) == false)
                    {
                        tool.EndDraw();
                        return(Capture.End);
                    }
                }
                else
                {
                    tool.UpdateDrawPreview_Ray_MultiClick(worldRay);
                }

                return(Capture.Continue);
            }
            else
            {
                tool.UpdateDraw_Ray_Continuous(worldRay);
                if (bReleased)
                {
                    tool.EndDraw();
                    return(Capture.End);
                }
                else
                {
                    return(Capture.Continue);
                }
            }
        }
Ejemplo n.º 16
0
        override public Capture ForceEndCapture(InputState input, CaptureData data)
        {
            SculptCurveTool tool = context.ToolManager.GetActiveTool((int)data.which) as SculptCurveTool;

            in_draw = false;
            tool.EndBrushStroke();
            return(Capture.End);
        }
Ejemplo n.º 17
0
        public override Capture ForceEndCapture(InputState input, CaptureData data)
        {
            GrabInfo gi = data.custom_data as GrabInfo;

            gi.complete();

            return(end_transform(data));
        }
Ejemplo n.º 18
0
        override public Capture ForceEndCapture(InputState input, CaptureData data)
        {
            DrawPrimitivesTool tool =
                (context.ToolManager.ActiveRightTool as DrawPrimitivesTool);

            tool.CancelDraw();
            return(Capture.End);
        }
Ejemplo n.º 19
0
        Capture(CaptureState state, InputBehavior e, CaptureSide which = CaptureSide.Any, object custom_data = null)
        {
            this.state   = state;
            this.element = e;

            this.data             = new CaptureData();
            this.data.which       = which;
            this.data.custom_data = custom_data;
        }
Ejemplo n.º 20
0
 public override Capture ForceEndCapture(InputState input, CaptureData data)
 {
     if (pCapturing != null)
     {
         pCapturing.EndCapture(InputEvent.Touch(input));
         pCapturing = null;
     }
     return(Capture.End);
 }
 public override Capture ForceEndCapture(InputState input, CaptureData data)
 {
     if (pCapturing != null)
     {
         pCapturing.EndCapture(InputEvent.Mouse(input.ToOrthoLayerInput()));
         pCapturing = null;
     }
     return(Capture.End);
 }
 public override Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.fMouseWheel != 0)
     {
         float fZoom = ZoomScale * input.fMouseWheel;
         cockpit.ActiveCamera.Manipulator().SceneZoom(cockpit.Scene, cockpit.ActiveCamera, fZoom);
     }
     return(Capture.Continue);
 }
        public override Capture ForceEndCapture(InputState input, CaptureData data)
        {
            SceneUIElement uiElem = data.custom_data as SceneUIElement;

            if (uiElem != null)
            {
                uiElem.EndCapture(InputEvent.Spatial(data.which, input));
            }
            return(Capture.End);
        }
Ejemplo n.º 24
0
 public override Capture ForceEndCapture(InputState input, CaptureData data)
 {
     if (pCapturing != null)
     {
         pCapturing.EndCapture(InputEvent.Gamepad(input));
         pCapturing  = null;
         ActiveInput = WhichInput.None;
     }
     return(Capture.End);
 }
Ejemplo n.º 25
0
 public override Capture ForceEndCapture(InputState input, CaptureData data)
 {
     if (inBehavior != null)
     {
         Capture result = inBehavior.ForceEndCapture(input, data);
         inBehavior = null;
         return(result);
     }
     return(Capture.End);
 }
Ejemplo n.º 26
0
 public override Capture ForceEndCapture(InputState input, CaptureData data)
 {
     if (pCapturing != null)
     {
         // if we don't do this, and EndCapture throws, we end up in a loop of exceptions!
         var temp = pCapturing;
         pCapturing = null;
         temp.EndCapture(InputEvent.Mouse(input.ToOrthoLayerInput()));
     }
     return(Capture.End);
 }
Ejemplo n.º 27
0
        Capture end_transform(CaptureData data)
        {
            GrabInfo gi = data.custom_data as GrabInfo;

            gi.change.parentAfter      = gi.so.GetLocalFrame(CoordSpace.SceneCoords);
            gi.change.parentScaleAfter = gi.so.GetLocalScale();

            context.Scene.History.PushChange(gi.change, true);
            context.Scene.History.PushInteractionCheckpoint();

            return(Capture.End);
        }
Ejemplo n.º 28
0
        public override Capture UpdateCapture(InputState input, CaptureData data)
        {
            // if we already picked a behavior, let it handle things
            if (inBehavior != null)
            {
                Capture result = inBehavior.UpdateCapture(input, data);
                if (result.state == CaptureState.End)
                {
                    inBehavior = null;
                }
                return(result);
            }

            // if we released button, and we are here, we must not have picked yet, so
            // do full click behavior
            if (ButtonReleasedF(input))
            {
                Capture begin = ClickBehavior.BeginCapture(input, data.which);
                if (begin.state == CaptureState.Begin)
                {
                    Capture update = ClickBehavior.UpdateCapture(input, data);
                    if (update.state != CaptureState.End)
                    {
                        DebugUtil.Log(2, "MouseClickDragSuperBehavior.UpdateCapture: ClickBehavior did not return End");
                        return(Capture.End);
                    }
                    return(update);
                }
            }


            float fDelta = mouseDownPos.Distance(input.vMousePosition2D);

            if (fDelta > DragTolerance)
            {
                inBehavior = DragBehavior;
                Capture begin = inBehavior.BeginCapture(input, data.which);
                if (begin.state == CaptureState.Begin)
                {
                    Capture update = inBehavior.UpdateCapture(input, data);
                    return(update);
                }
                else
                {
                    return(Capture.End);
                }
            }

            // haven't decided yet, carry on
            return(Capture.Continue);
        }
Ejemplo n.º 29
0
        override public Capture UpdateCapture(InputState input, CaptureData data)
        {
            Tool.UpdateStroke(SceneRay(ref input, Context.Scene));

            if (Released(input))
            {
                Tool.EndStroke();
                return(Capture.End);
            }
            else
            {
                return(Capture.Continue);
            }
        }
 override public Capture UpdateCapture(InputState input, CaptureData data)
 {
     if (input.bRightMouseReleased)
     {
         EndCaptureF(input);
         lastInput = input;
         return(Capture.End);
     }
     else
     {
         UpdateCaptureF(input, lastInput);
         return(Capture.Continue);
     }
 }