Project 4 - 3D World
CS354: Computer Graphics


Due 7:00 pm Fri June 2
EXTENSION - Due 7pm Mon June 5. Extra credit if you get it in by the original due date.


Your assignment in this project is to write an OpenGL program in which the the user can explore a virtual world. The examples I will give in class will have to do with making an undersea environment, but you are welcome to implement any world you like.

You may work with a partner on this project.

The technical requirements are:

Projects which solidly meet these requirements will get a B. I expect that most people will want to go beyond these basic requirements.

Getting started

Here is some code which brings up the holodeck, with perspective projection. Your job is to turn it into a 3D world, possibly undersea, which the user can navigate around. The files readBMP.c and readBMP.h are the same as from Project 0.
  • Makefile
  • sea.c
  • readBMP.c
  • readBMP.h
  • grid.bmp

    Navigation

    The holodeck code has global variables for the camera position, the camera direction as a vector in the x-y plane (assuming it can't tilt), and the camera direction as a rotation around the camera's y-axis (the world's z-axis). I found that having both representations of the camera direction was useful; it's up to you how you handle it. However you store the camera state, remember that you need to get a viewing transformation corresponding to that state into the MODELVIEW matrix at the beginning of every frame.

    Since it is very easy to get lost in 3D worlds, your program should have a RESET button which brings the camera back to the starting position.

    Have your program print out a message when it starts up, describing all the button and mouse controls. This is a big help to the user.

    Texture mapping

    The holodeck code reads in the file grid.bmp which it uses as a texture. You'll want to find and use textures more appropriate to your world; for instance, the image at the top of this page uses an image of sand for the ocean floor. You can find lots of texture images by vigorous Web surfing.

    Remember that texture images for OpenGL have to have dimensions which are a power of two, eg. 128x256.

    Modeling

    Think about what shapes are easy to construct as parametric surfaces. Spheres, cones, and cylinders are similar to the torus. A vertical ribbon above a horizontal Bezier curve is easy and can be used in lots of ways. To remind yourself how to define normals for a parametric surface, you can review these lecture notes for the torus example we did in class.

    Modeling a fish with two Bezier patches and some polygons would be perfectly acceptable. You could texture-map an eye onto it. Here is some code which draws one Bezier surface which could be the front of a fish. Bezier surfaces are drawn in OpenGL with evaluators: see pages 528-542 in the OpenGL book.

    A 3D fractal plant, or piece of coral, would be quite appropriate. Use an L-system. You can use glutSolidCylinder and glutSolidSphere, etc.

    Some shells are not too hard to define mathematically. Here is some code to recursively make a scallop.

    Reading in models you find on the Web is also fine for this part of the assignment. You can use the code to read .obj files from the last assignment.

    If you use the .obj reading code, or any other code you got from somewhere else, acknowledge the source and the author of the code (including URL, if appropriate) in your README file. You should also acknowledge the source of models, textures, and anything else that goes into your project that you find on the Web or elsewhere.

    Reshape

    Notice what happens to your object when you reshape the window. Fix it!

    Fog

    The gradual fade of the floor into the background in the image above is done using the fog feature of OpenGL. Fog is an optional feature of your world, but try it! It's easy and it's great for oceans.
    Remember to make the color of the background the same as the color of the fog, using glClearColor.

    Infinite plane

    Since the holodeck floor is a single square, it is easy to fly off the end once you start navigating. It is much nicer instead to give the user the illusion of moving in an infinite space. You can do this by drawing the part of the infinite floor that lies underneath the camera, wherever the camera happens to be.

    Notice that this is not the same as moving the floor along with the camera, which gives no illusion of motion at all.

    Again, this feature is optional, but it's not hard and combined with fog, it gives a very compelling undersea effect.

    What to turn in

    Turn in all the source files of your program, the executable, the Makefile, any input data files, and a plain text documentation file called README, using the handin program, to /proj4. If you work with a partner, only turn in the project once but make sure BOTH YOUR NAMES are at the top of the README file.

    Thanks!