// // Created by Иван Ильин on 29.01.2021. // #ifndef ENGINE_ATRANSLATETOPOINT_H #define ENGINE_ATRANSLATETOPOINT_H #include #include "Animation.h" #include "../Object.h" class ATranslateToPoint final : public Animation { private: const std::weak_ptr _object; const Vec3D _targetPoint; Vec3D _translationValue; bool _started = false; void update() override { if(_object.expired()) { stop(); return; } if(!_started) { _started = true; _translationValue = _targetPoint - _object.lock()->position(); } _object.lock()->translate(_translationValue * dprogress()); } public: ATranslateToPoint(std::weak_ptr object, const Vec3D& p, double duration = 1, LoopOut looped = LoopOut::None, InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped, interpolationType), _targetPoint(p), _object(object) { } }; #endif //INC_3DZAVR_ATRANSLATETOPOINT_H