CompSci 344
Spring 2015
Computer Graphics

Flight Simulator

Over the last two decades, 3D virtual worlds have advanced from primitive to, at least visually, very advanced and complex.

History of flight simulators, including the premier company for many decades and noting that you can fly through Google Earth. Also, refer to one of the first uses of generated terrain in the movies .

More motivation coming soon...

Specification

Create a program that displays a smoothly shaded terrain which the user can over fly interactively. The camera should (by default) automatically move forward at a fixed speed; the user should be able to control bank and tilt through the arrow keys.

Your input terrain will be a gray-scale image interpreted as a height field (darker is lower, brighter is higher). These input files could in principle be drawn using any 2D paint program and saved as a image file. The skeleton code supports the interpretation and rendering of these images.

These meshes given by these images, however, are too "coarse" to provide an interesting flying experience. We have to scale up the images (i.e. zoom in) siginificantly in order to provide enough terrain to fly over, and at that resolution each face of the initial height map appears as a wide, flat expanse at our flying scale. Instead, we'll use these initial height maps as a style/seed for our terrain, and add detail by refining the mesh via a quad subdivision algorithm (midpoint displacement). The end result is a fractal landscape. The second link actually provides a very good guide for implementation.

Part of this algorithm involves height perturbation by random amounts. For this we expect you to use Perlin noise, an implementation of which has been included in the framework library.

The rest of the project requirements (and also the extra credit) improve the simulator experience and/or performance.

  1. Refine each quad of the initial mesh using the diamond-square algorithm, using Perlin noise for the random perturbations. Note that this is also a data structure problem, as you'll need to choose/design a good data structure to maintain the mesh.
  2. Approximate normals for each face and vertex of the resulting [refined] mesh. Newell's method gives a way to approximate normals for not-necessarily-planar polygons. The faces in your mesh will fall into this category unless you triangulate (triangles are always planar), so use Newell's method. For vertex normals, the common technique is to normalize the sum of normals from adjoining faces.
  3. Implement level of detail: only perform refinement on render finer terrain close to the camera. For some examples, see Wikipedia, Google Images, and here.
  4. Surround the scene with a skybox. The user shouldn't be allowed to fly outside of the skybox (in other words, do collision detection). This is easier to program if you make your skybox axis aligned. You can use techniques (e.g. a plane for water) to connect the terrain to the skybox. A sample skybox texture has been provided on Github.
  5. Color/texture the terrain by height. Feel free to use fog or other techniques to make distant terrain less distinct.
  6. Implement the following user controls:
    1. change the flight direction (bank and tilt)
    2. speed up and slow down flight speed
    3. switch between a smooth shaded, flat shaded, and wireframe terrain
    4. display/hide/wireframe the skybox
    5. reset the scene viewpoint
    6. quit the program
    As usual, please list these controls in your README, along with any others you decide to add.

Extra Credit

Like the previous assignments, please explicitly state any extra credit you attempt/complete in your README. Some ideas:

Resources