Esempio n. 1
0
void reflectRay(const seenPair pair, const ray r, ray& ref)
{
	visible * hit 		= PARTS[pair.index];
	spaceVector dir 	= r.direction;
	spaceVector loc 	= ((dir*(pair.T)) + (r.origin)); // this places the location of the intersection .001 above the surface
	spaceVector normal 	= hit->getNormal(loc);

	loc = loc + normal*.001;
	dir = dir - (normal * ((dir.dotProduct(normal)) * 2.0));

	triple l = triple(loc.X, loc.Y, loc.Z);

	ref.origin = l;
	ref.direction = dir;
	ref.tMin = 0.f;
	ref.tMax = FLT_MAX;

	ref.normalize();
}
Esempio n. 2
0
ray<t> normalized (ray<t> r)
{
    return r.normalize();
}