Exemplo n.º 1
0
    // This method controllers how the function can be forwards and backwards
    // Created by Harvey Huag with the help of Rayhan Fakim
    private void joystickXYFunctionality()
    {
        float joyStickY = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.JoystickY);
        float joyStickX = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.JoystickX);

        moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0.0f, Input.GetAxis("Horizontal"));
    }
Exemplo n.º 2
0
    private void FixedUpdate()
    {
        float hMovement = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.PadX);

        __onPadXTouched(Mathf.Clamp(hMovement, -1.0f, 1.0f));

        float vMovement = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.PadY);

        __onPadYTouched(Mathf.Clamp(vMovement, -1.0f, 1.0f));
    }
Exemplo n.º 3
0
    private void joystickYFunctionality()
    {
        float joyStickYLEFT = ViveInput.GetAxisEx(HandRole.LeftHand, ControllerAxis.JoystickY);

        if (joyStickYLEFT > 0.5f)
        {
            ProceduralGrid.amplitude += BaseAmpl;
        }
        if (joyStickYLEFT < -0.5f)
        {
            ProceduralGrid.amplitude -= BaseAmpl;
        }
        // ProcedualGrid.amplitude = ViveInput.GetAxisEx(HandRole.LeftHand, ControllerAxis.JoystickY) * BaseAmp + 1;
    }
Exemplo n.º 4
0
    /// <summary>
    /// when scaling is actived (The object is grabbed),
    /// change its scale based on the Y axis value of the joystick
    /// </summary>
    void Update()
    {
        if (scalingActivated)
        {
            float joystickY = 0.0f;

            switch (handGrabbing)
            {
            case joystick.leftHand:
                joystickY = ViveInput.GetAxisEx(HandRole.LeftHand, ControllerAxis.JoystickY);
                break;

            case joystick.rightHand:
                joystickY = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.JoystickY);
                break;

            case joystick.none:
                Debug.Log("Scaling error: no trigger press, grabbed with another button?");
                break;
            }

            gameObject.transform.localScale *= (1 + scalingFactor * joystickY);
        }
    }
Exemplo n.º 5
0
 float GetY()
 {
     return(ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.PadY));
 }
Exemplo n.º 6
0
        protected override void Update()
        {
            hmdDisplay.recordingModeActiveIndicator(player.isRecording);

            if (ViveInput.GetPressDown(HandRole.LeftHand, ControllerButton.Menu) ||
                ViveInput.GetPressDown(HandRole.RightHand, ControllerButton.Menu))
            {
                Close();
                mainUI.Open();
            }

            base.Update();

            strokingValue = ViveInput.GetAxisEx(HandRole.RightHand, ControllerAxis.Trigger);

            // abort condition
            var endStrokeNow = stroking && strokingValue < paintThreshold;

            // start a new stroke if not stroking right now and over threshold
            if (strokingValue >= paintThreshold && !stroking)
            {
                OnStrokeStart();
                stroking = true;
            }

            if (stroking)
            {
                var probe = new Ray(rightControllerGO.transform.position,
                                    rightControllerGO.transform.rotation * Vector3.forward);
                if (Physics.Raycast(probe, out var hit, 10f, LayerMask.GetMask("Interface/Model")))
                {
                    var distanceToPrev = float.MaxValue;
                    if (currentStroke != null && currentStroke.keys.Count > 0)
                    {
                        distanceToPrev = Vector3.Distance(currentStroke.keys.Last().position, hit.point);
                    }

                    // only add a key to our stroke in case a min time has passed and there is a min distance to the previous key
                    if (nextKeyTime <= Time.time && distanceToPrev >= Constants.MIN_DISTANCE_BETWEEN_KEYS ||
                        endStrokeNow)
                    {
                        nextKeyTime = Time.time + 1f / Constants.SAMPLE_RATE;
                        var currentIntensities =
                            currentPaintingTool.OnStroke(hit, currentStroke, strokeTime, strokingValue);

                        if (hmdDisplay != null)
                        {
                            hmdDisplay.SetStrokingInfo(strokingValue);
                        }

                        RaspberryCommandSender.Instance.updateActuators(currentIntensities, player.activeTimes);

                        if (erasing)
                        {
                        }
                        strokeTime += Time.deltaTime;
                        player.SetTime(strokeTime);


                        if (endStrokeNow)
                        {
                            if (erasing)
                            {
                            }
                            stroking = false;
                            OnStrokeEnd();
                        }
                    }

                    if (player.isRecording && !stroking && currentStroke != null && currentStroke.duration > 0)
                    {
                        strokeTime += Time.deltaTime;
                        player.SetTime(strokeTime);
                    }
                }
            }
            timeline.ReDrawAllMarkers();
        }