RayTracer
This project is a raytracer. Requirements were to add an object of our
own and add refraction to light transmitted through the objects. I chose
to add a box object although I rather misnamed the new object as a
cube. Refraction is also demonstrated with objects of both index of
refraction 1 and 1.52 (glass). I included an image of the final applet outcome
since they are rather slow in scanning each line of the image.
Example applets:
- Crystal ball with index of refraction
1 - Notice that the sphere behind the crystal ball is visible since
the light passes straight through the crystal ball without bending.
- Crystal ball with index of refraction
1.52 - Notice that the sphere behind the crystal ball is seen but
since the light is bent it is refracted onto a different part of the
crystal ball.
- A sphere and cubes - A scene
demonstrating transparenct along with the new object in festive
Christmas colors!
- Box Man - A man made of boxes and two glass
spheres for eyes!
The Source Code:
Note that all .java files are actually located in the same file
containing all the classes.
- RayTrace.java - Code for applet and file
parsing - modified to read in new cube object.
- Cube.java - Code for new cube object,
including intersection test.
- Sphere.java - Code for sphere object,
modified to account for rays originating inside the sphere.
- Surface.java - Code for storing object
surfaces and shading given points - modified to include refraction and
internal reflections in shading. Infinite internal bouncing of rays was
limited to a depth of 5.
- Light.java - Code for lighting in the
scene.
- Ray.java - A utility class for
rays.
- Vector3D.java - A utility class for
vectors/ points.