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.
- 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.
- 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.
-
Implement level of detail:
only
perform refinement onrender finer terrain close to the camera. For some examples, see Wikipedia, Google Images, and here. - 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.
- Color/texture the terrain by height. Feel free to use fog or other techniques to make distant terrain less distinct.
-
Implement the following user controls:
- change the flight direction (bank and tilt)
- speed up and slow down flight speed
- switch between a smooth shaded, flat shaded, and wireframe terrain
- display/hide/wireframe the skybox
- reset the scene viewpoint
- quit the program
Extra Credit
Like the previous assignments, please explicitly state any extra credit you attempt/complete in your README. Some ideas:
- Additional movement schemes, e.g. up and down in addition to forward.
- Model the flying object and provide a third person camera.
- Collision detection against the terrain. Again, bounding boxes are a classic technique for this.
- Projecting the flying object's shadow onto the terrain (shadow mapping).
- In addition to level of detail, only do calculations for the visible patches of terrain. This has a similar flavor to the varieties of culling done by OpenGL (face culling, view frustum culling) but is not the same -- we're avoiding work before we even hand vertices to OpenGL.
- Move a sun through the sky (from dawn to dusk) and show how lighting changes in the scene. You might do this by animating the texture or slowly fading between two skyboxes. You'll want to adjust the ambient lighting to make it darker at night.
- Add moving clouds: create a plane inside the skybox, let it have transparent edges and a texture with transparent clouds and animate the texture coordinates in a given direction.
Resources
- Tutorial on camera motion
- True geographical data from USGS in common image formats
- Virtual Terrain Project