Added animation
This commit is contained in:
@@ -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
|
||||
)
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user