To generate realistic-looking images using ray tracing.
You will implement a RayTraceWindow.java class that can be used to ray-trace a joogl scene (we will provide you with some sample code below to get you started). Your program (a5.java) should create a joogl scene graph and display it in a window, and then create a RayTraceWindow object to render the same scene graph using a ray tracer.
The RayTraceWindow class opens a Swing window and creates a Thread using its run() method. A ray traced version of the scene should be displayed in the window as the ray tracing progresses. The ray traced scene should be stored in an Image structure in the RayTraceWindow class, and the window should display the contents of the Image. When the ray tracer is finished, the ray tracer thread should save the Image in a jpeg file before terminating. Most of this logic is provided in the sample code below: you will write the code to ray trace the scene.
Your program should handle all joogl objects except teapots and cones: all lights (except spot lights, which is an extra credit option), and the sphere, polygon and cube objects. The jooglMaterial has been enhanced with the additional information needed by the ray tracer, as described below.
The supplied sample program takes a snapshot (copy) of a jooglRoot. This snapshot contains copies of all the nodes and properties, and converts dynamic properties to static properties by sampling them at the appropriate time value. You should use this copy of the scene graph in your ray tracer; you may optionally perform additional optimizations on this scene graph to speed up the ray tracer (see the extra credit).
Your program should compute colors using the local illumination model we discussed in class earlier in the semester. It should also generate shadows, handle transparency and reflection.
In addition to using sample joogl scenes provided by the TA, you should create at least one "new" joogl scene and include it with your submission as part of the a5.java file.
You will most likely need to modify the joogl objects to implement your ray tracer. You may use your version of joogl, or the sample version posted with assignment 4.
You should NOT modify the existing interface to joogl, nor the provided interface to RayTraceWindow.java: all your changes should be internal to these objects, or be to add additional methods to support ray tracing of the objects. This will allow the TA to use his own test program to test your ray tracer.
Your submission should consist of a collection of java files needed to implement RayTraceWindow.java, and a mainline joogl program (a5.java) that demonstrates the use of your RayTraceWindow class on a "new" joogl scene created by you. Your source files should be commented with the usual comments.
You must also include a ray traced image generated by your sample program, at a resolution of 512x512.
Your submission MUST be submitted using WebWork, as discussed in class. If you are unsure of how to submit using WebWork, talk to the TAs BEFORE THE ASSIGNMENT IS DUE.
IMPORTANT: If the TA has to edit your files to compile your code, you will lose up to 25% of the grade you could have gotten.
This program is due on or before class on Tuesday, December 4th. This means it must be received by 9:30am EDT on Tuesday to not be considered late.
There is one significant difference between the previous version of joogl, which is the material properties on the geometry objects. In addition to the "r g b" values from assignment 3, these objects now have the following additional four parameters:
Kd Ks Shine index_of_refraction
As before, RGB are in the range of 0.0 to 1.0. The original joogl material
properties are used. The alpha value of the material color is used as Kt,
the transmission coefficient (where Kt = 1 - alpha).
Kd is the diffuse component, Ks the specular, Shine is the Phong cosine
power for highlights. Usually, 0 <= Kd <= 1 and 0 <= Ks <= 1,
though it is
not required that Kd + Ks == 1. Note that transmitting objects ( alpha <
1 )
are considered to have two sides for algorithms that need these (normally
objects have one side).
Your task will be to implement the function "public Color ShootRay(int x, int y)" in the file RayTraceWindow.java. The window has a copy of the scene graph that can be used inside ShootRay.
A skeleton version of RayTraceWindow.java, with a simple driver program to call it and save a file, is available here.
A suggested way to implement the ray tracer is to create a Hit.java class and implement a function such as "public abstract Hit intersectRay (originx, originy, originz, dirx, diry, dirz, jooglRoot root)" on each of the scene objects, and put whatever information you need in the returned "Hit" object that this function returns (for example, the color, object hit, and t-value of the intersection along the ray might all be useful).
The window size is passed to the RayTraceWindow when it is created. You should keep it small while debugging (ray tracing is slow), but increase it when you are generating images you are happy with.
Finally, the provided sample program is based on the juggler in assignment 4. Feel free to change it as you want, but do not change the interface to RayTraceWindow.java.
The following options can be added for extra credit. You will receive extra credit for each option you implement, which may exceed the 2 possible point total that could be obtained in the previous assignments (each option will be worth 1 or 2 points, and are listed in order of probable difficulty):
In all cases, be sure that you have a README file that describes the enhancement(s), as well as instructions on how to invoke them or show them off. For example, you should include additional sample programs that demonstrate your features. For speedup options, you should be able to enable or disable them from the command line, so the TA can observe the speed differences.
To support animation, you should generate a series of images of a joogl animation (such as your juggler) and save them as a Quicktime movie. We will provide you with sample source to write Quicktime movies using JFM here; you should use the ImageSource and SequenceExporter classes to export the movie (JMF is the Java Media Framework, which can be downloaded from Sun. There is a Windows version and a pure Java version). Your joogl program should show each frame of the animation as it is being ray traced, and the RayTraceWindow should show the same frame as it is being traced. The provided RayTraceWindow class has a constructor to specify the start/stop/increment parameters for the animation. You should submit the video created by your test program with your submission, and it should be at reasonable length.
To simplify the scene graph prior to ray tracing (#3 above), you should do the following:
Note: you should NOT worry about any of these until you have implemented the basic functionality of the program--the required parts!