Archive for the ‘assignments’ Category

Assignment 10

Sunday, May 14th, 2006

If you didn’t finish Assignment 10, you can download assignment10.c as a starting point for Assignment 11.

Is this <hint>normal</hint> behavior?

Wednesday, May 10th, 2006

Have you noticed that the lighting calculations don’t seem to be affecting your windshield the same way they affect the rest of the car?

I wonder which part of the illumination equation isn’t being evaluated normally.

Assignment 9

Friday, April 28th, 2006

Assignment 9 is available. Trust me — the assignment will be easier if you attend class and implement the version of the algorithm that we discuss.

A note on doing the work yourself

Friday, April 14th, 2006

I realize that in Assignment 6 and Assignment 7 where we deal with well-known algorithms, it will be especially tempting to use someone else’s implementation — they are, after all, readily available on teh interwebs.

Note, however, the following:

  1. Turning in code you didn’t write yourself is Academic Dishonesty.
  2. Using someone else’s pseudocode is fine, as long as you credit the source.
  3. If you do use someone else’s pseudocode, make sure you understand what it does.
  4. There will be at least one question on each algorithm on the Final Exam.
  5. If you take the time to implement the algorithm yourself, you will be more likely to remember it well enough to earn full credit on the exam.

Remember also that if you are struggling with an algorithm, you are allowed to work on homework assignments with a partner.

Hint: pick a partner who’s smarter than you are.

Assignment 5

Saturday, March 11th, 2006

Assignment 5 is available. Note that this is the last assignment due before the Midterm Exam on March 24.

A correction

Monday, March 6th, 2006

If you were paying attention over the weekend, you noticed that I updated the screenshot for Assignment 4.If you compare it with the original screenshot, you’ll notice that the original wasn’t really a parallel projection.

The problem is that (as you should recall from your reading) OpenGL is a state machine. When you make a function call like gluPerspective() to update the current projection matrix, that change stays in effect until you reset the matrix (e.g., with glLoadIdentity().

My mistake was to draw the parallel projections (calling glOrtho()) without remembering to reset the projection matrix, which had already been set with gluPerspective. The result was that we took a cube in perspective, then drew a parallel projection of the perspective rendering. Oops. I didn’t notice because it looks “sort of” right — there was, in fact, a parallel projection happening.

To avoid making silly mistakes like me, do the following whenever you go to render a model (e.g., in your display callback):

  1. Set the viewport.
    glViewport(0, 0, width, height);
  2. Set up the projection.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2.0, 2.0, -2.0, 2.0, 0.0, 10.0);
  3. Set your viewing parameters.
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(0.0, 0.0, 3.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
  4. Draw the scene.
    glClearColor(0.0, 0.0, 0.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT);
    
    glColor(0.0, 0.0, 1.0);
    glutWireSphere(1.0, 10, 10);

Don’t cross the streams

Friday, March 3rd, 2006

If you’re still working on Assignment 3, note that the coordinate axes (the lines in gray) should not be moving when you transform the cube. The axes should remain at the center of the world, not at the center of your model.

By the way, Assignment 4 is available.

Assignment 3

Saturday, February 25th, 2006

Assignment 3 is available.

Demo version of Assignment 2

Monday, February 20th, 2006

A compiled executable version of Assignment 2 is now available. Download assignment2.exe to see how your program should work.

My version needed 14 new lines of code: a function to implement the vector cross product operation and some changes to the function move_point().

Assignment 2 update

Sunday, February 19th, 2006

Some compilers may have trouble with Assignment 2 because their standard library’s <math.h&gt header files define y0() and y1() to compute the Bessel function.

To fix the issue, replace y0 and y1 with y_0 and y_1 or download the updated version of assignment2.c

Line 194 may cause some compilers to issue warnings:

glutPostRedisplay;

should be

glutPostRedisplay();