add ADecompose.h animation
parent
ae4784e057
commit
07ddceaa37
|
@ -86,6 +86,7 @@ add_executable(${CMAKE_PROJECT_NAME}
|
|||
engine/animation/AShowCreation.h
|
||||
engine/animation/AShowUncreation.h
|
||||
engine/animation/ARotateLeftUpLookAt.h
|
||||
engine/animation/ADecompose.h
|
||||
engine/physics/RigidBody.cpp
|
||||
engine/physics/RigidBody.h
|
||||
engine/physics/Simplex.h
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
//
|
||||
// Created by Иван Ильин on 23.02.2022.
|
||||
//
|
||||
|
||||
#ifndef INC_3DZAVR_ADECOMPOSE_H
|
||||
#define INC_3DZAVR_ADECOMPOSE_H
|
||||
|
||||
#include "Animation.h"
|
||||
#include "../Mesh.h"
|
||||
#include "../Consts.h"
|
||||
|
||||
class ADecompose final : public Animation {
|
||||
private:
|
||||
const std::weak_ptr<Mesh> _mesh;
|
||||
std::vector<Triangle> _triangles;
|
||||
|
||||
double _value;
|
||||
bool _started = false;
|
||||
|
||||
void update() override {
|
||||
auto mesh = _mesh.lock();
|
||||
|
||||
if (mesh == nullptr) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_started) {
|
||||
_started = true;
|
||||
_triangles = _mesh.lock()->triangles();
|
||||
}
|
||||
|
||||
std::vector<Triangle> newTriangles;
|
||||
newTriangles.reserve(_triangles.size());
|
||||
|
||||
for(auto &t : _triangles) {
|
||||
newTriangles.emplace_back((t * Matrix4x4::Translation(t.position().normalized()*progress()*_value)));
|
||||
}
|
||||
mesh->setTriangles(std::move(newTriangles));
|
||||
mesh->glFreeFloatArray();
|
||||
}
|
||||
|
||||
public:
|
||||
ADecompose(std::weak_ptr<Mesh> mesh, double value, double duration = 1, LoopOut looped = LoopOut::None,
|
||||
InterpolationType interpolationType = InterpolationType::Bezier) : Animation(duration, looped,
|
||||
interpolationType),
|
||||
_value(value), _mesh(mesh) {}
|
||||
};
|
||||
|
||||
#endif //INC_3DZAVR_ADECOMPOSE_H
|
|
@ -20,6 +20,7 @@
|
|||
#include "AShowCreation.h"
|
||||
#include "AShowUncreation.h"
|
||||
#include "ARotateLeftUpLookAt.h"
|
||||
#include "ADecompose.h"
|
||||
|
||||
|
||||
#endif //SHOOTER_ANIMATIONS_H
|
||||
|
|
Loading…
Reference in New Issue