added getNormalAt() to Shape & Sphere, trying to get basic lighting

git-svn-id: svn://anubis/fart/trunk@44 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
Josh Holtrop committed 2009-01-23 18:09:27 +00:00
1 parent 801f61f48c
commit 761925220b
6 files changed
+23 -7

No files matched your search

+10 -3
View File
@@ -132,9 +132,16 @@ void Scene::renderPixel(int x, int y, unsigned char * pixel)
if (intersections.numResults > 0)
{
pixel[BMP_RED] = 0xFF;
pixel[BMP_GREEN] = 0xFF;
pixel[BMP_BLUE] = 0xFF;
Vector local_intersection_point =
transformed_ray[intersections.results[0]];
Vector normal = (*it)->getNormalAt(local_intersection_point);
double dot = -(normal % transformed_ray.getDirection());
cout << "got dot " << dot << endl;
if (dot < 0.0)
dot = 0.0;
pixel[BMP_RED] = (unsigned char) (0xFF * dot);
pixel[BMP_GREEN] = (unsigned char) (0xFF * dot);
pixel[BMP_BLUE] = (unsigned char) (0xFF * dot);
}
else
{