vectozavr-shooter/engine/animation/ATranslateToPoint.h

36 lines
919 B
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 29.01.2021.
//
#ifndef ENGINE_ATRANSLATETOPOINT_H
#define ENGINE_ATRANSLATETOPOINT_H
#include "Animation.h"
2021-10-09 13:41:12 +03:00
#include "../Object.h"
2021-09-13 15:53:43 +03:00
class ATranslateToPoint final : public Animation {
2021-09-13 15:53:43 +03:00
private:
2021-10-02 20:36:07 +03:00
std::shared_ptr<Object> _object;
Vec3D point;
std::unique_ptr<Vec3D> value;
2021-09-13 15:53:43 +03:00
public:
ATranslateToPoint(std::shared_ptr<Object> object, const Vec3D& p, double duration = 1, LoopOut looped = LoopOut::None, InterpolationType interpolationType = InterpolationType::bezier) : point(p) {
2021-10-02 20:36:07 +03:00
_object = object;
2021-09-13 15:53:43 +03:00
_duration = duration;
_looped = looped;
_intType = interpolationType;
}
2021-10-02 20:36:07 +03:00
bool update() override {
2021-09-13 15:53:43 +03:00
if(!_started) {
value = std::make_unique<Vec3D>(point - _object->position());
2021-09-13 15:53:43 +03:00
}
_object->translate(*value * _dp);
2021-09-13 15:53:43 +03:00
return updateState();
}
};
#endif //INC_3DZAVR_ATRANSLATETOPOINT_H