Exemplo n.º 1
0
 public override Capture BeginCapture(InputState input, CaptureSide eSide)
 {
     return(Capture.Begin(this));
 }
Exemplo n.º 2
0
        void HandleInput_MouseOrGamepad()
        {
            // update mouse/gamepad cursor
            MouseController.Update();

            // have to do this after cursor update in case hotkey uses mouse position
            HandleKeyboardInput();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_MouseGamepad(this);
            lastInputState = input;

            CameraInteractionState eCamState = (MouseCameraController != null)
                ? MouseCameraController.CheckCameraControls(input) : CameraInteractionState.Ignore;

            if (eCamState == CameraInteractionState.BeginCameraAction)
            {
                TerminateHovers(input);

                bInCameraControl = true;
                ActiveCamera.SetTargetVisible(true);
            }
            else if (eCamState == CameraInteractionState.EndCameraAction)
            {
                bInCameraControl = false;
                ActiveCamera.SetTargetVisible(false);
            }
            else if (bInCameraControl)
            {
                ActiveCamera.SetTargetVisible(true);
                MouseCameraController.DoCameraControl(Scene, ActiveCamera, input);
            }
            else
            {
                // run override behaviors
                overrideBehaviors.SendOverrideInputs(input);

                input.MouseGamepadCaptureActive = (captureMouse != null);

                if (InCaptureMouse)
                {
                    Capture cap = captureMouse.element.UpdateCapture(input, captureMouse.data);
                    if (cap.state == CaptureState.Continue)
                    {
                        // (carry on)
                    }
                    else if (cap.state == CaptureState.End)
                    {
                        captureMouse = null;
                    }
                }
                else
                {
                    // this is very simplistic...needs to be rewritten like space controllers

                    List <CaptureRequest> vRequests = new List <CaptureRequest>();
                    inputBehaviors.CollectWantsCapture(input, vRequests);
                    if (vRequests.Count > 0)
                    {
                        // end outstanding hovers
                        TerminateHovers(input);

                        // select one of the capture requests. technically we could end
                        //  up with none successfully Begin'ing, but behaviors should be
                        //  doing those checks in WantCapture, not BeginCapture !!
                        vRequests.OrderBy(x => x.element.Priority);
                        Capture capReq = null;
                        for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                        {
                            if (vRequests[i].side != CaptureSide.Any)
                            {
                                continue;       // not possible in mouse paths...
                            }
                            // before we actually begin capture we will complete any text editing
                            // [RMS] perhaps this should be configurable for behavior? Some behaviors
                            // do not require this (eg view controls...)
                            completeTextEntryOnFocusChange();

                            Capture c = vRequests[i].element.BeginCapture(input, vRequests[i].side);
                            if (c.state == CaptureState.Begin)
                            {
                                capReq = c;
                            }
                        }

                        captureMouse = capReq;
                    }
                }

                // if we don't have a capture, do hover
                if (captureMouse == null)
                {
                    inputBehaviors.UpdateHover(input);
                }
            }
        }
Exemplo n.º 3
0
        void HandleInput_SpaceControllers()
        {
            // update cursors
            SpatialController.Update();
            MouseController.HideCursor();

            // have to do this after cursor update in case hotkey uses mouse position
            HandleKeyboardInput();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_SpatialController(this);
            lastInputState = input;

            // run override behaviors
            overrideBehaviors.SendOverrideInputs(input);


            input.LeftCaptureActive  = (captureLeft != null);
            input.RightCaptureActive = (captureRight != null);

            // update left-capture
            if (captureLeft != null)
            {
                Capture cap = captureLeft.element.UpdateCapture(input, captureLeft.data);
                if (cap.state == CaptureState.Continue)
                {
                    // (carry on)
                }
                else if (cap.state == CaptureState.End)
                {
                    DebugUtil.Log(10, "[SceneController] released left capture " + captureLeft.element.CaptureIdentifier);
                    if (captureRight == captureLeft)
                    {
                        captureRight = null;        // if we are doing a dual-capture, we only want to end once!!
                    }
                    captureLeft = null;
                }
            }

            // update right-capture
            // if we are doing a both-capture, we only want to send update once
            if (captureRight != null && captureRight != captureLeft)
            {
                Capture cap = captureRight.element.UpdateCapture(input, captureRight.data);
                if (cap.state == CaptureState.Continue)
                {
                    // (carry on)
                }
                else if (cap.state == CaptureState.End)
                {
                    DebugUtil.Log(10, "[SceneController] released right capture " + captureRight.element.CaptureIdentifier);
                    captureRight = null;
                }
            }

            // if we have a free device, check for capture.
            bool bCanCapture = (bInCameraControl == false);

            if (bCanCapture && (captureLeft == null || captureRight == null))
            {
                // collect up capture requests
                List <CaptureRequest> vRequests = new List <CaptureRequest>();
                inputBehaviors.CollectWantsCapture(input, vRequests);
                if (vRequests.Count > 0)
                {
                    // end outstanding hovers
                    TerminateHovers(input);

                    // select one of the capture requests. technically we could end
                    //  up with none successfully Begin'ing, but behaviors should be
                    //  doing those checks in WantCapture, not BeginCapture !!
                    vRequests.OrderBy(x => x.element.Priority);
                    Capture capReq = null;
                    for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                    {
                        // filter out invalid requests
                        CaptureSide eUseSide = vRequests[i].side;
                        if (eUseSide == CaptureSide.Any)        // replace Any with Both. Does that make sense??
                        {
                            eUseSide = CaptureSide.Both;
                        }
                        if ((eUseSide == CaptureSide.Left || eUseSide == CaptureSide.Both) &&
                            captureLeft != null)
                        {
                            continue;
                        }
                        if ((eUseSide == CaptureSide.Right || eUseSide == CaptureSide.Both) &&
                            captureRight != null)
                        {
                            continue;
                        }

                        Capture c = vRequests[i].element.BeginCapture(input, eUseSide);
                        if (c.state == CaptureState.Begin)
                        {
                            capReq = c;
                        }
                    }

                    if (capReq != null)
                    {
                        // technically we only should terminate hover on capture controller,
                        // but that seems really hard. This will clear hovers but they will
                        // come back next frame. Perhaps revisit if this is causing flicker...
                        TerminateHovers(input);

                        // [RMS] most of this checking is redundant now, but leaving because of debug logging
                        if (capReq.data.which == CaptureSide.Left)
                        {
                            if (captureLeft != null)
                            {
                                DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for Left side from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier);
                            }
                            else
                            {
                                captureLeft = capReq;
                                DebugUtil.Log(10, "[SceneController] began left-capture" + captureLeft.element.CaptureIdentifier);
                            }
                        }
                        else if (capReq.data.which == CaptureSide.Right)
                        {
                            if (captureRight != null)
                            {
                                DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for Right side from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier);
                            }
                            else
                            {
                                captureRight = capReq;
                                DebugUtil.Log(10, "[SceneController] began right-capture" + captureRight.element.CaptureIdentifier);
                            }
                        }
                        else if (capReq.data.which == CaptureSide.Both || capReq.data.which == CaptureSide.Any)
                        {
                            if (captureLeft != null || captureRight != null)
                            {
                                DebugUtil.Warning("[SceneController.HandleInput_SpaceControllers] received Capture request for both sides from {0}, but already capturing! Ignoring.", capReq.element.CaptureIdentifier);
                            }
                            else
                            {
                                captureLeft = captureRight = capReq;
                                DebugUtil.Log(10, "[SceneController] began both-capture " + captureLeft.element.CaptureIdentifier);
                            }
                        }
                    }
                }
            }

            // update hover if we have a free device
            if (captureLeft == null || captureRight == null)
            {
                inputBehaviors.UpdateHover(input);
            }
        }
Exemplo n.º 4
0
        void HandleInput_Touch()
        {
            // update mouse/gamepad cursor
            MouseController.Update();

            // create our super-input object  (wraps all supported input types)
            InputState input = new InputState();

            input.Initialize_TouchInput(this);
            lastInputState = input;

            // run override behaviors
            overrideBehaviors.SendOverrideInputs(input);

            input.TouchCaptureActive = (captureTouch != null);

            // update left-capture
            if (captureTouch != null)
            {
                Capture cap = captureTouch.element.UpdateCapture(input, captureTouch.data);
                if (cap.state == CaptureState.Continue)
                {
                    // (carry on)
                }
                else if (cap.state == CaptureState.End)
                {
                    DebugUtil.Log(10, "[SceneController] released touch capture " + captureTouch.element.CaptureIdentifier);
                    captureTouch = null;
                }
            }

            // if we have a free device, check for capture.
            bool bCanCapture = (bInCameraControl == false);

            if (bCanCapture && captureTouch == null)
            {
                // collect up capture requests
                List <CaptureRequest> vRequests = new List <CaptureRequest>();
                inputBehaviors.CollectWantsCapture(input, vRequests);
                if (vRequests.Count > 0)
                {
                    // select one of the capture requests. technically we could end
                    //  up with none successfully Begin'ing, but behaviors should be
                    //  doing those checks in WantCapture, not BeginCapture !!
                    vRequests.OrderBy(x => x.element.Priority);
                    Capture capReq = null;
                    for (int i = 0; i < vRequests.Count && capReq == null; ++i)
                    {
                        // filter out invalid requests
                        //  (??)

                        // before we actually begin capture we will complete any text editing
                        // [RMS] perhaps this should be configurable for behavior? Some behaviors
                        // do not require this (eg view controls...)
                        completeTextEntryOnFocusChange();

                        Capture c = vRequests[i].element.BeginCapture(input, CaptureSide.Any);
                        if (c.state == CaptureState.Begin)
                        {
                            capReq = c;
                        }
                    }
                    if (capReq != null)
                    {
                        captureTouch = capReq;
                    }
                }
            }
        }
Exemplo n.º 5
0
        // Use this for initialization
        public void Start(SceneOptions options)
        {
            this.options = options;

            DebugUtil.LogLevel = options.LogLevel;

            // initialize VR platform if VR is active
            if (gs.VRPlatform.VREnabled)
            {
                if (options.Use2DCockpit)
                {
                    throw new Exception("FContext.Start: cannot use 2D Orthographic Cockpit with VR!");
                }
                if (options.SpatialCameraRig != null)
                {
                    gs.VRPlatform.Initialize(options.SpatialCameraRig);
                }
            }

            InputExtension.Get.Start();

            nextFrameActions = new ActionSet();

            // intialize camera stuff
            camTracker = new CameraTracking();
            camTracker.Initialize(this);

            GetScene();
            if (options.SceneInitializer != null)
            {
                options.SceneInitializer.Initialize(GetScene());
            }

            if (options.DefaultGizmoBuilder != null)
            {
                transformManager = new TransformManager(options.DefaultGizmoBuilder);
            }
            else
            {
                transformManager = new TransformManager(new AxisTransformGizmoBuilder());
            }
            if (options.EnableTransforms)
            {
                transformManager.Initialize(this);
            }

            toolManager = new ToolManager();
            toolManager.Initialize(this);
            toolManager.OnToolActivationChanged += OnToolActivationChanged;

            MouseController.Start();
            SpatialController.Start();

            // [RMS] hardcode starting cam target point to origin
            ActiveCamera.SetTarget(Vector3f.Zero);

            if (options.MouseCameraControls != null)
            {
                MouseCameraController = options.MouseCameraControls;
            }

            // apply initial transformation to scene
            ActiveCamera.Manipulator().SceneTranslate(Scene, SceneGraphConfig.InitialSceneTranslate);

            // create behavior sets
            inputBehaviors    = new InputBehaviorSet();
            overrideBehaviors = new InputBehaviorSet();

            // cockpit needs to go last because UI setup may depend on above
            cockpitStack = new Stack <Cockpit>();
            if (options.EnableCockpit)
            {
                PushCockpit(options.CockpitInitializer);
            }


            captureMouse     = null;
            captureTouch     = null;
            captureLeft      = captureRight = null;
            bInCameraControl = false;

            // [RMS] this locks cursor to game unless user presses escape or exits
            if (FPlatform.IsUsingVR() || options.UseSystemMouseCursor == false)
            {
                Cursor.lockState = CursorLockMode.Locked;
            }

            // set hacky hackenstein global
            ActiveContext_HACK = this;

            startup_checks();
        }