Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (_trackedobj.index == SteamVR_TrackedObject.EIndex.None)
        {
            return;
        }
        _controller = SteamVR_Controller.Input((int)_trackedobj.index);

        if (_controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
        {
            //Vector2 touchpad = _leftController.GetAxis(EVRButtonId.k_EButton_Axis0);
            Vector2 touchpad = _controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Touchpad);

            _video.Playing = !_video.Playing;

            if (_video.Playing)
            {
                _video.Play();
            }
            else
            {
                _video.Pause();
            }
        }
    }
Exemplo n.º 2
0
    void HandleVideoPlayback()
    {
        if (_leftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad) && _video != null)
        {
            Vector2 touchpad = _leftController.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad);

            if (touchpad.y > 0.7f)
            {
                print("Pressed Stop");
                _video.Stop();
                _playing = false;
                _annotationManager.DisableAnnotations();
                _annotationManager.currentTime    = 0.0f;
                _annotationManager.IsPlayingVideo = false;
                GameObject o = GameObject.Find("Avatar");
                if (o != null)
                {
                    o.GetComponent <SkeletonRepresentation>().hide();
                }
            }
            else if (touchpad.y < -0.7f)
            {
                print("Pressed Play");
                _playing = !_playing;

                if (_playing)
                {
                    _video.Play();
                    SetRepresentation(_representation);
                    _annotationManager.IsPlayingVideo = true;
                }
                else
                {
                    _video.Pause();
                    _annotationManager.IsPlayingVideo = false;
                }
            }
            else if (touchpad.x > 0.7f)
            {
                print("Pressed Foward");
                _video.Skip5Sec();
            }
            else if (touchpad.x < -0.7f)
            {
                print("Pressed Backward");
                _video.Back5Sec();
            }
        }

        if (_video != null && _video.getVideoTime() != 0 && _video.getVideoDuration() != 0)
        {
            float ratio = _video.getVideoTime() / _video.getVideoDuration();

            //_slider.SetActive(true);
            _slider.GetComponentInChildren <Slider>().value = ratio;
            //_slider.transform.position = new Vector3(0, 2.5f, 0);
            //  _slider.transform.forward =  Camera.main.transform.forward;
        }

        if (_video != null)
        {
            _video.Update();
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (_rightObj.index == SteamVR_TrackedObject.EIndex.None || _leftObj.index == SteamVR_TrackedObject.EIndex.None)
        {
            return;
        }
        _rightController = SteamVR_Controller.Input((int)_rightObj.index);
        _leftController  = SteamVR_Controller.Input((int)_leftObj.index);

        if (_annotationManager != null)
        {
            _annotationManager.SetRightHand(_rightHand);
            _annotationManager.SetRightHandController(_rightController);
            _annotationManager.SetHead(_head);
            _annotationManager.Update();
        }

        InputOpenMenus();

        if (_video != null)
        {
            if (_video.getTime() != 0 && _video.getDuration() != 0)
            {
                float ratio = _video.getTime() / _video.getDuration();

                //_slider.SetActive(true);
                _slider.GetComponentInChildren <Slider>().value = ratio;
                //_slider.transform.position = new Vector3(0, 2.5f, 0);
                //  _slider.transform.forward =  Camera.main.transform.forward;
            }
        }

        if (_menu == MenuOpened.DatasetSelect)
        {
            SelectDataset();
        }
        else if (_menu == MenuOpened.ColorSelect)
        {
            // SelectColor();
        }
        else if (_menu == MenuOpened.AnnotationSelect)
        {
            _menuGO.transform.position = new Vector3(_rightHand.transform.position.x,
                                                     _rightHand.transform.position.y + 0.15f, _rightHand.transform.position.z);
            Vector3 rot = _head.transform.forward;
            rot.y = 0.0f;
            _menuGO.transform.rotation = Quaternion.LookRotation(rot);
            SelectAnnotationType();
        }
        else if (_menu == MenuOpened.AnnotationEdit)
        {
            _menuGO.transform.position = new Vector3(_rightHand.transform.position.x,
                                                     _rightHand.transform.position.y + 0.15f, _rightHand.transform.position.z);
            Vector3 rot = _head.transform.forward;
            rot.y = 0.0f;
            _menuGO.transform.rotation = Quaternion.LookRotation(rot);
            EditAnnotations();
        }


        //if no menu is opened, annotation input, and playback control
        else if (_menu == MenuOpened.None)
        {
            if (!_controlDataset.activeSelf && _video != null)
            {
                _controlDataset.SetActive(true);
            }
            else
            {
                _controlDataset.transform.position = new Vector3(_leftHand.transform.position.x,
                                                                 _leftHand.transform.position.y + 0.15f, _leftHand.transform.position.z);
                Vector3 rot = Camera.main.transform.forward;
                rot.y = 0.0f;
                _controlDataset.transform.rotation = Quaternion.LookRotation(rot);
            }

            if (_leftController.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                //Vector2 touchpad = _leftController.GetAxis(EVRButtonId.k_EButton_Axis0);
                Vector2 touchpad = _leftController.GetAxis(EVRButtonId.k_EButton_SteamVR_Touchpad);

                if (touchpad.y > 0.7f)
                {
                    print("Pressed Stop");
                    _video.Stop();
                    _playing = false;
                    _controlDataset.SetActive(false);
                    _annotationManager.DisableAnnotations();
                    _annotationManager.currentTime    = 0.0f;
                    _annotationManager.IsPlayingVideo = false;
                    GameObject o = GameObject.Find("Avatar");
                    if (o != null)
                    {
                        o.GetComponent <SkeletonRepresentation>().hide();
                    }
                }

                else if (touchpad.y < -0.7f)
                {
                    print("Pressed Play");
                    _playing = !_playing;

                    if (_playing)
                    {
                        _video.Play();
                        SetRepresentation(_representation);
                        _annotationManager.IsPlayingVideo = true;
                    }
                    else
                    {
                        _video.Pause();
                        _annotationManager.IsPlayingVideo = false;
                    }
                }

                else if (touchpad.x > 0.7f)
                {
                    print("Pressed Foward");
                    _video.Skip5Sec();
                }

                else if (touchpad.x < -0.7f)
                {
                    print("Pressed Backward");
                    _video.Back5Sec();
                }
            }


            /*  //Got controllers, now handle input.
             * if (_rightController.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
             * {
             *    _playing = !_playing;
             *
             *    if (_playing)
             *        _video.Play();
             *    else
             *        _video.Pause();
             * }
             */

            if (_rightController.GetPressDown(SteamVR_Controller.ButtonMask.Trigger) && _annotationManager != null && !_annotationManager.IsAnnotationActive)
            {
                EnableRightPointer();
                if (_annotationManager != null)
                {
                    _annotationManager.EditAnnotation();
                    Debug.Log("Annotation Selected = " + _annotationManager.currentAnnotationSelected);
                }
            }
            if (_rightController.GetPressUp(SteamVR_Controller.ButtonMask.Trigger) && _annotationManager != null && !_annotationManager.IsAnnotationActive)
            {
                Ray        raycast = new Ray(_rightHand.transform.position, _rightHand.transform.forward);
                RaycastHit hit;
                bool       bHit = Physics.Raycast(raycast, out hit);
                if (bHit && hit.collider.gameObject.name.Equals("VRPlane"))
                {
                    Debug.Log("colide with = " + hit.collider.gameObject.name);
                    GameObject camera = GameObject.Find("[CameraRig]");
                    camera.transform.position = new Vector3(hit.point.x, camera.transform.position.y, hit.point.z);
                }
                DisableRightPointer();
            }
        }
    }