53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// Copyright (c) 2023 Dominic Masters
|
|
//
|
|
// This software is released under the MIT License.
|
|
// https://opensource.org/licenses/MIT
|
|
|
|
#include "VisualNovelTransformItemEvent.hpp"
|
|
|
|
using namespace Dawn;
|
|
|
|
VisualNovelTransformItemEvent::VisualNovelTransformItemEvent(
|
|
VisualNovelManager *man,
|
|
SceneItem *item,
|
|
glm::vec3 start,
|
|
glm::vec3 end,
|
|
easefunction_t *ease,
|
|
float_t duration
|
|
) : VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>(man) {
|
|
assertNotNull(item);
|
|
this->item = item;
|
|
|
|
this->callbackAnimation.setCallback(
|
|
&item->transform, &Transform::setLocalPosition
|
|
);
|
|
if(duration != 0) {
|
|
this->callbackAnimation.addKeyframe(0.0f, start);
|
|
}
|
|
this->callbackAnimation.addKeyframe(duration, end);
|
|
}
|
|
|
|
VisualNovelTransformItemEvent::VisualNovelTransformItemEvent(
|
|
VisualNovelManager *man,
|
|
SceneItem *item,
|
|
glm::vec3 end,
|
|
easefunction_t *ease,
|
|
float_t duration
|
|
) : VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>(man) {
|
|
assertNotNull(item);
|
|
this->item = item;
|
|
|
|
this->callbackAnimation.setCallback(
|
|
&item->transform, &Transform::setLocalPosition
|
|
);
|
|
|
|
if(duration != 0) this->relative = true;
|
|
this->callbackAnimation.addKeyframe(duration, end);
|
|
}
|
|
|
|
void VisualNovelTransformItemEvent::onStart(IVisualNovelEvent *previous) {
|
|
if(this->relative) {
|
|
this->callbackAnimation.addKeyframe(0.0f, this->item->transform.getLocalPosition());
|
|
}
|
|
VisualNovelSimpleCallbackAnimationEvent::onStart(previous);
|
|
} |