コード例 #1
0
ファイル: Drawing.cs プロジェクト: adamchang2000/hw4
    void pickerInput()
    {
        bool _press = c_non_dom.GetPress(WVR_InputId.WVR_InputId_Alias1_Touchpad);

        if (_press && !_prev)
        {
            Log.i("drawing", "starting input", true);
            start       = non_dom_t.rotation;
            start_color = new Color(color.r, color.g, color.b);
            float S, V;

            Color.RGBToHSV(start_color, out H, out S, out V);

            selectSphere.SetActive(true);

            /*
             * selectSphere.transform.position = non_dom_t.position;
             * selectSphere.transform.rotation = non_dom_t.rotation;*/
            selectSphere.GetComponent <MeshRenderer>().material.SetColor("_Color", color);
        }
        else if (_press)
        {
            /*
             * selectSphere.transform.position = non_dom_t.position;
             * selectSphere.transform.rotation = non_dom_t.rotation;*/
            selectSphere.GetComponent <MeshRenderer>().material.SetColor("_Color", color);

            Quaternion current_rotation = non_dom_t.rotation;
            float      rotation_h       = Quaternion.Angle(start, current_rotation) / 180.0f;

            rotation_h += H;

            if (rotation_h > 1)
            {
                rotation_h -= 1;
            }
            if (rotation_h < 0)
            {
                rotation_h += 1;
            }

            color = Color.HSVToRGB(rotation_h, 1.0f, 1.0f);
        }
        _prev = _press;

        pickerInput1();
        clearInput();
        //undoInput();
        moveInput();
        scaleInput();
        rotationInput();
    }
コード例 #2
0
    void Update()
    {
        bool _press = c_dom.GetPress(WVR_InputId.WVR_InputId_Alias1_Trigger);

        if (_press && !_prev)
        {
            first.p = dom_transform.position;
            ml      = new Mesh();
        }

        Vector3 e;

        if (Input.GetMouseButtonDown(0))
        {
            s = transform.InverseTransformPoint(GetNewPoint());
        }

        if (Input.GetMouseButton(0))
        {
            e = GetNewPoint();
            AddLine(ml, MakeQuad(transform.TransformPoint(s), e, lineSize), true);
        }

        if (Input.GetMouseButtonUp(0))
        {
            e = GetNewPoint();
            AddLine(ml, MakeQuad(transform.TransformPoint(s), e, lineSize), false);
        }

        Draw();
    }
コード例 #3
0
 public override bool GetPress(XRButton button)
 {
     if (controller == null || !focusMappings.ContainsKey(button))
     {
         return(false);
     }
     return(controller.GetPress(focusMappings[button]));
 }
コード例 #4
0
ファイル: Drawing.cs プロジェクト: adamchang2000/hw4
    // Update is called once per frame
    void Update()
    {
        pickerInput();
        bool _press = c_dom.GetPress(WVR_InputId.WVR_InputId_Alias1_Trigger);

        if (_press && !prev_press)
        {
            drawingSphere.GetComponent <MeshRenderer>().enabled = true;
            eraser.GetComponent <MeshRenderer>().enabled        = false;
            go = new GameObject();
            go.SetActive(false);
            arr.Add(go);
            lr               = go.AddComponent <LineRenderer>();
            lr.startWidth    = width;
            lr.endWidth      = width;
            lr.useWorldSpace = false;

            Log.i("drawing", "drawing with colors:", true);
            Log.i("drawing", "r: " + (int)color.r, true);
            Log.i("drawing", "g: " + (int)color.g, true);
            Log.i("drawing", "b: " + (int)color.b, true);
            lr.material       = new Material(Shader.Find("Standard"));
            lr.material.color = color;
            lr.SetColors(color, color);
            num = 0;
        }
        else if (_press)
        {
            go.SetActive(true);
            lr.positionCount = num + 1;
            lr.SetPosition(num, drawingSphere.transform.position);
            num++;
        }
        previous   = dom_t;
        prev_press = _press;
    }
コード例 #5
0
 public override bool IsButtonPressed(WVR_InputId button)
 {
     return(Device.GetPress(button));
 }
コード例 #6
0
        private void UpdateDeviceInput(uint deviceIndex, WaveVR_Controller.Device deviceInput)
        {
#if VIU_WAVEVR_2_1_0_OR_NEWER
            const WVR_InputId digitalTrggerBumpID = WVR_InputId.WVR_InputId_Alias1_Digital_Trigger;
#else
            const WVR_InputId digitalTrggerBumpID = WVR_InputId.WVR_InputId_Alias1_Bumper;
#endif

            IVRModuleDeviceState   prevState;
            IVRModuleDeviceStateRW currState;

            if (!TryGetValidDeviceState(deviceIndex, out prevState, out currState) || !deviceInput.connected)
            {
                return;
            }

            if (deviceInput != null)
            {
                var systemPressed         = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_System);
                var menuPressed           = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_Menu);
                var triggerPressed        = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_Trigger);
                var digitalTriggerPressed = deviceInput.GetPress(digitalTrggerBumpID);
                var gripPressed           = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_Grip);
                var touchpadPressed       = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_Touchpad);
                var dpadLeftPressed       = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Left);
                var dpadUpPressed         = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Up);
                var dpadRightPressed      = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Right);
                var dpadDownPressed       = deviceInput.GetPress(WVR_InputId.WVR_InputId_Alias1_DPad_Down);
                currState.SetButtonPress(VRModuleRawButton.System, systemPressed);
                currState.SetButtonPress(VRModuleRawButton.ApplicationMenu, menuPressed);
                currState.SetButtonPress(VRModuleRawButton.Touchpad, touchpadPressed || dpadLeftPressed || dpadUpPressed || dpadRightPressed || dpadDownPressed);
                currState.SetButtonPress(VRModuleRawButton.Trigger, triggerPressed || digitalTriggerPressed);
                currState.SetButtonPress(VRModuleRawButton.Grip, gripPressed);
                currState.SetButtonPress(VRModuleRawButton.DPadLeft, dpadLeftPressed);
                currState.SetButtonPress(VRModuleRawButton.DPadUp, dpadUpPressed);
                currState.SetButtonPress(VRModuleRawButton.DPadRight, dpadRightPressed);
                currState.SetButtonPress(VRModuleRawButton.DPadDown, dpadDownPressed);

                var systemTouched         = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_System);
                var menuTouched           = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_Menu);
                var triggerTouched        = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_Trigger);
                var digitalTriggerTouched = deviceInput.GetTouch(digitalTrggerBumpID);
                var gripTouched           = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_Grip);
                var touchpadTouched       = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_Touchpad);
                var dpadLeftTouched       = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_DPad_Left);
                var dpadUpTouched         = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_DPad_Up);
                var dpadRightTouched      = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_DPad_Right);
                var dpadDownTouched       = deviceInput.GetTouch(WVR_InputId.WVR_InputId_Alias1_DPad_Down);
                currState.SetButtonTouch(VRModuleRawButton.System, systemTouched);
                currState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, menuTouched);
                currState.SetButtonTouch(VRModuleRawButton.Touchpad, touchpadTouched || dpadLeftTouched || dpadUpTouched || dpadRightTouched || dpadDownTouched);
                currState.SetButtonTouch(VRModuleRawButton.Trigger, triggerTouched || digitalTriggerTouched);
                currState.SetButtonTouch(VRModuleRawButton.Grip, gripTouched);
                currState.SetButtonTouch(VRModuleRawButton.DPadLeft, dpadLeftTouched);
                currState.SetButtonTouch(VRModuleRawButton.DPadUp, dpadUpTouched);
                currState.SetButtonTouch(VRModuleRawButton.DPadRight, dpadRightTouched);
                currState.SetButtonTouch(VRModuleRawButton.DPadDown, dpadDownTouched);

                var triggerAxis = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Trigger);
                var touchAxis   = deviceInput.GetAxis(WVR_InputId.WVR_InputId_Alias1_Touchpad);
                currState.SetAxisValue(VRModuleRawAxis.Trigger, triggerAxis.x);
                currState.SetAxisValue(VRModuleRawAxis.TouchpadX, touchAxis.x);
                currState.SetAxisValue(VRModuleRawAxis.TouchpadY, touchAxis.y);
            }
            else
            {
                currState.buttonPressed = 0u;
                currState.buttonTouched = 0u;
                currState.ResetAxisValues();
            }
        }