diff --git a/main/Scene-load.cc b/main/Scene-load.cc index dd5228b..b85dd12 100644 --- a/main/Scene-load.cc +++ b/main/Scene-load.cc @@ -19,64 +19,10 @@ void Scene::load(const char * filename) { refptr scope = new Scope(); refptr node = parse(filename, scope); - processNode(node); -} - -void Scene::processNode(refptr node) -{ - if (node.isNull()) - return; - - if ( typeid(*node) == typeid(SceneNode) ) + if ( ! node.isNull() ) { processScene(node); } - else if ( node->isShape() ) - { - ShapeRef shape = processShape(node); - if ( ! shape.isNull() ) - m_shapes.push_back(shape); - } - else if ( typeid(*node) == typeid(LightNode) ) - { - refptr light = processLight(node); - if ( ! light.isNull() ) - m_lights.push_back(light); - } - else if ( typeid(*node) == typeid(OptionsNode) ) - { - processOptions(node); - } - else if (node->isTransformBlock()) - { - vector shapes = processTransformBlock(node); - for (int i = 0, sz = shapes.size(); i < sz; i++) - { - m_shapes.push_back(shapes[i]); - } - } - else if ( typeid(*node) == typeid(MaterialDefinitionNode) ) - { - processMaterialDefinition(node); - } - else if ( typeid(*node) == typeid(ShapeDefinitionNode) ) - { - processShapeDefinition(node); - } - else - { - cerr << __FILE__ << ": " << __LINE__ - << ": error: unrecognized node!" << endl; - } -} - -void Scene::processChildren(refptr node) -{ - std::vector< refptr > & children = node->getChildren(); - for (int i = 0, sz = children.size(); i < sz; i++) - { - processNode(children[i]); - } } void Scene::processScene(refptr node) @@ -100,15 +46,25 @@ void Scene::processScene(refptr node) } } + /* then any other scene-specific items */ for (Node_Iterator it = node->getChildren().begin(); it != node->getChildren().end(); it++) { - if ( typeid(**it) != typeid(CameraNode) ) + if ( typeid(**it) == typeid(LightNode) ) { - processNode(*it); + refptr light = processLight(*it); + if ( ! light.isNull() ) + m_lights.push_back(light); + } + else if ( typeid(**it) == typeid(OptionsNode) ) + { + processOptions(*it); } } + + /* then any general items */ + processGeneralItems(node); } ShapeRef Scene::processShape(refptr node) diff --git a/main/Scene.h b/main/Scene.h index 21be396..eb789d2 100644 --- a/main/Scene.h +++ b/main/Scene.h @@ -58,8 +58,6 @@ class Scene /* In Scene-load.cc */ void load(const char * filename); - void processNode(refptr node); - void processChildren(refptr node); void processScene(refptr node); refptr processMaterial(refptr node); ShapeRef processBox(refptr node);