예제 #1
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        float duration   = (float)playable.GetDuration();
        float passedTime = (float)playable.GetTime();

        Debug.Log("Playable get time " + playable.GetTime());
        Debug.Log("Playable duration " + playable.GetDuration());

        float t = duration - passedTime;

        Vector3 change = position - initialPosition;

        trasnform.position = Equations.ChangeVector(t, position, change, duration, Ease.Linear);
    }
예제 #2
0
    public override void OnGraphStart(Playable playable)
    {
        duration = (float)playable.GetDuration();
        float scrollingDuration = Mathf.Clamp(duration - holdDelay - startDelay, float.Epsilon, duration);

        inverseScrollingDuration = 1f / scrollingDuration;
    }
예제 #3
0
        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
            base.OnBehaviourPause(playable, info);
            firstFrameHappened = false;

            var duration = playable.GetDuration();

            var time  = playable.GetTime();
            var delta = info.deltaTime;

            if (info.evaluationType == FrameData.EvaluationType.Playback)
            {
                var count = time + delta;

                if (count >= duration)
                {
                    TimelineManager.instance.Pause();
                }
            }

            //if (chatInteraction == null)
            //{
            //    return;
            //}
            //chatInteraction.transform.position = defaultPos;
        }
예제 #4
0
        public override void OnBehaviourPause(Playable playable, FrameData info)
        {
            if (video == null)
            {
                return;
            }

            if (PlayingState.IsPreviewingInPlayMode || PlayingState.IsPlayingTimelineInEditor)
            {
                video.Stop();
            }

            if (PlayingState.IsScrubbing)
            {
                var duringVideo = (playable.GetTime() / playable.GetDuration()) < 1d;
                if (duringVideo)
                {
                    video.Pause();
                }
                else
                {
                    video.Stop();
                }
            }

            if (PlayingState.IsRecording)
            {
                video.Stop();
                video.frameReady -= FrameReady;
                isInVideoTime     = false;
            }
        }
예제 #5
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                if (_subject == null || playable.GetTime() <= 0)
                {
                    return;
                }

                float f = (float)(playable.GetTime() / playable.GetDuration()) * info.weight;

                if (useQuaternion)
                {
                    if (isLocal)
                    {
                        _subject.localRotation = Quaternion.Lerp(Quaternion.Euler(src), Quaternion.Euler(dst), curve.Evaluate(f));
                    }
                    else
                    {
                        _subject.rotation = Quaternion.Lerp(Quaternion.Euler(src), Quaternion.Euler(dst), curve.Evaluate(f));
                    }
                }
                else
                {
                    if (isLocal)
                    {
                        _subject.localEulerAngles = Vector3.Lerp(src, dst, curve.Evaluate(f));
                    }
                    else
                    {
                        _subject.eulerAngles = Vector3.Lerp(src, dst, curve.Evaluate(f));
                    }
                }
            }
예제 #6
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        Debug.Log(MethodInfo.GetCurrentMethod().Name + " Time=" + playable.GetTime());

        double preTime      = playable.GetPreviousTime();
        double timeOnClip   = playable.GetTime();
        double deltaTime    = timeOnClip - preTime;
        double durationTime = playable.GetDuration();
        double rate         = timeOnClip / durationTime;
        double rateAfter    = (timeOnClip + deltaTime) / durationTime;

        double weight = info.weight;

        int inputCount  = playable.GetInputCount();
        int outputCount = playable.GetOutputCount();

        Debug.Log(MethodInfo.GetCurrentMethod().Name + " InputCount=" + inputCount);

        // 文字列を設定
        messageDialog.SetText(textString);

        // 表示する
        messageDialog.Show();


        // ★次のフレームで完了する(クリップから抜ける)時
        // ※クリップを抜けるとProcessFrameは呼ばれず、OnBehaviourPauseが呼ばれるので、
        // ProcessFrame内で捕まえるタイミングは今しかない。
        if (rate < 1.0f && 1.0f <= rateAfter)
        {
            OnBehaviourPreFinish(playable, info, playerData);
        }
    }
예제 #7
0
    /// <summary>
    /// クリップ再生時の処理
    /// </summary>
    /// <param name="playable"></param>
    /// <param name="info"></param>
    public override void OnBehaviourPlay(Playable playable, FrameData info)
    {
        // クリップの開始時間を保持
        var clipStartTime = Director.time;

        clipEndTime = clipStartTime + playable.GetDuration();
    }
    // Called each frame while the state is set to Play
    public override void PrepareFrame(Playable playable, FrameData info)
    {
        // Debug.Log ("SimplePlayableBehaviour.PrepareFrame");
        float normTime = (float)(playable.GetTime() / playable.GetDuration());

        cubeObject.transform.position = new Vector3(4.0f, 2.0f * normTime, 0.0f);
    }
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        Plugin = playerData as Plugin4DS;

        if (onstart)
        {
            if (Plugin == null)
            {
                return;
            }

            double duration = playable.GetDuration() * Plugin.Framerate;
            double newSpeed = 1;

            if (firstFrame < lastFrame && firstFrame >= 0)
            {
                newSpeed = (lastFrame - firstFrame) / duration;
                //Debug.Log("new speed : " + newSpeed);
            }
            else
            {
                newSpeed = (Plugin.SequenceNbOfFrames - firstFrame) / duration;
                //Debug.Log("new speed : " + newSpeed);
            }

            Plugin.SpeedRatio = (float)newSpeed;
            Plugin.GotoFrame(firstFrame);
            Plugin.Play(true);

            onstart = false;
        }

        base.ProcessFrame(playable, info, playerData);
    }
예제 #10
0
 private void Setup(Playable playable)
 {
     _started  = true;
     _duration = (float)playable.GetDuration();
     Animator  = PoseAnimator.Main;
     Animator.UpdatePose();
     SetupPoseTransition(Animator.DefaultPose);
 }
예제 #11
0
 // Called each frame while the state is set to Play
 public override void PrepareFrame(Playable playable, FrameData info)
 {
     if (blurCtrl != null)
     {
         var pct = playable.GetTime() / playable.GetDuration();
         blurCtrl.blurSize.value = this.blurSizeCur.Evaluate((float)pct);
     }
 }
예제 #12
0
 void SyncDurationWithExternalSource(Playable playable)
 {
     if (m_TimeSource.IsValid())
     {
         playable.SetDuration(m_TimeSource.GetDuration());
         playable.SetTimeWrapMode(m_TimeSource.GetTimeWrapMode());
     }
 }
예제 #13
0
    //Each frame of the behaviour
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        m_TrackBinding = playerData as RPGTalk;
        if (!m_FirstFrameHappened)
        {
            OnBehaviourPlay(playable, info);
            return;
        }



        //for now, we wont support spped changes into timeline
        if (m_TrackBinding.actualTextSpeed != textSpeed)
        {
            m_TrackBinding.actualTextSpeed = textSpeed;
        }

        //The current character will be calculated based on the textspeed and the time of the playable
        float currentChar = m_TrackBinding.actualTextSpeed * (float)playable.GetTime();



        //only change it if there is something new to change and we are not paused
        if (m_TrackBinding.rpgtalkElements.Count > m_TrackBinding.cutscenePosition - 1 &&
            Mathf.Min(currentChar, m_TrackBinding.rpgtalkElements [m_TrackBinding.cutscenePosition - 1].dialogText.Length)
            != m_TrackBinding.currentChar)
        {
            if (!rpgTime || !rpgTime.isPaused)
            {
                m_TrackBinding.currentChar = currentChar;
                m_TrackBinding.PutRightTextToShow();
            }
        }

        //If we reached the final, check if we should pause the timeline until the player finish the talk
        if (playable.GetTime() >= playable.GetDuration() - (double)0.1)
        {
            if (!reachedFinal)
            {
                reachedFinal = true;
                if (pauseUntilTalkEnd)
                {
                    if (!rpgTime)
                    {
                        Debug.LogError("To use the option 'Pause Until Talk End' the RpgTalk must contain a RPGTalkTimeline Component");
                    }
                    else
                    {
                        rpgTime.Pause();
                    }
                }
            }
        }
        else
        {
            reachedFinal = false;
        }
    }
예제 #14
0
 //Will hide the dialogue in the last .4f seconds of the clip
 //so that a following piece of dialogue doesn't overlap
 public override void ProcessFrame(Playable playable, FrameData info, object playerData)
 {
     if (!dialogueHidden &&
         (float)(playable.GetDuration() - playable.GetTime()) < .4f)
     {
         UIManager.Instance.HideDialogue();
         dialogueHidden = true;
     }
 }
예제 #15
0
    /// <summary>
    /// クリップの再生終了時刻へ時間を飛ばす処理
    /// </summary>
    /// <param name="playable"></param>
    public void GoToClipEnd(Playable playable)
    {
        // クリップ全体の時間
        var clipDuration = playable.GetDuration();
        // 経過時間
        var clipNowTime = playable.GetTime();

        Director.time += clipDuration - clipNowTime;
    }
예제 #16
0
 /// <summary>
 /// クリップ終了時に呼び出される処理
 /// </summary>
 /// <param name="playable"></param>
 /// <param name="info"></param>
 public override void OnBehaviourPause(Playable playable, FrameData info)
 {
     // まだループするべきなら時間をクリップの開始時刻に戻す
     if (IsLooping)
     {
         Director.time -= playable.GetDuration();
         return;
     }
 }
예제 #17
0
 public override void OnGraphStart(Playable playable)
 {
     Duration = playable.GetDuration();
     if (Mathf.Approximately((float)Duration, 0f))
     {
         throw new UnityException("A TransformTween cannot have a duration of zero.");
     }
     inverseDuration = 1f / (float)Duration;
 }
예제 #18
0
    public override void OnPlayableCreate(Playable playable)
    {
        var duration = playable.GetDuration();

        if (Mathf.Approximately((float)duration, 0))
        {
            throw new UnityException("A Clip Cannot have a duration of zero");
        }
    }
예제 #19
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            duration   = (float)playable.GetDuration();
            passedTime = (float)playable.GetTime();

            float t = duration - passedTime;

            EvaluteAtTime(t);
        }
예제 #20
0
    private bool fadeOutRequired(Playable playable)
    {
        // Check whether we are currently within a fade out or blend out segment.
        float timeLeft = (float)(playable.GetDuration() - playable.GetTime());
        float remainingBlendOutDuration = blendOutDuration - timeLeft;
        float remainingEaseOutDuration  = easeOutDuration - timeLeft;

        return(remainingBlendOutDuration >= 0.0f || remainingEaseOutDuration >= 0.0f);
    }
예제 #21
0
        /// <summary>
        /// This method is called during the PrepareFrame phase of the PlayableGraph.
        /// </summary>
        /// <remarks>
        /// Called once before processing starts.
        /// </remarks>
        /// <param name="playable">The reference to the playable associated with this PlayableBehaviour.</param>
        /// <param name="info">Playable context information such as weight, evaluationType, and so on.</param>
        public override void PrepareFrame(Playable playable, FrameData info)
        {
            // Never trigger on scrub
            if (info.evaluationType == FrameData.EvaluationType.Evaluate)
            {
                return;
            }

            SyncDurationWithExternalSource(playable);
            SortNotifications();
            var currentTime = playable.GetTime();

            // Fire notifications from previousTime till the end
            if (info.timeLooped)
            {
                var duration = playable.GetDuration();
                TriggerNotificationsInRange(m_PreviousTime, duration, info, playable, true);
                var dx             = playable.GetDuration() - m_PreviousTime;
                var nFullTimelines = (int)((info.deltaTime * info.effectiveSpeed - dx) / playable.GetDuration());
                for (var i = 0; i < nFullTimelines; i++)
                {
                    TriggerNotificationsInRange(0, duration, info, playable, false);
                }
                TriggerNotificationsInRange(0, currentTime, info, playable, false);
            }
            else
            {
                var pt = playable.GetTime();
                TriggerNotificationsInRange(m_PreviousTime, pt, info,
                                            playable, true);
            }

            for (var i = 0; i < m_Notifications.Count; ++i)
            {
                var e = m_Notifications[i];
                if (e.notificationFired && CanRestoreNotification(e, info, currentTime, m_PreviousTime))
                {
                    Restore_internal(ref e);
                    m_Notifications[i] = e;
                }
            }

            m_PreviousTime = playable.GetTime();
        }
예제 #22
0
        // Performs blend of position and rotation of all clips connected to a track mixer
        // The result is applied to the track binding's (playerData) transform.
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            Transform trackBinding = playerData as Transform;

            if (trackBinding == null)
            {
                return;
            }

            // Get the initial position and rotation of the track binding, only when ProcessFrame is first called
            InitializeIfNecessary(trackBinding);

            Vector3    accumPosition = Vector3.zero;
            Quaternion accumRotation = QuaternionUtils.zero;

            float totalPositionWeight = 0.0f;
            float totalRotationWeight = 0.0f;

            // Iterate on all mixer's inputs (ie each clip on the track)
            int inputCount = playable.GetInputCount();

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                if (inputWeight <= 0)
                {
                    continue;
                }

                Playable input = playable.GetInput(i);
                float    normalizedInputTime = (float)(input.GetTime() / input.GetDuration());

                // get the clip's behaviour and evaluate the progression along the curve
                TweenBehaviour tweenInput    = GetTweenBehaviour(input);
                float          tweenProgress = GetCurve(tweenInput).Evaluate(normalizedInputTime);

                // calculate the position's progression along the curve according to the input's (clip) weight
                if (tweenInput.shouldTweenPosition)
                {
                    totalPositionWeight += inputWeight;
                    accumPosition       += TweenPosition(tweenInput, tweenProgress, inputWeight);
                }

                // calculate the rotation's progression along the curve according to the input's (clip) weight
                if (tweenInput.shouldTweenRotation)
                {
                    totalRotationWeight += inputWeight;
                    accumRotation        = TweenRotation(tweenInput, accumRotation, tweenProgress, inputWeight);
                }
            }

            // Apply the final position and rotation values in the track binding
            trackBinding.position = accumPosition + m_InitialPosition * (1.0f - totalPositionWeight);
            trackBinding.rotation = accumRotation.Blend(m_InitialRotation, 1.0f - totalRotationWeight);
            trackBinding.rotation.Normalize();
        }
        public float GetStatePlayableDuration(int index)
        {
            Playable playable = m_States[index].playable;

            if (!playable.IsValid())
            {
                return(0f);
            }
            return((float)playable.GetDuration());
        }
예제 #24
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            var target = playerData as Transform;

            if (target == null)
            {
                return;
            }

            var time           = (float)playable.GetTime();
            var normalizedTime = time / (float)playable.GetDuration();

            // Calculate amplitude. Break if it's nearly zero.
            var amp = info.weight * amplitude * envelope.Evaluate(normalizedTime);

            if (Mathf.Approximately(amp, 0))
            {
                return;
            }

            // Noise variables.
            var hash = new XXHash(randomSeed);
            var nt   = time * noiseFrequency;
            var norm = 1 / 0.75f;

            // Calculate position offset.
            var p = position;

            if (noiseOctaves > 0)
            {
                var n = new Vector3(
                    Perlin.Fbm(hash.Range(-1e3f, 1e3f, 0) + nt, noiseOctaves),
                    Perlin.Fbm(hash.Range(-1e3f, 1e3f, 1) + nt, noiseOctaves),
                    Perlin.Fbm(hash.Range(-1e3f, 1e3f, 2) + nt, noiseOctaves)
                    );
                p = Vector3.Scale(p, n) * norm;
            }

            target.localPosition += p * amp;

            // Calculate rotation offset.
            var r = rotation;

            if (noiseOctaves > 0)
            {
                var n = new Vector3(
                    Perlin.Fbm(hash.Range(-1e3f, 1e3f, 3) + nt, noiseOctaves),
                    Perlin.Fbm(hash.Range(-1e3f, 1e3f, 4) + nt, noiseOctaves),
                    Perlin.Fbm(hash.Range(-1e3f, 1e3f, 5) + nt, noiseOctaves)
                    );
                r = Vector3.Scale(r, n) * norm;
            }

            target.localRotation *= Quaternion.Euler(r * amp);
        }
예제 #25
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            base.ProcessFrame(playable, info, playerData);

            Color tmpColor = color;

            if (FadeType == EFadeInOut.FadeIn)
            {
                tmpColor.a = 1.0f - (float)(playable.GetTime() / playable.GetDuration());
            }
            else
            {
                tmpColor.a = (float)(playable.GetTime() / playable.GetDuration());
            }
            tmpColor.a *= color.a;
            if (VRFade.Instance != null)
            {
                VRFade.Instance.SetColor(tmpColor);
            }
        }
예제 #26
0
            public override void ProcessFrame(Playable playable, FrameData info, object playerData)
            {
                if (_subject == null || playable.GetTime() <= 0)
                {
                    return;
                }

                float f = (float)(playable.GetTime() / playable.GetDuration()) * info.weight;

                _subject.color = Color.Lerp(src, dst, curve.Evaluate(f));
            }
예제 #27
0
    public override void OnBehaviourPause(Playable playable, FrameData info)
    {
        if (waitTimeline.trigger == true)
        {
            waitTimeline.trigger = false;
            return;
        }

        Debug.Log(waitTimeline.trigger);
        director.time -= playable.GetDuration();
    }
예제 #28
0
    public override void OnGraphStart(Playable playable)
    {
        //m_VideoPlayer = m_Theater.GetComponentInChildren<VideoPlayer>();
        //m_VideoPlayer.Prepare();

        duration        = (float)playable.GetDuration();
        inverseDuration = 1f / duration;

        //m_VideoPlayer = m_Theater.GetComponentInChildren<VideoPlayer>();
        //m_VideoPlayer.Prepare();
    }
예제 #29
0
 private void checkForFadeOutImmediate(Playable playable)
 {
     if (eventTracker != null && !eventTracker.fadeoutTriggered)
     {
         if (fadeOutRequired(playable))
         {
             float timeLeft = (float)(playable.GetDuration() - playable.GetTime());
             triggerFadeOut(timeLeft);
         }
     }
 }
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            base.ProcessFrame(playable, info, playerData);
            float   duration  = (float)playable.GetDuration();
            float   timeNow   = (float)playable.GetTime();
            float   deltaTime = (float)info.deltaTime;
            Vector3 potition  = (Vector3)Path?.Update(m_Target.transform, duration, timeNow, deltaTime);

            //设置特效位置
            //Effect?.transform.position = potition;
        }