Vector rayColour(Scene *s, Ray *r) { Vector ret; if ((*r).recursionDepth++ < RECURSELIMIT) { //printf("\nrecurse %d",(*r).recursionDepth); Intersection intersections[(*s).objectsSize]; Intersection first; int i; Vector pntTime, nat; for (i=0; i<(*s).objectsSize; i++){ ObjectRel objectrel = (*s).objects[i]; (intersections[i]) = initIntersection(objectrel.sphere, intersectionTime((*s).objects[i].sphere,(*r)), (*s).objects[i].surface); } first = firstIntersection(intersections, (*s).objectsSize); if (first.t == 9999999) { ret.x = 0; ret.y = 0; ret.z = 0; } else { pntTime = pointAtTime((*r), first.t); nat = normalAt(first.o, pntTime); //printf("lambert: %f\n", first.s.lambertCoefficient); ret = colorAt(&first.s, s, (*r), &pntTime, nat ); } } else { ret.x = 0; ret.y = 0; ret.z = 0; } return ret; }
Spline2f Spline2f::offsetPath( float distance ) { Spline2f offsetSpline; int nControlPoints = numControlPoints(); float delta = 1.f / ( nControlPoints - 1 ); for( int i = 0; i < nControlPoints; ++i ) { float t = i * delta; Vector2f controlPoint = getControlPoint( i ); Vector2f normalAtControlPoint = normalAt( t ).normalized(); offsetSpline.appendControlPoint( controlPoint + distance * normalAtControlPoint ); } return offsetSpline; }