void update() { const double progressRate = Saturate(1.0*m_state.m_timer / (1.0*m_state.m_stateLimit)); const Vec2 focusPos = Vec2(3904, 4082); switch (m_state.m_state) { case 0: D2Camera::I()->m_pos = EaseInOut(m_startPos, focusPos, Easing::Cubic, progressRate); m_state.checkTimerAndGoNextState(150); break; case 1: D2Camera::I()->m_pos = focusPos; m_state.checkTimerAndGoNextState(60); break; case 2: D2Camera::I()->m_pos = EaseInOut(focusPos, m_startPos, Easing::Cubic, progressRate); m_state.checkTimerAndGoNextState(60); break; case 3: break; } m_state.update(); }
double update() { m_progress += 3.0; //speed const double progressRate = m_progress / (m_end - m_start).length(); const Vec2 newPos = EaseInOut(m_start, m_end, Easing::Linear,progressRate); D2Camera::I()->m_pos = newPos; return progressRate >= 1.0; }
void ToricInterpolator::interpolateVector( const double & t, Vector3 & pOutVecA, Vector3 & pOutVecB ) { { pOutVecA = Quaternion(Vector3::WorldUp(), m_infoA.viewAngleChange * t) * m_infoA.startVector; pOutVecA = Quaternion(pOutVecA ^ Vector3::WorldUp(), m_infoA.viewHeightChange * t) * pOutVecA; } { pOutVecB = Quaternion(Vector3::WorldUp(), m_infoB.viewAngleChange * t) * m_infoB.startVector; pOutVecB = Quaternion(pOutVecB ^ Vector3::WorldUp(), m_infoB.viewHeightChange * t) * pOutVecB; } Vector3 vecAB = m_wposB-m_wposA; double AB = vecAB.norm(); double alpha = m_alpha[0] * (1-t) + m_alpha[1] * t; double PiMinusAlpha = PI-alpha; double transform = PI / PiMinusAlpha; double dA; { double dA1 = m_infoA.distance[0] * (1-t) + m_infoA.distance[1] * t; double beta = pOutVecA.angle(vecAB)(); beta = clamp(beta, 0.0, PiMinusAlpha); double dA2 = Constraints::ComputeDistanceToA(AB, alpha, beta*2); double wA2 = EaseInOut( sin( beta * transform ) ); dA = (dA1 + dA2 * wA2) / (1 + wA2); } double dB; { double dB1 = m_infoB.distance[0] * (1-t) + m_infoB.distance[1] * t; double beta = pOutVecB.angle(-vecAB)(); beta = clamp(beta, 0.0, PiMinusAlpha); double dB2 = Constraints::ComputeDistanceToA(AB, alpha, beta*2); double wB2 = EaseInOut( sin( beta * transform ) ); dB = (dB1 + dB2 * wB2) / (1 + wB2); } pOutVecA *= dA; pOutVecB *= dB; }
double easeInOut(double easingFunction(double) = Easing::Quart) const { return EaseInOut(easingFunction, m_value); }
Type easeInOut() const { return EaseInOut(m_start, m_end, m_easingFunction, elapsed()); }
[[nodiscard]] inline constexpr Type EaseInOut(double f(double), const Type& start, const Type& end, const double t) { return Math::Lerp(start, end, EaseInOut(f, t)); }
[[nodiscard]] constexpr double easeInOut(double easingFunction(double) = Easing::Quart) const { return EaseInOut(easingFunction, m_value); }