First render.
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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();
|
||||
};
|
||||
}
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user