Starting new VN Structure
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "SimpleVisualNovelBackground.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
SimpleVisualNovelBackground * SimpleVisualNovelBackground::create(Scene *s) {
|
||||
auto item = s->createSceneItem();
|
||||
// item->addComponent<MeshRenderer>();
|
||||
item->addComponent<MeshHost>();
|
||||
item->addComponent<SimpleTexturedMaterial>();
|
||||
auto background = item->addComponent<SimpleVisualNovelBackground>();
|
||||
return background;
|
||||
}
|
||||
|
||||
SimpleVisualNovelBackground::SimpleVisualNovelBackground(SceneItem *item) :
|
||||
SceneItemComponent(item)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::vector<SceneItemComponent*> SimpleVisualNovelBackground::getDependencies(){
|
||||
return std::vector<SceneItemComponent*>{
|
||||
this->material = this->item->getComponent<SimpleTexturedMaterial>(),
|
||||
this->meshHost = this->item->getComponent<MeshHost>()
|
||||
};
|
||||
}
|
||||
|
||||
void SimpleVisualNovelBackground::setTexture(Texture *texture) {
|
||||
assertNotNull(texture);
|
||||
this->material->texture = texture;
|
||||
|
||||
// Since we go both negative and positive, actual height is doubled
|
||||
float_t aspect = (float_t)texture->getWidth() / (float_t)texture->getHeight();
|
||||
float_t height = 0.5f;
|
||||
|
||||
QuadMesh::bufferQuadMeshWithZ(&this->meshHost->mesh,
|
||||
glm::vec2(-aspect * height, -height), glm::vec2(0, 1),
|
||||
glm::vec2( aspect * height, height), glm::vec2(1, 0),
|
||||
0.0f, 0, 0
|
||||
);
|
||||
}
|
||||
|
||||
void SimpleVisualNovelBackground::onStart() {
|
||||
assertNotNull(this->material);
|
||||
assertNotNull(this->meshHost);
|
||||
|
||||
QuadMesh::initQuadMesh(&this->meshHost->mesh,
|
||||
glm::vec2(-1, -1), glm::vec2(0, 1),
|
||||
glm::vec2(1, 1), glm::vec2(1, 0),
|
||||
0.0f
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user