Project 4 - Virtual World
ECS 175 - Computer Graphics
Due Mon June 7 at 11:30pm

Instructions

Your program should allow the user to explore a virtual world. The techniques you should master are changing the camera position (flying around), texture mapping, controling lighting and modeling with curved surfaces.

You may work on this project in teams of two. The more you get done the more fun it is to play with, so a partner might be a good idea. We will take off five points for a project with a partner, since the goal is for you to get more done as a team, not to make it easier to produce a minimally passing project. Hopefully five points is not so much that is will discourage people from working together.

Your environment can be whatever you like. A good environment to work with is outer space, since no one is sure what lies out there. Feel free to put whatever you want to in your world - aliens, crystalline entities, planets surrounded by clouds of fog, whatever. Just make sure your program uses (at least!) the required techniques, which are:

  • Perspective projection
  • Illusion of an infinite space
  • Fly forwards and backwards, change pitch and heading (yaw), under mouse and keyboard control.
  • Texture mapping on a curved surface.

    Using evaluators to get Bezier surfaces with normals and texture coordinates is fine.

    As usual, implementing the required features well will get you about a B, and to get an A you'll need to make an intersting world by building interesting models, finding appropriate textures and implementing the whole thing neatly, or try out some other technical features (display lists, special lighting effects which we will talk about next week), or both.

    Here's some steps you might want to follow to make a basic outer space project.

    Step 1: Get an object and start flying around it

    Draw an object - say a crude space station - and implement the camera motions to let the user fly around it. Use perspective projection (a good field of view angle is about 25 degrees). One reasonable interface is to let mouse motion control the forwards and backwards motion and use the arrow keys to change the pitch and heading. Here are some suggestions on one way to get a flying interface with heading and pitch. The TA has prepared a handout with an easier interface which might be good to start with, but will not be given full credit; check back later for another way to do the full-credit interface. A reset button to get the user back to the original position is essential - it is surprisingly easy to get lost in space.

    Step 2: Make a background simulating an infinite universe

    One way to do this is to draw in two phases, one for the background and another for the foreground, with different PROJECTION and MODELVIEW matrices in each phase. For the background, draw a big icosohedron surrounding the camera, with colored faces for now. Use orthographic projection, and only allow the rotations which change heading and pitch change the background MODELVIEW matrix, not the forward and backwards motion. For the foreground, use the PROJECTION and MODELVIEW matrices from Step 1. Draw the background with writing to the Z-buffer turned off, then turn on writing to the Z-buffer before drawing the foreground.

    Step 3: Texture map something flat

    To get started with texture mapping, try to texture map a photograph of a planet onto a disk in the background of your scene.

    First you'll have to find a planet. One good place to look is JPL. Find a nice looking photo of a circular planet or moon (not too big - a few megabytes is plenty), get an image, and convert it to a .bmp file (one way to do this is with xv). Here is a little program that reads and displays a .bmp files on the Linux machines in 67 Kemper. (This replaces the .ppm reading code from the first project; we needed a more space-efficient image-reading system).

    You'll need to draw a round polygon with many sides to texture map the planet onto. Be sure to place this polygon inside the big background icosohedron. Try drawing the disk first, without texture mapping, to make sure you can see it, and then try and get the texture onto it.

    Here's some more hints on the texture mapping process iteself.

    At this point it might be a good idea to texture map some stars onto the background.

    Step 4: Build a texture-mapped planet

    A planet, for our purposes, is a sphere with a texture map. The easiest way to model a sphere if you intend to use a texture map is to write a function that has one parameter for lattitude and one for longitude, and draws the sphere as a mesh of quads; this is a kind of generalized cylinder, where the radius changes at each height. Remember to specify a normal vector for every vertex.

    You can search the Web for cylindrical or hemi-spherical planet texture maps appropriate for spheres; Here are a lot of cylindrical textures maps. To be a little more other-worldly, you could consider modifying the colors with xv.

    You should have BOTH lighting and texture mapping working simultaneously on your planet.

    Step 6: Add optional features

    To make your project interesting and fun, add optional features. We will grade your project based on technical sophistication, imagination, and attractivness. Some ideas:
  • Put metallic texture maps on your space station.
  • Add motion - make your space station rotate around its own axis, add a sputnik revolving around it, add blinking lights, etc. Please DO NOT implement the solar system example from the OpenGL book - it will be worth zero points.
  • Add lighted windows to your station, or even better a glowing window through which we can look in and see the pilot. Emissive light will be useful here.
  • Draw the `windshield' and control panel of your ship around the edges of the frame. Extra points if the control panel actually does anything!
  • Surprise me!

    Step 7: Document your work

    Since every program is going to be different, document well! Make your program print out a usage message as soon as it starts up, explaining what all the keys and mouse buttons are supposed to do. You might mention interesting features of your world you want the grader to notice. Write a README file describing a) how to compile your program, and b) important design decisions you made.

    Step 8: Turn in your assignment

    Hand in all the source, the executable, the textures (as .bmp files, or whatever you are using), and the README for your project, using handin.