asg00.tar.gz
tarball, gunzip it, and compile the ray tracer with the
Makefile
provided:
gunzip asg00.tar.gz
tar xvf asg00.tar
cd asg00
make clean
make
./main cbox.txt > cbox.ppm
cbox.ppm
image with your
favorite image viewer (e.g., xv
), it should
look like the one here, but larger:
ray_t
object
with the following private data members:
double dis; // distance
vec_t pos; // position
vec_t dir; // direction
and public method:
void trace(model_t&,rgb_t<double>&,object_t*);
ray_t
class.
ray.h
and ray.cpp
).
main()
subroutine to "spawn a ray"
for each position and direction calculated and then
call this ray's trace
method to calculate
the resultant color at each given pixel. This is
usually done via instantiation of a new ray object, e.g.,
// spawn new ray; analogous to C's malloc()
ray = new ray_t(pos,dir);
and then by calling the ray's trace function:
// trace ray (note the use of the -> operator, not the .)
ray->trace(model,color,NULL);
Don't forget to delete the ray once it is no longer
needed:
// delete ray, analogous to C's free()
delete ray;
ray_trace()
function from
main.cpp
.
cbox.txt
file.
trace()
routine into a public member function of the ray_t
class. What you need to watch out for are the stand-alone
function's argument and local variables' semantics,
i.e., how these variable contents change as the recursive ray
tracing algorithm proceeds. In the new object-oriented version,
clearly each ray maintains its own distance, position, and
direction. One tricky aspect of this assignment is how to
properly update these.
trace()
routine agian, each ray needs to spawn a reflection ray and
"bounce" that at the current surface point. Make sure that
you free up any allocated memory here—do NOT create a
memory leak!
tar.gz
archive of your asg##/ directory, including:
README
file containing
Makefile
.h
headers and .cpp
source)
make clean
before tar
)
handin
notes