Assignment 6: Students’ Revenge (building and reading a C++ program)

by Mike Gleicher on October 7, 2014

This assignment is due on Wednesday, October 15th, and will be turned in via Moodle.

Objectives

The goal of this assignment is to make sure that you are ready for the first project. That you have the mechanics in place (access to the compiler and library), can get partially written programs from us, and read through them to understand them. You’ll also get a little exposure to OpenGL and C++. It’s funny, but we spend a lot of time teaching you to write programs: and much less time teaching you to read them (which is a great way to learn to write them).

The Idea

Normally, Adam, the TA, grades your assignment. This time, we’re turning the tables! I’ve assigned him with writing a graphics program, it’s your job to check it.

You’ll need to download his program and build it. This means you’ll need to have a computer with Visual Studio 2013, FlTk, GLM, and GLEW all set up. Getting this ready is a good idea: next week, we’ll assign project one, so you’ll want to have these things in place.

The CSL Windows labs are already set up with all the appropriate software. However, if you want to work on your own machine, you’ll need to get Visual Studio (see this). You’ll also need to get FlTk, GLM and GLEW (see this). We recommend installing them the same way that CSL installs them on the lab computers (which you will get by downloading the ZIP file Adam has prepared). Part of this assignment is to make sure you have all this in place.

Once you’re set, you can download Adam’s program and make sure that you can compile and run it. You might also want to try running the debugger on it (maybe stepping through things, or setting breakpoints). You are free to tinker with it (make changes to see how things work).

What we’ll ask you to turn in is a screen shot (to make sure you can make screen shots of programs), and to answer a few questions about the code (that you should be able to figure out easily by reading the code, the documentation, or by experimenting. Note that we are not asking you to change his program – you do not turn in any code. The questions ask you to describe how you would change his program.

The Specifics

Adam’s program (as a ZIP file) is HERE. Notice how he has “turned in” the correct set of files: the source code, project file, and workspace file required to build the program – and nothing else (except for a README).

NOTE: The code itself has very few comments. It would probably score a 0 if we were grading comments. This was done on purpose. It might be useful to comment the code yourself as you understand what happens in each section.

Adam’s assignment was to give you a program where you could experiment with Euler Angles for a variety of different objects, using sliders to change the rotations. He was supposed to draw the objects using a bunch of different OpenGL mechanisms.

Notice that he puts his name and a description at the top of every file, and give proper attribution for code that he appropriates.

If everything is set up correctly on your machine, you should be able to double click on the workspace file to open it in Visual Studio, hit the “Run” button (F5), and see the program work. (remember, when you turn in projects you need to have this be true!)

Experiment with the program and see what it does.

Now, answer the following questions. Note: you will turn in a text document with your answers, and a single screen shot.

  1. In class, we commented how with Euler Angles, you can have very different angles but get things that are close to each other in terms of the results. (so getting from one place to another is hard – a phenomenon called gimball lock). Give 2 sets of angles (3 numbers) that give the same rotations (or very similar ones), but are far apart – for the type of Euler Angles used in Adam’s program. Confirm that these two sets of angles do indeed look the same in Adam’s program. Take a screen shot of one of those configurations. (note: your answer is 2 sets of 3 numbers – plus the screenshot). Avoid answers where the difference is on a single axis (e.g. +/- 180 degrees on any axis is the same rotation with very far away numbers).
  2. In class, we mentioned how physicists like to use ZXZ Euler angles (rather than the XYZ ones used in Adam’s program). What lines of code would you need to change in order to switch to ZXZ Euler angles and how would you change them?
  3. The slider callback for the rotation angles has a function call to “damageMe”. What does this do?
  4. The cube  has a red side. How would you change it to blue?
  5. Describe what you would add to the program in order to change the size of the triangle?
  6. What is the significance of the calls to glPushMatrix() and glPopMatrix() when drawing the duck? What happems when some (or all) of those calls are removed?
  7. Notice how the different objects don’t know where they get drawn – they just assume that the coordinate system was set up correctly. What assumptions do they make about the coordinate system they are being drawn in?
  8. Suppose you wanted to draw all objects at the same time, next to each other. How would you change the program?

What to turn in

You will turn in a single screen shot of just the window that Adam’s program runs in, and a text file with the answers to the questions. Please put the answers to the questions into the moodle type-in box for turning in the assignment. (we recommend you write your answer in some editor, and copy it into the textbox on moodle – that way, you have a copy of it in case moodle messes up).

Grading

This assignment will be graded check / no check. You will get a check if you make a good try at the questions (even if you don’t get them all). However, it’s worth trying to figure them out: you will need to figure out similar kinds of questions when you get the project framework code next week.

{ 1 trackback }

Previous post:

Next post: