working on die scene, fixed bug in Scene-load for loading colors applied to lights

git-svn-id: svn://anubis/fart/trunk@216 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-03-15 21:11:01 +00:00
1 parent 5590c533ce
commit 7d9eb65fde
4 files changed
+124 -51

No files matched your search

+3 -3
View File
@@ -375,17 +375,17 @@ refptr<Light> Scene::processLight(refptr<Node> node)
}
else if ( typeid(**it) == typeid(DiffuseNode) )
{
Color c(node->getVector());
Color c((*it)->getVector());
light->setDiffuseColor(c);
}
else if ( typeid(**it) == typeid(SpecularNode) )
{
Color c(node->getVector());
Color c((*it)->getVector());
light->setSpecularColor(c);
}
else if ( typeid(**it) == typeid(ColorNode) )
{
Color c(node->getVector());
Color c((*it)->getVector());
light->setDiffuseColor(c);
light->setSpecularColor(c);
}
+6 -3
View File
@@ -26,7 +26,7 @@ Scene::Scene(const map<string, const char *> & options,
m_vfov = 60.0;
m_verbose = true;
m_data = NULL;
m_ambient_light = Color(0.1, 0.1, 0.1);
m_ambient_light = Color(0.2, 0.2, 0.2);
m_max_depth = 10;
m_transforms.push(Transform());
@@ -252,6 +252,9 @@ Color Scene::computePhong(const refptr<Material> material,
double shininess = material->getShininess();
const Color & diffuseColor = material->getDiffuseColor();
const Color & specularColor = material->getSpecularColor();
Vector normal = surfaceNormal;
if (normal % viewRay.getDirection() > 0.0) /* back face */
normal = -normal;
for (std::vector< refptr<Light> >::const_iterator it = m_lights.begin();
it != m_lights.end();
@@ -260,7 +263,7 @@ Color Scene::computePhong(const refptr<Material> material,
Vector directionToLight = (*it)->getPosition() - surfacePoint;
directionToLight.normalize();
Vector reflectedLightDirection =
directionToLight.reflect(surfaceNormal);
directionToLight.reflect(normal);
Ray surfaceToLight(surfacePoint, directionToLight);
Color light_contribution =
@@ -271,7 +274,7 @@ Color Scene::computePhong(const refptr<Material> material,
|| light_contribution.b > 0.0 )
{
/* calculate the diffuse term */
double diffuse_coef = directionToLight % surfaceNormal;
double diffuse_coef = directionToLight % normal;
if (diffuse_coef > 0.0)
{
result += diffuseColor