added optional block following shape references which can contain transforms or materials specific to the shape instance
git-svn-id: svn://anubis/fart/trunk@312 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
f67707e666
commit
e5e4f991fb
@ -709,17 +709,38 @@ refptr<Polygon> Scene::processNGon(refptr<Node> node)
|
||||
refptr<Shape> Scene::processShapeRef(refptr<Node> node)
|
||||
{
|
||||
if (m_shape_definitions.find(node->getString())
|
||||
!= m_shape_definitions.end())
|
||||
== m_shape_definitions.end())
|
||||
{
|
||||
refptr<Shape> shape = m_shape_definitions[node->getString()]->clone();
|
||||
shape->setTransform(m_transforms.top() * shape->getTransform());
|
||||
return shape;
|
||||
}
|
||||
cerr << "Error: no shape definition for '" << node->getString()
|
||||
<< "' found!" << endl;
|
||||
exit(3);
|
||||
}
|
||||
|
||||
refptr<Material> material;
|
||||
refptr<Shape> shape = m_shape_definitions[node->getString()]->clone();
|
||||
|
||||
bool restore_transform = processTransforms(node);
|
||||
|
||||
for (Node_Iterator it = node->getChildren().begin();
|
||||
it != node->getChildren().end();
|
||||
it++)
|
||||
{
|
||||
if ( (*it)->isMaterial() )
|
||||
{
|
||||
material = processMaterial(*it);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! material.isNull() )
|
||||
shape->setMaterial(material);
|
||||
shape->setTransform(m_transforms.top() * shape->getTransform());
|
||||
|
||||
if (restore_transform)
|
||||
m_transforms.pop();
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
||||
bool Scene::processTransforms(refptr<Node> node)
|
||||
{
|
||||
bool did_any = false;
|
||||
|
@ -458,7 +458,22 @@ shape_definition: DEFINE SHAPE IDENTIFIER shape {
|
||||
}
|
||||
;
|
||||
|
||||
shape_ref: SHAPE IDENTIFIER { $$ = new ShapeRefNode($2->getString()); }
|
||||
shape_ref: SHAPE IDENTIFIER shape_ref_more {
|
||||
$$ = new ShapeRefNode($2->getString());
|
||||
$$->addChildren($3);
|
||||
}
|
||||
;
|
||||
|
||||
shape_ref_more: /* empty */
|
||||
| LCURLY shape_ref_items RCURLY { $$ = $2; }
|
||||
;
|
||||
|
||||
shape_ref_items: /* empty */
|
||||
| shape_item shape_ref_items {
|
||||
$$ = new ItemsNode();
|
||||
$$->addChild($1);
|
||||
$$->addChildren($2);
|
||||
}
|
||||
;
|
||||
|
||||
shape_item: material { $$ = $1; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user