Starting new VN Structure
This commit is contained in:
11
archive/visualnovel/events/characters/CMakeLists.txt
Normal file
11
archive/visualnovel/events/characters/CMakeLists.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
# Copyright (c) 2022 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
VisualNovelFadeCharacterEvent.cpp
|
||||
VisualNovelTransformItemEvent.cpp
|
||||
)
|
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "VisualNovelFadeCharacterEvent.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
VisualNovelFadeCharacterEvent::VisualNovelFadeCharacterEvent(
|
||||
VisualNovelManager *man,
|
||||
VisualNovelCharacter *character,
|
||||
bool_t fadeIn,
|
||||
easefunction_t *ease,
|
||||
float_t duration
|
||||
) : VisualNovelSimpleAnimationEvent<float_t>(
|
||||
man,
|
||||
&character->material->color.a
|
||||
) {
|
||||
this->simpleAnimation.easing = ease;
|
||||
if(fadeIn) {
|
||||
this->simpleAnimation.addKeyframe(0.0f, 0.0f);
|
||||
this->simpleAnimation.addKeyframe(duration, 1.0f);
|
||||
} else {
|
||||
this->simpleAnimation.addKeyframe(0.0f, 1.0f);
|
||||
this->simpleAnimation.addKeyframe(duration, 0.0f);
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/events/animation/VisualNovelSimpleAnimationEvent.hpp"
|
||||
#include "visualnovel/components/VisualNovelCharacter.hpp"
|
||||
#include "scene/components/display/Material.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VisualNovelFadeCharacterEvent :
|
||||
public VisualNovelSimpleAnimationEvent<float_t>
|
||||
{
|
||||
public:
|
||||
VisualNovelFadeCharacterEvent(
|
||||
VisualNovelManager *man,
|
||||
VisualNovelCharacter *character,
|
||||
bool_t fadeIn,
|
||||
easefunction_t *ease,
|
||||
float_t duration
|
||||
);
|
||||
};
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
// 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);
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#pragma once
|
||||
#include "visualnovel/events/animation/VisualNovelSimpleCallbackAnimationEvent.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
class VisualNovelTransformItemEvent :
|
||||
public VisualNovelSimpleCallbackAnimationEvent<glm::vec3, Transform>
|
||||
{
|
||||
protected:
|
||||
bool_t relative = false;
|
||||
SceneItem *item = nullptr;
|
||||
void onStart(IVisualNovelEvent *previous) override;
|
||||
|
||||
public:
|
||||
VisualNovelTransformItemEvent(
|
||||
VisualNovelManager *man,
|
||||
SceneItem *item,
|
||||
glm::vec3 start,
|
||||
glm::vec3 end,
|
||||
easefunction_t *ease,
|
||||
float_t duration
|
||||
);
|
||||
|
||||
VisualNovelTransformItemEvent(
|
||||
VisualNovelManager *man,
|
||||
SceneItem *item,
|
||||
glm::vec3 end,
|
||||
easefunction_t *ease,
|
||||
float_t duration
|
||||
);
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user