600.357/600.457 Assignment 2

Handed out: Oct 7
Due: Oct 27, 3:59pm.

457 students, turn in your assignment here
357 students, turn in your assignment here

As usual, a Makefile/project file, documented source and a README file must be included.

Note: 20% of your grade will be depend on the design, readability and documentation of your program.


We will implement some of the OpenGL functions used in assignment 1. You may then use your own version of these functions to run the previous program. (Of course, you will be tested on this assignment, not the previous one. You may use the a test example.) You will implement transformations and lighting. In particular, you will implement the following OpenGL functions (use the prefix gll/gllu instead of gl/glu) and put them into a gll library (that should be libgll.a or libgll.so on unix and gll.lib on windows). Your main "test" program will use this library and the new gll.h to perform rendering. In other words, you will replace all corresponding gl calls in your first assignment to test your library. (Even easier: you may include this header file after gl.h and glu.h in your main program.) Remember, you will IMPLEMENT these functions and NOT simply write wrappers to call the equivalent gl funtions. You will implement your own matrix stacks (allowing upto at least 8 matrices per stack). Your gllNormal3f implementation should simply store the values for future use. Your gllVertex3f implementation will use the stored normal to compute the vertex colors and then call glColor3f to set the appropriate color. It will then call the real glVertex3f to perform the rendering.

In gllEnable(GL_LIGHTING), you should call glDisable(GL_LIGHTING), so only your colors are used. Implement at least eight lights: GL_LIGHT0 to GL_LIGHT7.

In addition implement gllSetMatrix() to load the matrices at the top of your two stacks into corresponding gl Matrix stacks.

457 addendum

Students in 457 are required to implement additional functions: glluGetCamera returns the current camera frame of reference. The first three numbers returned form the unit camera-X vector in world space, the next two sets are the camera-Y and Z and the last three are thr origin of current camera.

glluLookAtOblique does not assume that the camera-Z is from the center of view to eye. Camera Z is directly specified by (Nx, Ny, Nz): You have to find the projection matrix that still generates normalized X, Y and Z coordinates after projection as follows
Center need not be on the view plane, of course. The intersection of center with the view-plane won't have a 0 coordinate any more.


In case you have not figured this out yet, the standard OpenGL Projection matrix is

                    {     f                                  }
                    |  ------- 0      0            0         |
                    |  aspect                                |
                    |                                        |
                    |    0     f      0            0         |
                    |                                        |
                    |             zFar+zNear  2*zFar*zNear   |
		    |	 0     0  ----------  ------------   |
                    |             zNear-zFar   zNear-zFar    |
                    |                                        |
                    {    0     0      -1           0	     }

where f = cot(yFOV/2).
Also if you do not yet know how to make libraries from your object files: here is the unix incantation --

          ar -ru libgll.a file1.o file2.o ...

(ar is in /usr/ccs/bin/, if your path does not include it). Once you have the library you can compile your main program using -lgll option. Make sure that the library's dir is in your load path: Use -L<path>.


subodh@cs.jhu.edu

-- The URL of this page is: http://www.cs.jhu.edu/~subodh/457/asn2.html --