50 lines
913 B
C++
50 lines
913 B
C++
#include "scene.h"
|
|
#include "resourcemanager.h"
|
|
|
|
Scene::Scene()
|
|
{
|
|
|
|
}
|
|
|
|
void Scene::update()
|
|
{
|
|
m_root->update();
|
|
}
|
|
|
|
// Container Node
|
|
|
|
void ContainerNode::update()
|
|
{
|
|
for(SceneNode* sn : m_children)
|
|
sn->update();
|
|
}
|
|
|
|
void ContainerNode::addChild(const std::string &childName)
|
|
{
|
|
SceneNode* node = RESOURCE_GET(SceneNode, childName);
|
|
if(node != NULL)
|
|
{
|
|
m_children.push_back(node);
|
|
node->m_parent = this;
|
|
}
|
|
}
|
|
|
|
void ContainerNode::removeChild(const std::string &childName)
|
|
{
|
|
SceneNode* node = RESOURCE_GET(SceneNode, childName);
|
|
if(node != NULL)
|
|
{
|
|
for(unsigned int i=0; i<m_children.size(); ++i)
|
|
{
|
|
if(m_children[i] == node)
|
|
{
|
|
m_children[i]->m_parent = NULL;
|
|
m_children[i] == m_children.back();
|
|
m_children.pop_back();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|