MIT OCW 6.837 Assignment 2

Last weekend I have finished assignment_2.

This assignment adds ambient & normal shading to the raycast program of assignment 1.

Now 3D objects looks much more like 3D objects.

And, here is my code.


Now the objects looks like this. (3 graphics for each scene. From left to right: real, depth, normal[red:x, green:y, blue:z])
Figure 1. A Sphere with normal shading

depth5 normal5 scene5

Figure 2. A Sphere with both normal shading and ambient
depth6 normal5 scene6

Figure 3. Perspective Camera

depth7 scene7

Figure 4. Infinite Plane Object

depth8 normal7 scene8

Figure 5. Triangle

depth9 normal8 scene9

Figure 6. Triangle Mesh


Figure 7. Rotated Sphere



Figure 8. Transformed Sphere


Figure 9. Complex Triangle Mesh (n = 200)

depth13 normal13 scene14
Figure 10. More Complex Triangle Mesh (n = 1000)

depth14 normal14 scene15

Figure 11. Axies

depth15 normal15 scene16


I am learning MIT OCW. Today I have finished 6.837 Computer Graphics, Fall 2003 Assignment 1.

The assignment is:

6.837 Introduction to Computer Graphics Assignment 1: Ray Casting Due Wednesday September 17, 2003 at 11:59pm
In this assignment, you will implement a basic ray caster. This will be the basis of all the following assignments, so proper code design is quite important. As seen in class, a ray caster sends a ray for each pixel and intersects it with all the objects in the scene. You will implement a ray caster for an orthographic camera (parallel rays) for sphere primitives. You will use a very basic shading model: the objects have a constant color. As an alternative, you will also display the distance t of each pixel to the camera.
You will use object-oriented design to make your ray-caster flexible and extendable. A generic Object3D class will serve as the parent class for all 3D primitives. You will derive subclasses, such as Sphere, to implement specialized primitives. In later assignments, you will extend the set of primitives with planes and polygons. Similarly, this assignment requires the implementation of a general Camera class and an OrthographicCamera subclass. In the next assignment, you will also derive a general perspective camera.
We provide you with a Ray class and a Hit class to manipulate camera rays and their intersection points.
•Write a pure virtual Object3D class (see specifications below).
•Derive Sphere, a subclass of Object3D, and implement the intersection of a sphere with a ray.
•Derive Group, also a subclass of Object3D, that stores an array of pointers to Object3D instances. Write the intersection routine.
•Write a pure virtual Camera class and subclass OrthographicCamera. Write the corresponding ray generation method for the subclass.
•Use the input file parsing code provided to load the camera, background color and objects of the scene. 1
•Write a main function that reads the scene (using the parsing code provided),
loops over the pixels in the image plane, generates a ray using your OrthographicCamera class, intersects it with the high-level Group that stores the objects of the scene, and writes the color of the closest intersected object.
•Implement a second rendering style to visualize the depth of objects in the scene.
•Extra credit: Write both the geometric and algebraic sphere intersection methods, add cylinders and cones, fog based on distance to the image plane, etc.
•Provide a README.txt file that discusses any problems you encountered, how long it took to complete the assignment, and any extra credit work that you did.

Here is my homework


And here is the output.

depth1 depth2 depth3 depth4 scene1 scene2 scene3 scene4