Em suma, seu programa estara usando o codigo para ray-tracing que voce fez e nao algoritmo z-buffer otimizado do OpenGL para fazer o rendering. Assim, alguns segundos (ou mesmo minutos) extras poderao ser necessario para renderizar um simples quadro em resolucao completa. Provavelmente, voce devera rodar seu programa em background num "batch", do que interativamente. Talvez demore um ou dois dias para gerar a animacao.
Voce pode gerar quadros de 320 x 240, se achar mais facil (claro, preferimos
640 x 480). Voce pode mover sua animacao mais lentamente e conseguir mais
resolucao, por exemplo. Quanto mais movimento, mais quadros sao necessarios
(lembre-se disso ao gerar sua animacao).
Nomeie cada frame como 00.gif, 01.gif, 02.gif, ... 49.gif, etc. Gere
um gif animado com esta sequencia e
coloque num disquete identificado (o qual deverá ser entregue
no final). Coloque junto o seu código
(comentado)
I suggest you start by writing code to intersect a ray with objects. You'll also need a routine to calculate the normal at an arbitrary point in the objects, as in Phong shading. The goal of Phong shading, as you recall, is to interpolate normal vectors smoothly across a polygon so that you can shade the planar polygon (in our case, a triangle, if you model your objects using triangles) as if it were curved. Essentially you can linearly interpolate the x, y, and z components of the normal vector across the polygon, according to the position of the intersection point within the triangle, and then normalize the vector to unit length. (There are many places within a ray caster/tracer at which you should normalize direction vectors: normals, vectors toward the light, incident ray directions, etc. Be careful to do this. If your shading comes out strange, it could be because you forgot to normalize a direction vector.) Your interpolation scheme should give the normal vectors at least C0 continuity across the surface.
The method we recommend for interpolating normal vectors is barycentric coordinates, as discussed in the course notes.
You'll also need to implement texture mapping and for that you need to interpolate texture coordinates u and v (a.k.a. s and t) linearly across the polygon. The formulas for this are very much like those for Phong shading. You might want to share code or cache information to simplify and speed up the interpolation of both normal and texture coordinates.
Your data structures don't need to store a color with each vertex of the triangle, so you're not supporting Gouraud shading of vertex colors, as OpenGL does. Instead you can have a single Material associated with each Triangle. The Material properties include a diffuse reflectance color, which you assume to be constant across the triangle.
You'll also need to implement methods to calculate intersections, normals,
and texture coordinates for spheres. I recommend you implement spheres
first, as their code is simpler than that for general geometric models
represented by triangles.