fixed bug in QuadraticSolver, cheap lighting working
git-svn-id: svn://anubis/fart/trunk@45 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
761925220b
commit
d88f1ab5fd
5 files changed
+29
-20
No files matched your search
+9
-10
@@ -125,23 +125,22 @@ void Scene::renderPixel(int x, int y, unsigned char * pixel)
|
||||
{
|
||||
/* transform the ray by the inverse of the shape's transform */
|
||||
Transform inv = (*it)->getTransform().getInverse();
|
||||
Ray transformed_ray = inv.transform_ray(ray);
|
||||
Ray local_ray = inv.transform_ray(ray);
|
||||
|
||||
/* then intersect this inversely transformed ray with the shape */
|
||||
Solver::Result intersections = (*it)->intersect(transformed_ray);
|
||||
Solver::Result intersections = (*it)->intersect(local_ray);
|
||||
|
||||
if (intersections.numResults > 0)
|
||||
{
|
||||
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;
|
||||
Vector local_normal =
|
||||
(*it)->getNormalAt(local_ray[intersections.results[0]]);
|
||||
double dot = local_ray.getDirection() % local_normal;
|
||||
dot = -dot;
|
||||
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);
|
||||
pixel[BMP_RED] = 0xFF * dot;
|
||||
pixel[BMP_GREEN] = 0xFF * dot;
|
||||
pixel[BMP_BLUE] = 0xFF * dot;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user