added operators +, - to Vector, added inverse transform instance variable to shapes/Shape, changed Sphere to use its inverse transform when calculating intersections and normals, removed simplistic lighting from main/Scene
git-svn-id: svn://anubis/fart/trunk@47 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
dad8497bf4
commit
7d7ec130e0
5 files changed
+40
-25
No files matched your search
+1
-16
@@ -151,26 +151,11 @@ Vector Scene::traceRay(const Ray & ray)
|
||||
it != m_shapes.end();
|
||||
it++)
|
||||
{
|
||||
/* transform the ray by the inverse of the shape's transform */
|
||||
Transform inv = (*it)->getTransform().getInverse();
|
||||
Ray local_ray = inv.transform_ray(ray);
|
||||
|
||||
/* then intersect this inversely transformed ray with the shape */
|
||||
Solver::Result intersections = (*it)->intersect(local_ray);
|
||||
Solver::Result intersections = (*it)->intersect(ray);
|
||||
|
||||
if (intersections.numResults > 0)
|
||||
{
|
||||
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;
|
||||
#if 0
|
||||
color[0] = dot;
|
||||
color[1] = dot;
|
||||
color[2] = dot;
|
||||
#endif
|
||||
color[0] = color[1] = color[2] = 1.0;
|
||||
}
|
||||
else
|
||||
|
||||
Reference in new issue
Block a user