CPE 471 Final Project

David Pan
Spring 2009

City Builder Simulation


Description


The City Builder simulation is a simple program that allows the user to add environment objects to a small world. The world is a small 4 block radius with a street intersection at the origin. In the third quadrant, there is a grassy area designated to be a city park. In the fourth quadrant, there is a city block already populated with buildings. The first and second quadrant are empty and free for the user to to modify.

One of the most notable features is the implementation of sun light and time simulation. The sun will orbit around the small world and the world will shift from day to night lighting based on its position. This is done by dynamically shifting the rgb value of the sky dome from a light blue to a dark blue based on the sun's current position. Once the sun passes the world horizon, the light source is disabled.

The skydome is a hemisphere that encompasses the top of the world. A sky texture is mapped to the inside of the sky dome to simulate a real sky and the shifting rgb values further assist in transitioning from day to night. When night time comes around, simple stars are drawn at random, predetermined vertices of the skydome.

Building models were made in OpenGl primarily using OpenGl polygons. One difficulty I encounted was using glutSolidCube as my building block. Unfortunately, glut primitives do not generate texture coordinates so I implemented my own code to render a cube and apply texture coordinates. There are 6 pre-made building models available each with their own unique texture.

Another feature of the project is the ability to add more buildings to the environment. The user can select objects to add to the environment via a menu. By selecting an object, the user will enter "Builder Mode" where camera rotations will be disabled. The requested object will intially be drawn at the middle of the intersection (aka the origin of the world). From there, the user can choose a transform from the menu to translate or rotate the object. After the user is satisfied with his placement, he must select "Set Building" from the menu to save the position of the object. While it is currently possible to select more than one building at a time, this may have unwanted results as all transforms applied after will affect ALL buildings that have not been set.

Controls
W - move forward
A - strafe left
S - move backward
D - strafe right
P - pause sun
Left click and hold - rotate camera
Right click to open menu
Select building to enter "Builder Mode"
Note* Camera rotations are disabled in builder mode
After selecting an object, user will be positioned in overhead view. Object will start at origin. Select transforms to perform on object. Select set buildings to lock objects at current location.
Note* You can select more than one building at a time but all translation after will apply to ALL buildings until set buildings is selected

 Screenshots

Starting the Day


Sun is up


Menu Options

The city at night


Resources:

http://www.vterrain.org
  -  excellent resource for environment rendering info, sky and atmosphere articles were particularly helpful when i was trying to figure out a good way to render my sky dome

http://www.cgtextures.com
 - excellent free textures resource.  got almost all my textures from here.




Source File

Source Package