First render.

This commit is contained in:
2023-11-17 00:02:04 -06:00
parent 55f629c7b5
commit 490da9d0c1
43 changed files with 1039 additions and 67 deletions

View File

@@ -44,6 +44,21 @@ namespace Dawn {
*/
std::shared_ptr<SceneItem> createSceneItem();
/**
* Returns a list of scene components that match the given type.
*
* @return List of scene components matching the type.
*/
template<class T>
std::vector<std::shared_ptr<T>> findComponents() {
std::vector<std::shared_ptr<T>> components;
for(auto item : sceneItems) {
auto component = item->getComponent<T>();
if(component) components.push_back(component);
}
return components;
}
/**
* Destroys the scene object and cleans up all of its children.
*/

View File

@@ -5,8 +5,8 @@
#include "assert/assert.hpp"
#include "util/Flag.hpp"
#include "scene/Scene.hpp"
#include "game/Game.hpp"
#include "scene/Scene.hpp"
using namespace Dawn;

View File

@@ -49,6 +49,20 @@ namespace Dawn {
return component;
}
/**
* Returns a list of components that match the given type.
*
* @return List of components matching the type.
*/
template<class T>
std::shared_ptr<T> getComponent() {
for(auto component : this->components) {
auto cast = std::dynamic_pointer_cast<T>(component);
if(cast) return cast;
}
return nullptr;
}
virtual ~SceneItemComponents();
};
}

View File

@@ -84,6 +84,10 @@ glm::mat4 SceneItemTransform::getLocalTransform() {
return this->transformLocal;
}
glm::mat4 SceneItemTransform::getWorldTransform() {
return this->transformWorld;
}
void SceneItemTransform::setWorldTransform(const glm::mat4 transform) {
this->transformWorld = transform;
this->updateLocalTransformFromWorldTransform();

View File

@@ -68,6 +68,13 @@ namespace Dawn {
* @return Local transform of this item.
*/
glm::mat4 getLocalTransform();
/**
* Returns the world transform of this item (relative to scene root).
*
* @return World transform of this item.
*/
glm::mat4 getWorldTransform();
/**
* Sets the transform of this item within world space (relative to scene