Assignment 3 To-Do List

In the Oct. 29 lab, we went through the requirements of Assignment 3. The main discussion points are summarized below.

I highly recommend that you familiarize yourself with the provided code (md2.h), which includes a function that parses an MD2 file and fills in the data structures for vertices, triangles, texture coordinates, and so on.

Weekend programming task:

  • Once you're comfortable with the code, take a few minutes to write a Render() function in the MD2 class, to draw the model in wireframe mode. This should only require a few lines of code, but will be very valuable to have next week when we get into lighting.

Overall, your tasks for the assignment are:

  1. Add functions to the MD2 class.
    • void Render(int mode) -- draw the mesh using OpenGL commands, and supporting at least three modes: WIRE, FLAT, and SMOOTH. For bonus marks, you can support a fourth mode, TEXTURED.
    • void ComputeNormals() -- the FLAT and SMOOTH rendering modes require per-triangle and per-vertex normals, respectively, so you'll need to write a function to compute these. Techniques for computing normals have been discussed in lecture and lab.
    • You can use enum or #define to define the viewing modes, eg:
      typedef enum { WIRE, FLAT, SMOOTH } renderMode_t;
  2. Create some lights in your GL initialization (eg. InitGL()). Flat- and smooth-shading will not work without lights. This will be covered in lab next week.
  3. Add user controls for affine transformations.
    • Trackball rotation via the mouse.
    • Translation and scaling (both uniform and non-uniform) via GUI widgets (eg. sliders) or mouse interaction.
  4. Add controls for changing the camera. The function to use here is gluLookAt(eye, look_at, up), which takes parameters that specify the camera/eye position, look-at position, and the up direction (x-y-z coordinates for each). See the figure below for an illustration.
  • The default camera position is at the origin, looking down the negative z axis, with the y axis as the up direction.
  1. Toggle projection matrix between parallel (orthographic) and perspective.
    • You should know how to use glOrtho() by now.
    • For perspective projections, the provided GL command is glFrustum(). However, there is a related function in the GLU library that is easier to use, called gluPerspective(fov, aspect, zNear, zFar). See the figure below for an illustration of the parameters to this function.
      Illustration of gluPerspective parameters
    • You have to be careful of how gluLookAt() and your projections work together. The details are a bit tough to post, so email me if you missed lab or run into problems.

Note that these are only suggestions, you're free to implement the solution as you see fit. For example, you may decide to create a more versatile mesh class/data structure (i.e. half-edge) from the loaded model.