Color shootRay(Scene *world, Ray *ray, int bounce) { Color tempCol; Hit tempHit; Vector norm; Vector hitPt; tempCol.x = 0; tempCol.y = 0; tempCol.z = 0; if(bounce > MAX_BOUNCES) { fprintf(stderr, "TOO MANY BOUNCES\n"); tempCol.x = 1; tempCol.y = 1; tempCol.z = 1; return tempCol; } // if tempHit = intersectObjects(world, ray); /* Nothing hit, return background color */ if(tempHit.obj == NULL) { tempCol.x = 1; tempCol.y = 0; tempCol.z = 0; return tempCol; } // if Scalar t; t = tempHit.obj->hits(tempHit.obj, ray); // Distance of hit hitPt = rayEquation(ray, t); // Calculate hitpoint norm = tempHit.obj->normalAt(tempHit.obj, &hitPt); // Find normal tempCol = lightPoint(tempHit.obj, &hitPt, &norm, world); if((tempHit.obj->specular.x !=0) && (tempHit.obj->specular.y != 0) && (tempHit.obj->specular.z != 0)) { // Specular lighting goes here } // fprintf(stderr, "Color before return is - r:%3lf g:%3lf b: %3lf\n", tempCol.x, tempCol.y, tempCol.z); return tempCol; } // shootRay