added Node::evaluate(parent)

git-svn-id: svn://anubis/fart/branches/scene-file-scripting@335 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2010-10-06 15:38:25 +00:00
parent 74f27c2076
commit b851c3be98
2 changed files with 19 additions and 9 deletions

View File

@ -21,7 +21,12 @@ void Scene::load(const char * filename)
refptr<Node> node = parse(filename, scope); refptr<Node> node = parse(filename, scope);
if ( ! node.isNull() ) if ( ! node.isNull() )
{ {
processScene(node); refptr<Node> dummy = new Node();
/* evaluate any scripting nodes in the node tree */
node->evaluate(dummy);
/* now we have a new node tree under 'dummy' with no scripting nodes */
processScene(dummy->getChildren()[0]);
} }
} }
@ -233,14 +238,6 @@ vector<ShapeRef> Scene::processGeneralItems(refptr<Node> node)
{ {
shapes.push_back(processShape(*it)); shapes.push_back(processShape(*it));
} }
else if ( typeid(**it) == typeid(ForNode) )
{
incoming = processForNode(*it);
}
else if ( (*it)->isExpression() )
{
(*it)->getNumber(); /* evaluate the expression */
}
while (incoming.size() > 0) while (incoming.size() > 0)
{ {
shapes.push_back(incoming[0]); shapes.push_back(incoming[0]);

View File

@ -47,6 +47,19 @@ class Node
std::cerr << "Warning: Node::getNode() called!" << std::endl; std::cerr << "Warning: Node::getNode() called!" << std::endl;
return NULL; return NULL;
} }
virtual void evaluate(refptr<Node> parent)
{
std::cerr << "Warning: Node::evaluate() called!" << std::endl;
}
virtual void evaluateChildren(refptr<Node> parent)
{
for (std::vector< refptr<Node> >::iterator it = m_children.begin();
it != m_children.end();
it++)
{
(*it)->evaluate(parent);
}
}
virtual bool isShape() { return false; } virtual bool isShape() { return false; }
virtual bool isMaterial() { return false; } virtual bool isMaterial() { return false; }