diff --git a/parser/nodes.cc b/parser/nodes.cc index e69de29..b7cb8d2 100644 --- a/parser/nodes.cc +++ b/parser/nodes.cc @@ -0,0 +1,14 @@ + +#include "nodes.h" +#include +using namespace std; + +void Node::addChildren(refptr other) +{ + for (typeof(other.m_children)::const_iterator it = other.m_children.begin(); + it != other.m_children.end(); + it++) + { + addChild(*it); + } +} diff --git a/parser/nodes.h b/parser/nodes.h index 556a828..7e48853 100644 --- a/parser/nodes.h +++ b/parser/nodes.h @@ -8,6 +8,9 @@ class Node { public: void addChild(refptr child) { m_children.push_back(child); } + void addChildren(refptr other); + + virtual void process(refptr scene) {} virtual refptr getMaterial() { @@ -18,7 +21,7 @@ class Node std::vector< refptr > m_children; }; -class SceneNode +class SceneItemsNode : public Node { }; diff --git a/parser/parser.yy b/parser/parser.yy index 6f6eb0b..2fb23ee 100644 --- a/parser/parser.yy +++ b/parser/parser.yy @@ -329,9 +329,9 @@ plane_items: shape_items { $$ = $1; } scene_items: /* empty */ | scene_item scene_items { - $$ = new Node(); - $$->the_Node = $1; - $$->the_tail = $2; + $$ = new SceneItemsNode(); + $$->addChild($1); + $$->addChildren($2); } ;