Assignments

[Note: this webpage last modified Tuesday, 08-Jan-2013 11:36:45 EST]

Homework assignments will be posted to this website. Each homework assignment will list the date the assignment is due. Late assignments will not receive any credit; I will grade them just so you know how you did.

Here is a rough idea of my plans for the first few assignments.

Homework Assignments

The homework assignments are posted in the in class code. hw1.cpp contains the first homework assignment, hw2a.cpp and hw2b.cpp are the second homework assignments, etc. I will announce in class and/or by email when a new assignment has been posted. Note that if you are logged into the CS or one of the x** machines, you can copy the in class code from the directory ~jkinne/public_html/cs440-f2012/code/.

Software Setup

All assignments must compile and run on the CS server and x** machines in room A-015. Each assignment template file has instructions for what command to issue to compile the program. In brief, for non-OpenGL programs, you compile by running "g++ program.cpp -lm -o program" and then run the program by executing "./program". For OpenGL programs, you compile by running "g++ program.cpp -lm -lglut -lGLU -o program". Libraries and header files for OpenGL are already installed on CS and x** systems.

Logging into CS: If you want to keep your files on the CS server and login remotely to do your programming, you need an SSH client. A free client for Windows is Putty. A remote sftp client is WinSCP. If you have Linux, Unix, or Mac OS X then ssh and sftp access are already included - just open a terminal and type "ssh username@cs.indstate.edu" or "sftp username@cs.indstate.edu".

Emacs If you are programming by logging into the CS server, you have some choice about what text editor to use. Those installed on the CS server include: vi, pico, nano, emacs. I use emacs because it does auto-indenting and other things. If you decide to use emacs, you'll need to learn the shortcuts for things. The ones I use most are the following (search online for others).

Windows: You can also compile programs on Windows if you will work mostly from your personal computer. But when you turn the program in, it must compile and run on the cs and x** systems. To setup a build environment for OpenGL on Windows, (1) download and install Microsoft Visual C++ 2010 Express, (2) download freeglut MSVC Package, (3) follow the instructions in readme.txt in the freeglut zip file to build compile 32 bit programs.

Images: It is relatively easy to use images in OpenGL that are in the "raw" format. That means that you basically just have the RGB values for each pixel, all in a row, with no extra information in the file. I use the free GIMP" image editing software to create my images. It has similar functionality to Adobe Photoshop.

OpenGL Examples

See bubbles.cpp for a program that uses some of the OpenGL features we will use. See also simple.cpp for a very simple OpenGL program. You can find many more OpenGL examples by searching online.

C/C++ Examples

See prime.cpp as an example of a fairly basic C++ program. See matrix.cpp as an example of a fairly basic C++ program that uses classes/objects. You should probably be able to understand and modify the prime example pretty easily. The matrix example is a little more complicated because you need to understand how classes work in C++.

First Exam

Format: In class, no computer, you get one sheet (front and back) of whatever you want (handwritten notes or printed off a computer).

Topics: Everything we've done so far. This includes...

Exam, types of questions.

For T/F, give a sentence or two explaining why. For "give code", unless otherwise specified, you can assume glut has already been initialized. For "what does code do", you are asked to draw a picture and describe what the scene would look like. For analysis/word problem, you need to show your work.

Sample Exam:

  1. T/F. The basic ray tracing algorithm takes O(n log(n)) time to execute when there are n pixels and O(n) objects.

  2. T/F. Under Blinn-Phong shading, an object that is very reflective corresponds to using a normal vector that is close to 90 degrees.

  3. T/F. The following matrix is a translation matrix. Assume multiplying the position vector on the right of this matrix.

     1 1 0 0 
     0 1 1 0 
     0 0 1 0
     0 0 0 1
    
  4. Give code. Give OpenGL code to draw a 10x10 array of 1x1 cubes - so they would look like a wall that is 10 units wide and 10 units tall. You can place the "wall" wherever you like (but not edge on).

  5. Give code. Give OpenGL code to draw an octagon, anywhere on the screen (but not edge on).

  6. What does code do. Assume an orthographic projection, where the projection is through z=3 from x=-10 to 10 and y=-10 to 10. Assume the computer screen is also square. Assume the drawing is wireframe, single color.

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      
      glBegin(GL_QUADS);
      glVertex3f(0.0f, 0.0f, 0.0f);
      glVertex3f(5.0f, 0.0f, 0.0f);
      glVertex3f(5.0f, 5.0f, 0.0f);
      glVertex3f(0.0f, 5.0f, 0.0f);
    
      glScale3f(2.0f, 2.0f, 2.0f);
      glVertex3f(-2.0f, -2.0f, -2.0f);
      glVertex3f(3.0f, -2.0f, -2.0f);
      glVertex3f(3.0f, 3.0f, -2.0f);
      glVertex3f(-2.0f, 3.0f, -2.0f);
    
      glEnd();
    
  7. What does code do. Assume a perspective projection, where the eye is at (0, 0, 5), the viewing projection screen is at z=3, and the vertical field of view is 60 degrees total. Assume the computer screen has a 16:9 aspect ratio. Assume the drawing is drawn in grayscale with realistic-ish shading.

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
    
      glutSolidSphere(1.0f, 20, 20);  
    
      glPushMatrix();
      glTranslate3f(0.0f, 2.0f, 0.0f);
      glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
      glutSolidSphere(1.0f, 20, 20);
      glPopMatrix();
    
      glTranslate3f(0.0f,0.0f, -10.0f);
      glutSolidSphere(10.0f, 20, 20);
    
  8. Analysis/word problem. Give a 4x4 transformation matrix that would (in this order): (1) move the object to the right 2 and down 3, (2) make the object 4 times as large, and (3) rotate the object by 45 degrees about the vector (0.0, 1.0, 0.0)

  9. Analysis/word problem. For the "What does code do" problem with perspective projection, assume your computer screen is 1920x1080. Use the basic ray tracing algorithm to determine if the pixel at (850, 550) intersects the first sphere drawn. You can leave your answer as an expression if it is too complicated to evaluate on paper.