CSE3313 - Computer Graphics
assessment

CSE3313
Computer Graphics

Assignment 2
3D Graphics — Howard's World

Due Date: Friday, 12 October 2007 before 11.59pm.

Marks: 20% of your total mark for this unit.


 

This assignment is designed to give you some experience in using OpenGL, this time using 3D graphics.

For this assignment you are required to write a simple game using OpenGL and GLUT:

The island nation of Kangaroonia is in crisis! Global warming is increasing at an alarming rate, accelerated by government's lack of action to reduce carbon dioxide (CO2) emissions. The government of Kangaroonia is one of the worst offenders, with the highest CO2 output per capita in the world.

Fed up with government inaction and hubris, a group of concerned citizens (GCC) has been forced into political action, with a plan to replace all the dirty coal generating power stations with clean solar technology. The have created a biofuel "freedom vehicle" that contains all the equipment necessary to decommission dirty coal power stations and replace them with clean solar technology.

In this role-playing game you play the role of the GCC, who must visit and decommission all the coal-fired power stations before the island becomes submerged by rising water levels. The actions of the GCC vehicle is watched on high from the parliamentary tower, located in the hills at the northeast corner of the island.

You should use OpenGL to remove hidden surfaces. Use whatever shading model you think appropriate. You are welcome to play with models, lighting and textures if you want (and credit will be given for their use), but it is quite possible to get full marks with just simple lighting and smooth (Gouraud) shading (so your images will not look as detailed as the ones shown on this page).

Program Specifications

The game operates within the desert land of Kangaroonia— a three-dimensional fractal landscape that you can create using the mid-point displacement algorithm. The algorithm is simple and allows the easy generation of simple landscapes. Here is a description of the basic description of the algorithm:

1. Start with a square in the x-z plane.

2. Find the mid-point (centre) of the current square.

3. Shift the 5 points by a random amount in the y axis and create 4 new sub-squares.

4. If not finished, for each of the 4 new squares: go to step 2.

You can implement this surface generation algorithm as a recursive function. You will want to scale the size of the random displacement in proportion to the area of the square being subdivided (this gives more "natural" looking mountains). Your landscape needs to be big enough to make the game playable, but not so complex as to slow OpenGL down (hint: triangulate your grid and use triangle strips). You might wish to colour vertices according to their height. You should set the level of subdivision for the landscape and square scaling factor as command line options which default to reasonable values. Thus the user of the program can select a less detailed/faster or more detailed/slower landscape depending on their OpenGL hardware performance. The scaling factor controls the "ruggedness" of the landscape.

If you are interested in more information about generating fractal landscapes, you might find these references helpful:

Ebert, DS, et al.: 1994, Texturing and Modeling: A Procedural Approach, Academic Press, London.

Musgrave, FK, Klob, CE and Mace, RS: 1989, The synthesis and rendering of eroded fractal terrains. SIGGRAPH '89 Conference Proceedings (Boston, Massachusetts, 31 July–4August). In Computer Graphics 23(3) pp. 41-50.

Carpenter, LC: 1980, Computer Rendering of Fractal Curves and Surfaces. (Seattle, Washington). In 7th Annual conference on Computer Graphics and Interactive Techniques (SIGGRAPH '80) ACM SIGGRAPH, Seattle, Washington, p. 109.

The GCC freedom vehicle can be represented by a box (if you have time you could try for a better looking vehicle, but this is optional). The parliamentary building can be represented by a cube and the power stations by a cylinder (or cube and cylinder– use your imagination. The parliamentary building and power stations are randomly placed over the landscape, but try to keep buildings a fair distance apart.

Remember that the GCC vehicle and the buildings must be placed on the landscape so you'll need to know the height of the landscape at any given point in order to place objects correctly (this also applies to driving the vehicle).

Game Play

The game begins at the edge of Kangaroonia. The user (driving the GCC vehicle) uses the mouse or keyboard commands to navigate and move around the landscape in their freedom vehicle. If the user sees a power station, they should head towards it. When they get very close to the power station (use a bounding radius to test) they can decommission the power station. The more power stations decommissions, the lower the rate of sea-level rise. Each game has a time limit of 60 seconds to decommission all the power stations and prevent flooding. Set your land size, maximum vehicle speed, power station size, etc. to reasonable values to make the game fun to play (i.e. requires a bit of skill to win!). The game will be more interesting if you force the GCC vehicle to slow down before it can approach a building. There is no need to do collision detection on the buildings. Note that due to flooding parts of the island may become inaccessible to the GCC vehicle. The vehicle cannot travel underwater, but can move over land that is underwater up to a depth of half the vehicle's height.

Viewports

Your program should display the game world simultaneously from four viewports in one window. The first viewport contains an orthographic projection of the entire scene looking down the y axis. This view should show the land, the GCC vehicle and the location of all the power stations and the parliamentary building. You might need to use simple icon shapes/colours and text so each element can be distinguished from so far away.

The second viewport should display the scene from the GCC vehicle's perspective (on top and slightly behind the vehicle), using a perspective projection (first person view).

The third viewport should display the scene from the top of the parliamentary building. The building camera is always pointing at the GCC vehicle.

The forth viewport should display the keyboard commands, messages (such as "decommissioning power station #3", "water too deep!", "you win", etc.) and the current status. It should also display the remaining time before the island submerges. This should be updated in real time. You should keep a running total of the number of games won and lost.

The first three viewports should be labeled, e.g. "Orthographic View", "GCC Car View", "Parliament View".

You should use OpenGL to remove hidden surfaces. Use whatever shading model you think appropriate. There is no need to use lighting or texturing (so your output will not look as "realistic" as the images shown here). You are welcome to play with models, lighting and textures if you want (and credit will be given for their use), but it is quite possible to get full marks without these features.

 

Keyboard Interaction

Your program should support the following commands:

Command Action
q quit the program
, or
left arrow
turn the GCC vehicle to the left of its current heading.
. or
right arrow
turn the GCC vehicle to the right of its current heading.
a increase GCC vehicle velocity (up to a maximum speed)
s decrease GCC vehicle velocity (down to 0, or you could allow the vehicle to reverse if necessary)
R restart — reset the game and begin again. Clear all scores.
z zoom out Parliamentary cam.
Z zoom in Parliamentary cam.
d Decommission current power station (if in range)

 

Bonus Section

For 3 bonus marks, create a Federal Police vehicle, released from the parliamentary building that chases the GCC vehicle. If the police vehicle catches up with the GCC vehicle the occupants of the GCC vehicle are arrested and you loose the game. You might also like to give the GCC vehicle better dynamics (e.g. slows down going up hills, speeds up going down them). Bonus marks will also be awarded for correct use of OpenGL lighting and/or texturing. A maximum of 3 bonus marks can be awarded for these additions.

Programming Tips:

   

 

Submission

You need to submit your program for assessment in electronic form using the submit program. See the submit page for details on how to submit assignments. You should submit a directory which contains the following:

  1. source code (.c, .c++ and .h files — see the declaration that must be included with all source files)
  2. a Makefile with the correct targets
  3. a README file that describes how to run the program and a brief description of how you coded your solution (no more than 1 A4 page of text)
  4. Any input files required to run your program successfully.

Do not submit any other files. Do not submit code that depends on any other libraries apart from GLUT, GLU and OpenGL. Submission that fail to make will not achieve a passing mark, nor will programs that do not run.

Marking Criteria

The following criteria will be used when assessing your submission:

Warning: students often get carried away with this assignment, making improvements and adding extra features beyond what is specified here. While you are encouraged to experiment and add extra features, this is not necessary to receive full marks for the assignment. Plan your time carefully and avoid spending too much extra time on this assignment at the expense of other subjects or your coursework.


This material is part of the CSE3313 Computer Graphics course.
Copyright © Jon McCormack, 2007.  All rights reserved. Any resemblance to actual events is purely intentional.

Last Modified: July 18, 2007