3501 #3: Transforms

Assignment 3: Transforms

Due date: Wednesday, Oct 6

This assignment is to get some practice with geometric transforms. It will build on the cannon model you made for assignment 2. If you are not happy with your cannon, you can borrow one from someone else in the class.

The purpose of this assignment is to get the transformations right, not to get a perfect cannon model, so if your cannon barrel has holes in it or other defects this is only an aesthetic problem.

Part 1: setup

Part 2: Animating the cannon

Give the cannon the ability to move around, rotate, and elevate the barrel. Create a location vector for the cannon, plus orientation parameters (angles). Have a single world transformation matrix that governs the movement of the cannon body (derived from the parameters using ISROT) and a second matrix that is applied to the barrel, rotating the barrel through the angle of elevation and translating the barrel away from the center of the cannon, if necessary.

Assign a set of keys to allow moving, rotating, and aiming the cannon interactively. I suggest IJKM for moving and ASDF for rotating and aiming.

Part 3: Firing the cannon

Now you will add the ability to fire the cannon. You will need to make a model for the shell, but you don't have to spend any great effort in doing so: a box is sufficient.

Shells should originate from the cannon at the press of a key, and be fired in the direction the barrel is pointing. Note that you can't use the cannon transformation as a root transformation for the shells (otherwise they are somehow "guided missiles" and will rotate as the cannon barrel rotates, which is not what is intended). Instead, use the cannon parameters to get a starting position and direction for the shell, and have it move forward as time passes. (Store a position vector for the shell and create a transformation matrix for the shell based on the current position whenever you need to draw it.) Remove the shell when it has travelled far enough.

Next, build a "helix shot pattern" shell. This shell will use the same base position as the previous type, but its trajectory will include an "orbit" element: a translation plus rotation off the central trajectory. The angle of rotation of the orbit should be computed using GameTime so that it changes as the shot moves; overall, the shell will follow a helical path. Use ISROT to get the world transformation for the shell.

If you are interested, you can quite easily make a multi-shell pattern by having several shells with different orbital angles and distances.

Part 4: bonus

For a bonus of up to +10%, add a third type of shells to the cannon. This type should fire in a ballistic arc (i.e., it should be subject to gravity). You will need to track the shell's velocity and modify it each timestep by -g*dt for a gravitational acceleration g.

Handing it in

Hand in your project using WebCT. The easiest thing to do is to create a single zipped folder and submit that, rather than all the individual files. It might take a while to upload, so be prepared to take a little break while the files are in transit.

Reference art

The simple cannon of the classic game Sabotage: