glExplorerTGA

Ian Marsh
Final Project, CSE 167

A Short Description from the readme

GLExplorerTGA is a program that renders terrain from values taken from a heightfield represented as a bitmap. Using traditional "w,a,s,d" controls and mouselook, the user can explore the virtual environment complete with trees, brush, water, and a beautiful blue sky. Trees and brush positions are calculated randomly upon initialization of the program. Trees and brush sprites are crosshatched while the underwater plants are "billboarded" (always rotated to face the viewer). To mask parts of these sprites I used Targa files and loaded them with a function taken from http://nehe.gamedev.net/ which I modified slightly. These elements are only drawn within a specified radius of the viewer to increase performance. Farther away objects are made transparent so that they blend into the background and do not pop into view when the viewer approaches them. There is primitive collision detection which prevents you from walking through the trees, but its a little buggy and doesn't work 100% of the time. The terrain itself is textured with a black and white ground texture which is blended with vertex colors derived from a color map (the color of the vertex is mapped using its X and Y position), resulting in subtle smooth changes in color. The use of fog makes the environment seem much more realistic and gives a slight performance boost. The water in drawn as a number of subdivided polygons in the xz plane (the plane was subdivided to prevent fog from shading the enire surface of the water the same amount) and uses blending to make it appear transparent. The scene has a single light source and uses phong lighting to shade the terrain. When the view dips below the water line the properties of the light source are changed, and the viewer's speed is reduced (how much depends on whether the player is completely submerged). Pulling the whole scene together is the skybox which surrounds it. Moving in the xz plane with the viewer it appears to be drawn at inifinity. The skybox was drawn without lighting and the env_mode was set to clamp at the edges so that no seams were visible. Enough of me talking about it, try it for yourself (must have glut libraries installed)!

Screenshots of GLExplorerTGA in action