shooter/engine/animation/ARotateRelativePoint.h

37 lines
1.1 KiB
C
Raw Normal View History

2021-10-31 22:11:04 +03:00
//
// Created by Иван Ильин on 01.11.2021.
//
#ifndef SHOOTER_AROTATERELATIVEPOINT_H
#define SHOOTER_AROTATERELATIVEPOINT_H
#include "Animation.h"
#include "../Object.h"
class ARotateRelativePoint : public Animation {
private:
const std::weak_ptr<Object> _object;
const Vec3D _targetPoint;
const Vec3D _rotationValue;
void update() override {
2021-11-09 22:54:20 +03:00
auto obj = _object.lock();
2021-10-31 22:11:04 +03:00
2021-11-09 22:54:20 +03:00
if (obj == nullptr) {
2021-10-31 22:11:04 +03:00
stop();
return;
}
2021-11-09 22:54:20 +03:00
obj->rotateRelativePoint(_targetPoint, _rotationValue * dprogress());
2021-10-31 22:11:04 +03:00
}
public:
ARotateRelativePoint(std::weak_ptr<Object> object, const Vec3D &targetPoint, const Vec3D &rotationValue,
double duration = 1, Animation::LoopOut looped = LoopOut::None,
Animation::InterpolationType interpolationType = InterpolationType::Bezier)
: Animation(duration, looped, interpolationType), _object(object), _targetPoint(targetPoint),
_rotationValue(rotationValue) {}
};
#endif //SHOOTER_AROTATERELATIVEPOINT_H