adding tree node classes, updated addChild() and added addChildren() to Node

git-svn-id: svn://anubis/fart/trunk@107 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-02-16 17:29:57 +00:00
parent 3014a39bb0
commit 9849ba06b5
3 changed files with 21 additions and 4 deletions

View File

@ -0,0 +1,14 @@
#include "nodes.h"
#include <vector>
using namespace std;
void Node::addChildren(refptr<Node> other)
{
for (typeof(other.m_children)::const_iterator it = other.m_children.begin();
it != other.m_children.end();
it++)
{
addChild(*it);
}
}

View File

@ -8,6 +8,9 @@ class Node
{
public:
void addChild(refptr<Node> child) { m_children.push_back(child); }
void addChildren(refptr<Node> other);
virtual void process(refptr<Scene> scene) {}
virtual refptr<Material> getMaterial()
{
@ -18,7 +21,7 @@ class Node
std::vector< refptr<Node> > m_children;
};
class SceneNode
class SceneItemsNode : public Node
{
};

View File

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