filled out Scene::processLight(), added color keyword to light specification

git-svn-id: svn://anubis/fart/trunk@171 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop 2009-03-01 22:41:23 +00:00
parent 0ea6e96e0a
commit 65c447f85a
3 changed files with 33 additions and 1 deletions

View File

@ -11,6 +11,7 @@ class Light
Light();
void setPosition(const Vector & position) { m_position = position; }
void setPosition(refptr<Vector> vec) { setPosition(*vec); }
const Vector & getPosition() const { return m_position; }
void setDiffuseColor(const Color & diffuse)

View File

@ -388,7 +388,35 @@ refptr<Shape> Scene::processCyl(refptr<Node> node)
refptr<Light> Scene::processLight(refptr<Node> node)
{
return refptr<Light>(NULL);
refptr<Light> light = new Light();
for (Node_Iterator it = node->getChildren().begin();
it != node->getChildren().end();
it++)
{
if ( typeid(**it) == typeid(PositionNode) )
{
light->setPosition((*it)->getVector());
}
else if ( typeid(**it) == typeid(DiffuseNode) )
{
Color c(node->getVector());
light->setDiffuseColor(c);
}
else if ( typeid(**it) == typeid(SpecularNode) )
{
Color c(node->getVector());
light->setSpecularColor(c);
}
else if ( typeid(**it) == typeid(ColorNode) )
{
Color c(node->getVector());
light->setDiffuseColor(c);
light->setSpecularColor(c);
}
}
return light;
}
refptr<Shape> Scene::processPlane(refptr<Node> node)

View File

@ -198,6 +198,9 @@ light_item: POSITION vector {
| SPECULAR vector {
$$ = new SpecularNode($2->getVector());
}
| COLOR vector {
$$ = new ColorNode($2->getVector());
}
;
material: MATERIAL LCURLY material_items RCURLY {