From 65c447f85ab87737d07f35c27835632d7c65caa1 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 1 Mar 2009 22:41:23 +0000 Subject: [PATCH] filled out Scene::processLight(), added color keyword to light specification git-svn-id: svn://anubis/fart/trunk@171 7f9b0f55-74a9-4bce-be96-3c2cd072584d --- main/Light.h | 1 + main/Scene-load.cc | 30 +++++++++++++++++++++++++++++- parser/parser.yy | 3 +++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/main/Light.h b/main/Light.h index 280fe0e..e1e869f 100644 --- a/main/Light.h +++ b/main/Light.h @@ -11,6 +11,7 @@ class Light Light(); void setPosition(const Vector & position) { m_position = position; } + void setPosition(refptr vec) { setPosition(*vec); } const Vector & getPosition() const { return m_position; } void setDiffuseColor(const Color & diffuse) diff --git a/main/Scene-load.cc b/main/Scene-load.cc index 4803b19..a03ac18 100644 --- a/main/Scene-load.cc +++ b/main/Scene-load.cc @@ -388,7 +388,35 @@ refptr Scene::processCyl(refptr node) refptr Scene::processLight(refptr node) { - return refptr(NULL); + refptr 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 Scene::processPlane(refptr node) diff --git a/parser/parser.yy b/parser/parser.yy index f7f4017..8d38256 100644 --- a/parser/parser.yy +++ b/parser/parser.yy @@ -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 {