mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Removed deprecated LaunchAnimation.h
This commit is contained in:
parent
ae7c9dabb8
commit
aa07a1094f
|
@ -48,7 +48,6 @@ set(ES_HEADERS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/UIModeController.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/UIModeController.h
|
||||||
|
|
||||||
# Animations
|
# Animations
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/LaunchAnimation.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/MoveCameraAnimation.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/MoveCameraAnimation.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,91 +0,0 @@
|
||||||
//
|
|
||||||
// LaunchAnimation.h
|
|
||||||
//
|
|
||||||
// Animation to play when launching a game.
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#ifndef ES_APP_ANIMATIONS_LAUNCH_ANIMATION_H
|
|
||||||
#define ES_APP_ANIMATIONS_LAUNCH_ANIMATION_H
|
|
||||||
|
|
||||||
#include "animations/Animation.h"
|
|
||||||
|
|
||||||
// Let's look at the game launch effect:
|
|
||||||
// - Move camera to center on point P (interpolation method: linear).
|
|
||||||
// - Zoom camera to factor Z via matrix scale (interpolation method: exponential).
|
|
||||||
// - Fade screen to black at rate F (interpolation method: exponential).
|
|
||||||
|
|
||||||
// How the animation gets constructed from the example of implementing the game launch effect:
|
|
||||||
// 1. Current parameters are retrieved through a get() call.
|
|
||||||
// Ugliness:
|
|
||||||
// - Have to have a way to get a reference to the animation.
|
|
||||||
// - Requires additional implementation in some parent objects,
|
|
||||||
// potentially AnimationController.
|
|
||||||
// 2. ViewController is passed in LaunchAnimation constructor, applies state through setters.
|
|
||||||
// Ugliness:
|
|
||||||
// - Effect only works for ViewController.
|
|
||||||
// 3. Pass references to ViewController variables - LaunchAnimation(mCameraPos, mFadePerc, target).
|
|
||||||
// Ugliness:
|
|
||||||
// - What if ViewController is deleted? --> AnimationController class handles that.
|
|
||||||
// - No callbacks for changes...but that works well with this style of update, so
|
|
||||||
// I think it's okay
|
|
||||||
// 4. Use callbacks to set variables.
|
|
||||||
// Ugliness:
|
|
||||||
// - Boilerplate as hell every time.
|
|
||||||
|
|
||||||
// #3 wins.
|
|
||||||
// Wan't wait to see how this one bites me in the ass.
|
|
||||||
|
|
||||||
class LaunchAnimation : public Animation
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Target is a centerpoint.
|
|
||||||
LaunchAnimation(
|
|
||||||
Transform4x4f& camera,
|
|
||||||
float& fade,
|
|
||||||
const Vector3f&
|
|
||||||
target,
|
|
||||||
int duration)
|
|
||||||
: mCameraStart(camera),
|
|
||||||
mTarget(target),
|
|
||||||
mDuration(duration),
|
|
||||||
cameraOut(camera),
|
|
||||||
fadeOut(fade) {}
|
|
||||||
|
|
||||||
int getDuration() const override { return mDuration; }
|
|
||||||
|
|
||||||
void apply(float t) override
|
|
||||||
{
|
|
||||||
// TEMPORARY - disabled the launch animations as they don't work properly and more
|
|
||||||
// work is needed to fix them. This has been done in LaunchAnimation.h instead of in
|
|
||||||
// ViewController as not calling the animation leads to input not being properly
|
|
||||||
// consumed. This also needs to be fixed later on.
|
|
||||||
return;
|
|
||||||
|
|
||||||
cameraOut = Transform4x4f::Identity();
|
|
||||||
|
|
||||||
float zoom = Math::lerp(1.0, 4.25f, t*t);
|
|
||||||
cameraOut.scale(zoom);
|
|
||||||
|
|
||||||
const float sw = (float)Renderer::getScreenWidth() / zoom;
|
|
||||||
const float sh = (float)Renderer::getScreenHeight() / zoom;
|
|
||||||
|
|
||||||
const Vector2f startPoint = Vector2f(-mCameraStart.translation()) +
|
|
||||||
Vector2f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f);
|
|
||||||
const Vector2f centerPoint = Vector2f().lerp(startPoint, Vector2f(mTarget),
|
|
||||||
Math::smootherStep(0.0, 1.0, t));
|
|
||||||
|
|
||||||
cameraOut.translate(Vector3f((sw / 2) - centerPoint.x(), (sh / 2) - centerPoint.y(), 0));
|
|
||||||
fadeOut = Math::lerp(0.0, 1.0, t*t);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Transform4x4f mCameraStart;
|
|
||||||
Vector3f mTarget;
|
|
||||||
int mDuration;
|
|
||||||
|
|
||||||
Transform4x4f& cameraOut;
|
|
||||||
float& fadeOut;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ES_APP_ANIMATIONS_LAUNCH_ANIMATION_H
|
|
Loading…
Reference in a new issue