Beispiel #1
0
    // Update is called once per frame
    public void Update()
    {
        if (IsAnnotationActive)
        {
            currentAnimationGO.transform.position = new Vector3(_rightHand.transform.position.x,
                                                                _rightHand.transform.position.y + 0.075f, _rightHand.transform.position.z);
            Vector3 rot = Camera.main.transform.forward;
            rot.y = 0.0f;
            currentAnimationGO.transform.rotation = Quaternion.LookRotation(rot);

            if (bVisualEffect)
            {
                //Debug.Log("Start highlightPoint Annotation");
                visualEffectAnnotation.annotate();

                if (!visualEffectAnnotation.IsActive)
                {
                    currentAnimationGO.SetActive(false);
                    if (visualEffectAnnotation.getHasBeenCreated())
                    {
                        staticAnnotationList.Add(visualEffectAnnotation);
                        DrawAnnotationsOnTimeline();
                    }
                    bVisualEffect = false;
                }
            }
            else if (bScribbler)
            {
                //Debug.Log("Start Scribbler Annotation");
                scribblerAnnotation.annotate();

                if (!scribblerAnnotation.IsActive)
                {
                    currentAnimationGO.SetActive(false);
                    if (scribblerAnnotation.getHasBeenCreated())
                    {
                        staticAnnotationList.Add(scribblerAnnotation);
                        DrawAnnotationsOnTimeline();
                    }

                    bScribbler = false;
                }
            }
            else if (bSpeechToText)
            {
                //Debug.Log("Start SpeechToText Annotation");
                speechAnnotation.annotate();
                if (!speechAnnotation.IsActive)
                {
                    currentAnimationGO.SetActive(false);
                    if (speechAnnotation.getHasBeenCreated())
                    {
                        staticAnnotationList.Add(speechAnnotation);
                        DrawAnnotationsOnTimeline();
                    }
                    bSpeechToText = false;
                }
            }

            else if (bMark)
            {
                //Debug.Log("Start Mark Annotation");
                markAnnotation.annotate();

                if (!markAnnotation.IsActive)
                {
                    currentAnimationGO.SetActive(false);
                    if (markAnnotation.getHasBeenCreated())
                    {
                        staticAnnotationList.Add(markAnnotation);
                        DrawAnnotationsOnTimeline();
                    }
                    _rightPointer.SetActive(false);
                    bMark = false;
                }
            }
            else if (bFloor)
            {
                //Debug.Log("Start Floor Annotation");
                floorAnnotation.annotate();

                if (!floorAnnotation.IsActive)
                {
                    currentAnimationGO.SetActive(false);
                    if (floorAnnotation.getHasBeenCreated())
                    {
                        staticAnnotationList.Add(floorAnnotation);
                        DrawAnnotationsOnTimeline();
                    }

                    bFloor = false;
                }
            }
        }
        IsAnnotationActive = bVisualEffect || bScribbler || bSpeechToText || bMark || bFloor;

        if (_video != null && staticAnnotationList.Count > 0)
        {
            currentTime = _video.getVideoTime();
            Debug.Log("number of annotations = " + staticAnnotationList.Count);
            foreach (StaticAnnotation staticAnnotation in staticAnnotationList)
            {
                Debug.Log("duration = " + staticAnnotation.getDuration());
                if (currentTime >= staticAnnotation.getStart() && currentTime < staticAnnotation.getStart() + staticAnnotation.getDuration())
                {
                    staticAnnotation.play();
                    //_video.Play();
                }
                else
                {
                    staticAnnotation.stop();
                }
            }
        }
    }
    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();
        }
    }