]> git.lizzy.rs Git - dragonblocks3d.git/blob - src/animations.cpp
New structure
[dragonblocks3d.git] / src / animations.cpp
1 #include <glm/gtc/constants.hpp>
2 #include "animations.hpp"
3
4 using namespace glm;
5 using namespace dragonblocks;
6
7 vec3 FlyInAnimation::getPos(vec3 pos)
8 {
9         pos.y -= offset * time_left / last_for;
10         return pos;
11 }
12
13 FlyInAnimation::FlyInAnimation(double l, double o, void (*on)(void *), void *e) : Mesh::IAnimation(l, on, e), last_for(l), offset(o)
14 {
15 }
16
17 vec3 GrowAnimation::getSize(vec3 size)
18 {
19         size *= 1 - time_left / last_for;
20         return size;
21 }
22
23 GrowAnimation::GrowAnimation(double l, void (*o)(void *), void *e) : Mesh::IAnimation(l, o, e), last_for(l)
24 {
25 }
26
27 float RotateAnimation::getRotationAngle(float rotation_angle)
28 {
29         rotation_angle += glfwGetTime() * speed * pi<float>() * 2;
30         return rotation_angle;
31 }
32
33 RotateAnimation::RotateAnimation(double s) : speed(s)
34 {
35 }