#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);
}
