2021-09-13 15:53:43 +03:00
|
|
|
//
|
|
|
|
// Created by Иван Ильин on 02.06.2021.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ENGINE_ACOLOR_H
|
|
|
|
#define ENGINE_ACOLOR_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 AColor : public Animation {
|
|
|
|
private:
|
2021-10-02 20:36:07 +03:00
|
|
|
std::shared_ptr<Mesh> _mesh;
|
|
|
|
|
2021-09-13 15:53:43 +03:00
|
|
|
sf::Color newColor;
|
|
|
|
sf::Color startColor;
|
|
|
|
|
|
|
|
public:
|
2021-10-02 20:36:07 +03:00
|
|
|
AColor(std::shared_ptr<Mesh> mesh, const sf::Color &color, double duration = 1, LoopOut looped = LoopOut::None, InterpolationType interpolationType = InterpolationType::linear) {
|
|
|
|
_mesh = mesh;
|
2021-09-13 15:53:43 +03:00
|
|
|
_duration = duration;
|
|
|
|
_looped = looped;
|
|
|
|
_intType = interpolationType;
|
|
|
|
_waitFor = true;
|
|
|
|
|
|
|
|
newColor = color;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
startColor = _mesh->color();
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
Point4D start(startColor.r, startColor.g, startColor.b, startColor.a);
|
|
|
|
Point4D end(newColor.r, newColor.g, newColor.b, newColor.a);
|
|
|
|
Point4D mid = start + (end - start)*_p;
|
|
|
|
|
2021-10-02 20:36:07 +03:00
|
|
|
_mesh->setColor(sf::Color(static_cast<sf::Uint8>(mid.x()), static_cast<sf::Uint8>(mid.y()), static_cast<sf::Uint8>(mid.z()), static_cast<sf::Uint8>(mid.w())));
|
2021-09-13 15:53:43 +03:00
|
|
|
|
|
|
|
return updateState();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //SHOOTER_3DZAVR_ACOLOR_H
|