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,15 +709,36 @@ refptr<Polygon> Scene::processNGon(refptr<Node> node)
|
|||||||
refptr<Shape> Scene::processShapeRef(refptr<Node> node)
|
refptr<Shape> Scene::processShapeRef(refptr<Node> node)
|
||||||
{
|
{
|
||||||
if (m_shape_definitions.find(node->getString())
|
if (m_shape_definitions.find(node->getString())
|
||||||
!= m_shape_definitions.end())
|
== m_shape_definitions.end())
|
||||||
{
|
{
|
||||||
refptr<Shape> shape = m_shape_definitions[node->getString()]->clone();
|
cerr << "Error: no shape definition for '" << node->getString()
|
||||||
shape->setTransform(m_transforms.top() * shape->getTransform());
|
<< "' found!" << endl;
|
||||||
return shape;
|
exit(3);
|
||||||
}
|
}
|
||||||
cerr << "Error: no shape definition for '" << node->getString()
|
|
||||||
<< "' found!" << endl;
|
refptr<Material> material;
|
||||||
exit(3);
|
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 Scene::processTransforms(refptr<Node> node)
|
||||||
|
@ -458,9 +458,24 @@ 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; }
|
shape_item: material { $$ = $1; }
|
||||||
| material_ref { $$ = $1; }
|
| material_ref { $$ = $1; }
|
||||||
| transform { $$ = $1; }
|
| transform { $$ = $1; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user