Assignments

CpSc 465, Principles of Computer Graphics

Section 1, Friday, 6:00-8:45pm


Assignment 11

due Friday, May 19

Update Assignment 10 to use appropriate material properties for the car: Note that you will need to define normals for the windshields if you have not done so already.

Use the texture mapping techique demonstrated in texture.c to apply a checkerboard pattern to the back windshield of the car.


Assignment 10

due Friday, May 12

Update Assignment 9 to include two lights:
  1. a white light, placed along the 45-degree line from (0, 0, 0) to (1, 1, 1), initially turned on
  2. a colored light, placed on the positive z-axis, initially turned off.
Implement the following controls:
Keystroke Action
1 toggle Light 1 on / off
2 toggle Light 2 on / off
r make Light 2 red
g make Light 2 green
b make Light 2 blue
w make Light 2 white

The lights should remain fixed while the model rotates in response to dragging the mouse.


Assignment 9

due Friday, May 5

Update Assignment 8 to use the "Virtual Trackball" interaction technique described in class.

If you didn't finish Assignment 8, choose another GLUT shape (e.g., cube, sphere, torus, etc.) The shape can be rendered as a wireframe if necessary.

If you didn't attend class and can't get the notes, you can either try searching the web for virtual trackball, or you can read Chapter 12 of the red book and try to figure out pick lists. If you choose the latter option, draw several overlapping shapes to choose from.


Assignment 8

due Friday, April 28

Draw a car using filled polygons:

Hint: use the following functions:
Color Function
Red and Yellow glutSolidCube()
Blue and Green glBegin(GL_POLYGON)
Black glutSolidTorus()

Another hint: use Polygon Mode GL_LINE and enable back-face culling to check that the front- and back-facing polygons have been specified in the correct order.

Download assignment8.exe and run it to experiment with the various options. Drag with the left mouse button to rotate the model, and use the right-click context menu to change rendering options.

Note that you do not need to implement either the rotation or the context menu. (We will implement the rotation next week.)

By the way -- feel free to draw a nicer car.


Assignment 7

due Friday, April 21

assignment7.c draws a line and a clip rectangle. The handles can be used to move them both:

Add code to clip the line to the rectangle, using either of the Cohen-Sutherland or Liang-Barsky algorithms.

Assignment 6

due Friday, April 14

Download assignment6.c and run it. Click the mouse to select two Chunky PixelsTM:

Your assignment is to draw a Chunky LineTM between the Chunky PixelsTM by implementing the draw_line() function. Use Bresenham's algorithm, but note that you will need to generalize in order to handle cases where the slope is not less than 1 and (x0, y0) is not lower than and to the left of (x1, y1).

Assignment 5

due Friday, March 17

Download a copy of assignment5.c and compile and run it. The program shows a simple model, rendered from two different viewpoints:

The right pane shows a perspective projection of the model given the camera position (x, y, z) and view frustum defined by (left, right, bottom, top, near, far), as shown in the code. You can adjust the view with the following keys:

Keystroke Action
z/Z Zoom the camera in/out
n/N Move the near clip plane in the negative/positive Z direction
f/F Move the far clip plane in the negative/positive z direction
x/X Increase/decrease the width of the near clip plane
y/Y Increase/decrease the height of the near clip plane
q Quit

The left pane shows the same scene, from a different angle. Its viewing parameters are fixed.

Your assignment is to render the camera and viewing frustum used by the view in the right pane into the scene in the left pane:

You may download a compiled executable for experimentation here

Assignment 4

due Friday, March 10

Modify Assignment 3 (preferably your solution with interactive transformations, not the original assignment3.c) to draw four different views from four different camera locations:

Camera at (0, 0, 3) Camera at (2, 2, 2)
Perspective
Projection
Parallel
Projection


Assignment 3

due Friday, March 3

Modify assignment3.c to respond the following keystrokes:

Keystroke Action
r Select rotation as the current transformation
s Select scaling as the current transformation
t Select translation as the current transformation
x As appropriate for the currently selected transformation:
  • Translate 0.1 unit in the x direction
  • Increase the scaling factor in the x direction by 0.1
  • Rotate about the x axis by π/5 radians
X As appropriate for the currently selected transformation:
  • Translate 0.1 unit in the -x direction
  • Decrease the scaling factor in the x direction by 0.1
  • Rotate about the x axis by -π/5 radians
y As appropriate for the currently selected transformation:
  • Translate 0.1 unit in the y direction
  • Increase the scaling factor in the y direction by 0.1
  • Rotate about the y axis by π/5 radians
Y As appropriate for the currently selected transformation:
  • Translate 0.1 unit in the -y direction
  • Decrease the scaling factor in the y direction by 0.1
  • Rotate about the y axis by -π/5 radians
z As appropriate for the currently selected transformation:
  • Translate 0.1 unit in the in the z direction
  • Increase the scaling factor in the z direction by 0.1
  • Rotate about the z axis by π/5 radians
Z As appropriate for the currently selected transformation:
  • Translate 0.1 unit in the -z direction
  • Decrease the scaling factor in the z direction by 0.1
  • Rotate about the z axis by -π/5 radians
i Return the cube to its original position

Rotation should be about the x, y, and z axes, not about the center of the cube. (Unless, of course, the cube is currently centered at the origin.)

Transformations should be cumulative. For example, switching to rotation from scaling should not reset the scaling factors to 1.


Assignment 2

due Friday, February 24

Download a copy of assignment2.c and compile and run it. The program shows the standard (x, y, z) coordinate axes in gray. The white lines represent three normal vectors: Each of the vectors has a colored "handle" by which you can drag it to change its position.
Currently, the vectors are independent: dragging one does not affect the others. Your assignment is to modify the program so that the vectors form an orthonormal basis set. This will cause all three vectors to move together as a unit when any of the handles is dragged.

Visually, the vectors will appear to form a second set of coordinate axes which moves separately from the original one. In fact, that is the purpose of an orthonormal basis (at least in computer graphics): to define a new coordinate frame. If you are having trouble visualizing the results, download assignment2.exe to see the results.


Assignment 1

due Friday, February 17

Start with Example 1-2 from the OpenGL Programming Guide:
  1. Add mouse click and motion callbacks to print the mouse coordinates to standard output.
  2. Observe the output. What do you notice about mouse coordinates?
  3. Modify the callbacks to convert mouse coordinates to the same coordinate system as the square.
  4. Modify the callbacks to do hit-testing, allowing the user to "pick up" the square and drag it around the screen.
  5. Maximize the window, then grab the square and drag it rapidly back and forth. What do you observe?
  6. Add double-buffering to your program. Does that fix the problem?
  7. Add menu items to toggle double-buffering on and off and to quit the program.
  8. Suggest ways to do hit-testing if the shape were a triangle instead of a square.

Assignment 0

due Friday, February 10

Your assignment for this week is to set up your programming environment so that you can start writing code next week. You will need to be able to compile code written with GLUT, the GL Utility Toolkit.

You can download pre-compiled DLLs for use with Visual C++ from Nate Robins's GLUT for Win32 page. If you are using Dev-C++, you can download a GLUT DevPack from Nigel Stewart's page

At some point, you will need the reference documentation for the GLUT API.

To test that your programming environment is set up correctly, type in Example 1-2 from Chapter 1 of the OpenGL Programming Guide and get it running. When you have finished, submit the assignment using the procedure described in the Syllabus and confirm that you get a return receipt.

Note: there is a difference between the HTML and PDF versions of the OpenGL Programming Guide. The PDF version uses GLUT, while the HTML version uses the older "aux" library. The libraries are similar, but code written for one will not compile and run without some translation between the two APIs.