shooter/engine/animation/AScale.h

41 lines
1.0 KiB
C
Raw Normal View History

2021-09-13 15:53:43 +03:00
//
// Created by Иван Ильин on 29.01.2021.
//
#ifndef ENGINE_ASCALE_H
#define ENGINE_ASCALE_H
#include "Animatable.h"
#include "Animation.h"
2021-10-02 20:36:07 +03:00
#include "Mesh.h"
2021-09-13 15:53:43 +03:00
class AScale : public Animation {
private:
2021-10-02 20:36:07 +03:00
std::shared_ptr<Mesh> _mesh;
2021-09-13 15:53:43 +03:00
Vec3D value;
2021-10-02 20:36:07 +03:00
std::vector<Triangle> triangles{};
2021-09-13 15:53:43 +03:00
public:
AScale(std::shared_ptr<Mesh> mesh, const Vec3D &s, double duration = 1, LoopOut looped = LoopOut::None, InterpolationType interpolationType = InterpolationType::bezier) : value(s) {
2021-10-02 20:36:07 +03:00
_mesh = mesh;
2021-09-13 15:53:43 +03:00
_duration = duration;
_looped = looped;
_intType = interpolationType;
_waitFor = true;
}
2021-10-02 20:36:07 +03:00
bool update() override {
2021-09-13 15:53:43 +03:00
if(!_started)
2021-10-02 20:36:07 +03:00
triangles = _mesh->triangles();
2021-09-13 15:53:43 +03:00
std::vector<Triangle> newTriangles;
for(auto &t : triangles) {
newTriangles.emplace_back(t * Matrix4x4::Scale(Point4D{1, 1, 1} + (value - Point4D{1, 1, 1}) * _p));
}
2021-10-02 20:36:07 +03:00
_mesh->setTriangles(newTriangles);
2021-09-13 15:53:43 +03:00
return updateState();
}
};
#endif //INC_3DZAVR_ASCALE_H