Added animation

This commit is contained in:
2022-04-23 23:51:28 +03:00
parent 50d032418e
commit 674191238f
10 changed files with 112 additions and 7 deletions
+15
View File
@@ -0,0 +1,15 @@
set(HEADERS
${HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/float_track.h
${CMAKE_CURRENT_SOURCE_DIR}/integer_track.h
${CMAKE_CURRENT_SOURCE_DIR}/vec3_track.h
PARENT_SCOPE
)
set(SOURCE
${SOURCE}
${CMAKE_CURRENT_SOURCE_DIR}/float_track.h
${CMAKE_CURRENT_SOURCE_DIR}/integer_track.h
${CMAKE_CURRENT_SOURCE_DIR}/vec3_track.h
PARENT_SCOPE
)
+15
View File
@@ -0,0 +1,15 @@
#include "animation/float_track.h"
BEGIN_NAMESPACE
animated_value float_track::get_value(const animated_value &first, const animated_value &second, float alpha) {
animated_value result;
result.floatVal = glm::mix(first.floatVal, second.floatVal, alpha);
return result;
};
void float_track::control_object(void *controlled_object, const animated_value &value) {
*reinterpret_cast<float *>(controlled_object) = value.floatVal;
}
END_NAMESPACE
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "animation_track.h"
BEGIN_NAMESPACE
class float_track : public animation_track {
public:
animated_value get_value(const animated_value &first, const animated_value &second, float alpha) override;
void control_object(void *controlled_object, const animated_value &value) override;
};
END_NAMESPACE
+16
View File
@@ -0,0 +1,16 @@
#include "animation/integer_track.h"
BEGIN_NAMESPACE
animated_value integer_track::get_value(const animated_value &first, const animated_value &second, float alpha) {
// no interpolation here
animated_value result;
result.intVal = static_cast<int>(first.intVal + (second.intVal - first.intVal) * alpha);
return result;
};
void integer_track::control_object(void *controlled_object, const animated_value &value) {
*reinterpret_cast<int *>(controlled_object) = value.intVal;
}
END_NAMESPACE
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "animation_track.h"
BEGIN_NAMESPACE
class integer_track : public animation_track {
public:
animated_value get_value(const animated_value &first, const animated_value &second, float alpha) override;
void control_object(void *controlled_object, const animated_value &value) override;
};
END_NAMESPACE
+15
View File
@@ -0,0 +1,15 @@
#include "vec3_track.h"
BEGIN_NAMESPACE
animated_value vec3_track::get_value(const animated_value &first, const animated_value &second, float alpha) {
animated_value result;
result.vec3_val = glm::mix(first.vec3_val, second.vec3_val, alpha);
return result;
};
void vec3_track::control_object(void *controlled_object, const animated_value &value) {
*reinterpret_cast<glm::vec3 *>(controlled_object) = value.vec3_val;
}
END_NAMESPACE
+14
View File
@@ -0,0 +1,14 @@
#pragma once
#include "animation_track.h"
BEGIN_NAMESPACE
class vec3_track : public animation_track {
public:
animated_value get_value(const animated_value &first, const animated_value &second, float alpha) override;
void control_object(void *controlled_object, const animated_value &value) override;
};
END_NAMESPACE