Computer Graphics Assignment 1

Document Sample
Computer Graphics Assignment 1 Powered By Docstoc
					Computer Graphics Assignment 1

Due date : 18 April, 2007
NB: date put back from original date (4 April, 2007)

Marks 20% of unit total

1. General Guidelines

The assignment component of this unit is worth 40% of the total overall assessment.
This is the first of two assignments.

The content of the assignments must not be copied/reproduced directly from a
book, journal, internet or any other source without due acknowledgement of the
original reference.

Please read the "Plagiarism" section from the Unit Information for GCO3817.

2. OpenGL Application
This assignment tests your ability to write an OpenGL graphics program using polygon
meshes, animation, 3D projection, lighting and events (both user input and timing
events). For this assignment each student will be producing a graphical representation of
a small building with two rooms separated by a hallway. Each student will be allocated
different shaped rooms, so for example you may be told to use a room with 10 sides at
one end and an 8 sided room at the other end of the connecting hallway. Each room will
have a roof that is pyramid shaped (ie has the appropriate number of sides to connect to
the walls and raises to a single point above the centre of the room) and a flat floor. The
connecting hallway will have a flat floor and roof. The connecting hallway takes the
shape of one individual wall at each room and is tapered to fit appropriately. The user
must be able to travel from one room through the connecting hallway and into the other
room when inside the building. The centre line of the two rooms and the hallway
corresponds to the x axis when viewed from above.

Lighting

There are to be two lighting conditions built into the program, the first is normal lighting
which has sufficient ambient light to be able to clearly see the building details. The
second is a spotlight mode in which a only a narrow beam of light is used, with initially
15 degrees of total spread for the spotlight looking in the current viewing direction from
the viewers position. The ambient light should be reduced to a very low level of
(0.1,0.1,0.1) for the spotlight mode.

       the 'N' or 'n' key changes to normal lighting mode
       the 'S' or 's' key changes to the spotlight mode
       the '+' key will increase the spotlight spread by one degree each time it is hit until
       a maximum of 45 degrees
       the '-' key will decrease the spotlight spread by one degree until a minimum of 5
       degrees
The spotlight mode requires that the building walls, floor and roof are created using a
polygon mesh which gives reasonably lighting results, remember that the OpenGL
lighting calculations are only done at vertices (so one polygon for each wall etc is not
likely to work).

Specification

Each student has been given an individual specification here, you must follow this
specification exactly. Each room will be different colours on the inside to the outside. The
size of each room and the length of the connecting hallway is also specified. The centre
of the hallway should be positioned at the origin,ie co-ordinate (0,0,0).

If your student id number does not appear on the list please contact me via email as
soon as possible. Also here are a few building clues, for example creating multi-sided
polygons.

The initial viewing position for this program should be at coordinate (0, 0, 100), that is on
the z axis looking directly at the origin. You should initially use a perspective projection
with the near cutoff plane at 0.5 units and the far cutoff plane at 300 units. Arrange for
the building to be approximately 75% of the size of the window from the initial viewing
position. The initial window size should be 650 pixels square.

Navigation

The program is to have two navigation "modes" of operation, the first placing the viewer
outside the building and the second when the viewer is inside the building. When
outside the building the viewer MUST not be able to pass through the walls to the inside
and vica versa. So if inside must stay inside, if outside must stay outside. Only when the
'O' or 'I' keys are hit can we change from the inside to the outside. Therefore when using
the navigation keys detailed below you must first ascertain whether the move is allowed
before doing that move. If illegal (ie would pass through a wall or floor etc) the viewing
position must not change.

Navigation in the program allows the viewer to change the viewing position using the
keys specified:

       'U' or 'u' move one unit in the positive y direction
       'D' or 'd' move one unit in the negative y direction
       'R' or 'r' move one unit in the positive x direction
       'L' or 'l' move one unit in the negative x direction
       'F' or 'f' move one unit in the negative z direction
       'B' or 'b' move one unit in the positive z direction
       'O' or 'o' moves outside the building to the initial viewing position ie (0,0,100)
       'I' or 'i' moves inside the building to the centre of the first room looking toward the
       origin
       Left arrow key rotates the viewing direction by 15 degrees to the left (ie anti-
       clockwise viewed from above)
       Right arrow key rotates the viewing direction by 15 degrees to the right (ie
       clockwise)
       Up arrow key moves the viewers position forward one unit in the current viewing
       direction
       Down arrow key moves the viewers position backward one unit in the viewing
       direction

Other interface operations that you must include are:

       the 'W' or 'w' key to toggle between wireframe mode and normal mode
       the 'P' or 'p' key to toggle from perspective view to orthogonal view
       the 'Q' or 'q' key will quit the program.

Automatic Tour
Finally the last requirement for this assignment is to create an automatic tour of the
building. The tour operation is specified below:

       Begins when the viewer is inside the building (only when inside) and the user
       hits the 'T' or 't' key
       The viewing position will move to the centre of room 1 looking horizontally
       towards the hallway
       The view will then rotate through 360 degrees on the same spot
       Then the viewer will move smoothly from room 1 through the hallway and into
       room 2
       When in the centre of room 2 will rotate through 540 degrees (ie a full circle plus
       180 degrees to look back towards the hallway)
       Proceed again back to the centre of room 1 through the hallway
       Tour is then completed

The whole tour will take 30 seconds to complete and will be done without any
intervention from the user.

3. Submission:

The assignment must be submitted electronically via Webface. You only need to submit
the source code which must be named building.cpp and any header file used (ie
building.h), and optionally a Readme file for any comments that you consider necessary
for the compilation, linking and running of your submission. You could include the
system under which you developed the program ie Borland, Visual C or djgpp.

4. Assessment
Your submission will be assessed according to its compliance with the specification,
constraining the viewer so not passing through walls, floor etc and of course the correct
interface operations.
Although the source code will be looked at briefly this is not a programming subject so
no great weight will be given to the coding standard including comments etc. However
you should incorporate a decent layout and enough comments that I can follow the code
easily.