public virtual void SetState(AnimatedCameraState state) { this.transform.position = state._position; this.transform.rotation = state._rotation; GetCamera().fieldOfView = state._fieldOfView; GetCamera().rect = state._cameraRect; }
public void SetState(AnimatedCameraState state) { if (state != null) { this.transform.position = state._position; this.transform.rotation = state._rotation; } _state = state; }
public virtual AnimatedCameraState GetState() { AnimatedCameraState state = new AnimatedCameraState(); state._position = this.transform.position; state._rotation = this.transform.rotation; state._cameraRect = GetCamera().rect; state._fieldOfView = GetCamera().fieldOfView; return(state); }
public AnimatedCameraState GetState() { if (_state == null) { _state = new AnimatedCameraState(); } _state._position = this.transform.position; _state._rotation = this.transform.rotation; return(_state); }
public virtual AnimatedCameraState InterpolateTo(AnimatedCamera camera, AnimatedCameraState to, eInterpolation ease, float t) { AnimatedCameraState state = new AnimatedCameraState(); state._position = MathUtils.Interpolate(ease, _position, to._position, t); state._rotation = MathUtils.Interpolate(ease, _rotation, to._rotation, t); state._fieldOfView = MathUtils.Interpolate(ease, _fieldOfView, to._fieldOfView, t); state._cameraRect = MathUtils.Interpolate(ease, _cameraRect, to._cameraRect, t); return(state); }
public void SetState(AnimatedCameraState snapshotState, float weight) { if (weight > 0.0f) { if (weight < 1.0f) { snapshotState = GetState().InterpolateTo(this, snapshotState, _currentEaseType, weight); } SetState(snapshotState); } }
public override void ProcessFrame(Playable playable, FrameData info, object playerData) { _trackBinding = playerData as AnimatedCamera; if (_trackBinding == null) { return; } if (!_firstFrameHappened) { _defaultState = _trackBinding.GetState(); _firstFrameHappened = true; } AnimatedCameraState blendedState = _defaultState; int inputPort = 0; foreach (TimelineClip clip in _clips) { ScriptPlayable <AnimatedCameraPlayableBehaviour> scriptPlayable = (ScriptPlayable <AnimatedCameraPlayableBehaviour>)playable.GetInput(inputPort); AnimatedCameraPlayableBehaviour inputBehaviour = scriptPlayable.GetBehaviour(); if (inputBehaviour != null) { double clipStart = clip.hasPreExtrapolation ? clip.extrapolatedStart : clip.start; double clipDuration = clip.hasPreExtrapolation || clip.hasPostExtrapolation ? clip.extrapolatedDuration : clip.duration; //If currently playing if (_director.time >= clipStart && _director.time <= clipStart + clipDuration) { float inputWeight = playable.GetInputWeight(inputPort); AnimatedCameraState behaviourState = inputBehaviour._snapshot.GetState(); //Interpolated behavior if (inputBehaviour._snapshotTo != null) { double clipT = Math.Min(Math.Max(_director.time - clip.start, 0.0) / clip.duration, 1.0); behaviourState = behaviourState.InterpolateTo(_trackBinding, inputBehaviour._snapshotTo.GetState(), inputBehaviour._easeType, (float)clipT); } //Fade playable over current state using its weight blendedState = blendedState.InterpolateTo(_trackBinding, behaviourState, eInterpolation.Linear, inputWeight); } } ++inputPort; } _trackBinding.SetState(blendedState); }
private void UpdateAnimation(Animation animation, float deltaTime) { if (animation._states.Length == 1) { SetState(animation._states[0], animation._weight); } else if (animation._states.Length > 1) { animation._animationT += deltaTime / animation._duration; if (animation._wrapMode == WrapMode.ClampForever) { animation._animationT = Mathf.Clamp01(animation._animationT); } else if (animation._wrapMode == WrapMode.Once) { if (animation._animationT > 1.0f) { animation._states = null; } } float baseValue = Mathf.Floor(animation._animationT); float fraction = animation._animationT - baseValue; if (animation._wrapMode == WrapMode.PingPong && ((int)baseValue % 2) == 1) { fraction = 1.0f - fraction; } float sectonTDist = 1.0f / (animation._states.Length - 1); float sectionT = fraction / sectonTDist; int sectionIndex = Mathf.FloorToInt(sectionT); sectionT = sectionT - (float)sectionIndex; AnimatedCameraState state = animation._states[sectionIndex].InterpolateTo(this, animation._states[sectionIndex + 1], animation._easeType, sectionT); SetState(state, animation._weight); } }
private void CacheCameraState() { AnimatedCamera camera = (AnimatedCamera)target; _cameraOrigState = camera.GetState(); }