YoggieEngine/BarinkEngine/Scene.cpp
nigel 8cc6ed1f15 Multiple changes to prepare for the basic render engine.
* Rendering 2 cubes
* per cube transform panels
* Updated TODO.md
* Updated README.md
2022-05-28 21:19:16 +02:00

53 lines
836 B
C++

#include "Scene.h"
SceneNode* SearchInChildren(SceneNode* root, std::string name ) {
if (root->name == name)
return root;
SceneNode* found = nullptr;
for (auto child : root->children) {
found = SearchInChildren(child, name);
}
return found;
}
SceneNode& Scene::GetSceneNode(std::string name)
{
return *SearchInChildren(root, name);
}
SceneNode& Scene::GetRoot()
{
return *root;
}
Scene::Scene(std::string sceneName)
{
// Create a root node
root = new SceneNode();
root->name = sceneName;
root->transform = Transform();
root->transform.Position = glm::vec3(0);
root->transform.Rotation = glm::vec3(0);
root->transform.Scale = glm::vec3(0);
root->transform.ModelMatrix = glm::mat4(0);
}
Scene::~Scene()
{
// Destruct scene!
}
void SceneNode::addChild(SceneNode& node)
{
children.push_back(&node);
}