VN System improved.

This commit is contained in:
2022-11-19 13:42:04 -08:00
parent 1e8dfa7388
commit 4eeecced2f
28 changed files with 577 additions and 154 deletions

View File

@ -51,12 +51,18 @@ namespace Dawn {
*/
template<class T>
T * findComponent() {
auto it = this->items.begin();
while(it != this->items.end()) {
auto it = this->itemsNotInitialized.begin();
while(it != this->itemsNotInitialized.end()) {
auto component = it->second->getComponent<T>();
if(component != nullptr) return component;
++it;
}
auto it2 = this->items.begin();
while(it2 != this->items.end()) {
auto component = it2->second->getComponent<T>();
if(component != nullptr) return component;
++it2;
}
return nullptr;
}
@ -70,12 +76,20 @@ namespace Dawn {
template<class T>
std::vector<T*> findComponents() {
std::vector<T*> components;
auto it = this->items.begin();
while(it != this->items.end()) {
auto it = this->itemsNotInitialized.begin();
while(it != this->itemsNotInitialized.end()) {
auto component = it->second->getComponent<T>();
if(component != nullptr) components.push_back(component);
++it;
}
auto it2 = this->items.begin();
while(it2 != this->items.end()) {
auto component = it2->second->getComponent<T>();
if(component != nullptr) components.push_back(component);
++it2;
}
return components;
}

View File

@ -1,9 +1,11 @@
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/display/Camera.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/Material.hpp"
// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/display/Camera.hpp"
#include "scene/components/display/MeshRenderer.hpp"
#include "scene/components/display/Material.hpp"
#include "scene/components/ui/UICanvas.hpp"

View File

@ -6,6 +6,7 @@
#pragma once
#include "scene/SceneItemComponent.hpp"
#include "display/RenderTarget.hpp"
#include "scene/Scene.hpp"
namespace Dawn {
enum CameraType {
@ -20,6 +21,12 @@ namespace Dawn {
void onRenderTargetResize(RenderTarget *target, float_t w, float_t h);
public:
static Camera * create(Scene *scene) {
auto item = scene->createSceneItem();
auto cam = item->addComponent<Camera>();
return cam;
}
glm::mat4 projection;
// Perspective

View File

@ -57,6 +57,17 @@ namespace Dawn {
this->children.push_back(item);
return item;
}
template<class T>
T * findElement() {
auto it = this->children.begin();
while(it != this->children.end()) {
auto castedAs = dynamic_cast<T*>(*it);
if(castedAs != nullptr) return castedAs;
++it;
}
return nullptr;
}
/**
* Returns the width of the root UI Canvas size. In future I may allow