ES-DE/es-app/src/animations/MoveCameraAnimation.h
2020-09-15 22:57:54 +02:00

41 lines
968 B
C++

// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// MoveCameraAnimation.h
//
// Animation to play when moving the camera, used by the slide transition style.
//
#ifndef ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H
#define ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H
#include "animations/Animation.h"
class MoveCameraAnimation : public Animation
{
public:
MoveCameraAnimation(
Transform4x4f& camera,
const Vector3f& target)
: mCameraStart(camera),
mTarget(target),
cameraOut(camera) {}
int getDuration() const override { return 400; }
void apply(float t) override
{
// Cubic ease out.
t -= 1;
cameraOut.translation() = -Vector3f().lerp(-mCameraStart.translation(), mTarget, t*t*t + 1);
}
private:
Transform4x4f mCameraStart;
Vector3f mTarget;
Transform4x4f& cameraOut;
};
#endif // ES_APP_ANIMATIONS_MOVE_CAMERA_ANIMATION_H