SimUrban

Populating and Rendering an Urban Environment

 

System Requirements

1GHz CPU with SSE capability (P3/AMD XP or above)

Direct X 9 Class video card (Geforce FX 5600/ Radeon 9500 or above)

128MB RAM

Windows 2000/XP

 

Introduction

This program and the accompanying paper were completed in 2004 as my final year project at university.

 

The project uses flocking and crowd modelling algorithms to simulate the behaviour of pedestrians and birds moving through a complex urban environment. Efficient collision detection algorithms were developed to prevent collisions between flocking entities and the environment. Pedestrians also avoid traffic (and each other) as they navigate around the city.

 

In order to render the environment efficiently, an original software-based occlusion culling solution was developed for this project. This uses a software rasteriser to render a Z-buffer based occlusion map, which is used to perform occlusion queries to determine the visibility of meshes in a scene. The system uses Intel’s SSE instructions to accelerate fill-rate. As the report demonstrates, this software solution was found to be faster than hardware approaches to occlusion culling for this type of environment.

 

The project uses a Cg vertex shader to perform character skinning in hardware, and fragment (pixel) shaders are used in order to apply phong shading to the paint of vehicles.

 

For more details of the technical implementation, please read the accompanying paper.

 

Program Instructions

To run the program, open the binary directory and run SimUrban.exe

 

Keys

Escape - menu

F1 – Toggles camera type – can be first person or orbital

F5 – Toggles occlusion culling

F6 – Toggles occlusion map display (may be slow with some drivers/chipsets)

T – clears the onscreen text buffer

 

Movement

Cursor keys – move forwards, backwards, left, right

 

Orbital camera mode:

Mouse Wheel or A/Z – adjust the camera’s radius

Hold down the right mouse button and move the mouse to rotate the camera

 

First person camera mode:

            Use the mouse to rotate - Mouselook is always on

 

Main Menu

Select Quit to exit the program, or Options to view the options menu

 

Options Menu

This menu makes it possible to toggle a number of rendering options. More options are available by init.xml file (see below)

 

XML Files

This section describes how to use the various XML configuration files to configure the SimUrban program. It is not necessary to modify these parameters for normal use of the program, but doing so greatly increases the flexibility. Various examples are used in this section to illustrate the usage of parameters.

 

Init.xml

 

Init.xml is used to specify a large number of options for the SimUrban program without the necessity of a rebuild.

 

Note: To give an idea of the distance measures used in this section, 1000 units is the width of a 1×1 tile model, such as a house or road tile. 

 

The root element is <init>:

<init>

 

The root contains elements for specifying the filenames of a number of resource files, which must be defined for the program to work. The filename of the city’s configuration filename is specified at this point, in the <cityConfig> element. The filenames for the vertex skinning shader, the cursor image and the default font are also specified:

 

      <defaultFont imageFilename="images\text\impactVerdana16.bmp" dataFilename="images\text\impactVerdana16.dat"/>

      <cursor filename="images\crosshair.bmp"/>

      <skybox filename="images\sky\sky*.bmp"/>

      <groundTexture filename="images\ground.bmp"/>

      <cityConfig filename="config files\city_cubeville.xml"/>

      <skinShader filename="shaders\skin.vp" language="ARBASM"/>

Cars can be configured by quantity and by the B3D model which is used. The car paint shader can be defined at this point, although this is optional; without it, the application will use simple OpenGL lighting to render the cars.

 

      <cars number="40">

            <model filename="models\car.b3d"/>

            <shader filename="shaders\carpaint" language="ARBASM"/>

      </cars>

     

The light parameters for the default light are specified in the <light> element. These are used by both OpenGL and fragment shader lighting.

 

      <light>

            <direction x="1" y="2" z="0.7"/>

            <ambient r="0.2" g="0.2" b="0.2" a="1.0"/>

            <diffuse r="0.7" g="0.7" b="0.7" a="1.0"/>

            <specular r="1.0" g="1.0" b="1.0" a="1.0"/>

      </light>

 

 

The <flock> element describes the two types of flocking entities. This contains the quantities of both birds and pedestrians, and is also used to set flocking parameters. Any number of pedestrian models can be specified in the <pedestrian> element, and these will be selected at random when new pedestrians are created. The <bird> element currently supports only one model type.

 

      <flock>

            <pedestrians number="200">

                  <flockgrid sizeX="22000.0" sizeZ="22000.0"

originX="5000.0" originZ="5000.0"/>

                  <flockParams      alignment="0.2"

cohesion="0.1"

separation="0.6"

separationDist="600.0"

neighbourDist="600.0" collisionRange="600.0"/>

                  <model filename="models\womanSuit.b3d" speed="120.0"/>

                  <model filename="models\manSuit.b3d" speed="130.0"/>

            </pedestrians>

 

            <birds number="150" floor="400.0" ceiling="3000.0">

                  <flockgrid sizeX="31000.0" sizeZ="31000.0"

originX="1000.0" originZ="1000.0"/>

                  <flockParams      alignment="0.6"

cohesion="1.0"

separation="1.0"

separationDist="600.0"

neighbourDist="1000.0" collisionRange="1000.0"/>

                  <model filename="models\bird.b3d" speed="1000.0"/>

            </birds>

      </flock>

 

Rendering preferences are set using the <appOptions> element. If these are not set then default values will be used instead.

      <appOptions renderBuildings="1"

                        renderBirds="0"

                        renderCars="1"

                        renderPedestrians="1"

                        displayFPS="1"

                        antialiasing="1"

                        fog="1"

                        nearClip="50.0"

                        farClip="30000.0"

                        showOcclusionMap="0"

                        occlusionCulling="1"/>

                       

 

Camera parameters for both the supported camera types specified in the <cameras> element.

      <cameras>

            <orbitalCamera    hemisphere="1" radius="500.0" minRadius="0.0"

maxRadius="10000.0"

                                    x="10000.0" y="200.0" z="10000.0"/>

            <fpsCamera x="10000" y="200" z="10000"/>

      </cameras>

 

           

The city configuration file

 

The city configuration file is used to specify the position of all roads and buildings in a city. The <city> root element is used to specify the tile set file which describes the city’s various tile models.

 

<city tileset="config files\tileset.xml">

 

Roads are specified using <road> elements. These must also define the endpoints of the roads in grid coordinates, using in the x1, x2, y1 and y2 attributes. Diagonal roads will cause an error at load-time. It is legal to specify roads that overlap. If two roads intersect then an appropriate junction or corner will be formed to connect them.

 

<road x1="6" y1="6" x2="6" y2="19" />

 

Buildings, parks and other tile models are specified with the <tile> element. This specifies a tile’s position offset in grid coordinates and its rotation, which ranges from 0 to 3, in increments of 90°. The tile’s model name is set in the model attribute.

 

<tile model="house1" x=" 7" y=" 7" rotation="1" />

 

 

The tile set configuration file

 

The tile set configuration file specifies the geometry that is used by a tile set. In the <tileset> root element, the b3d file containing the tile set’s geometry is specified.

 

<tileset model="models\city.b3d">

The <tilemodel> element contains name and dimensions of a tile model. The name should correspond to the name of a mesh in the B3D file. Similarly, the dimensions should correspond to the dimensions of the tile’s mesh.

 

<tilemodel name="road" width="1" height="1">

            <walkrestrictions type="walkmap" walkmap="wm_road.bmp"/>

      </tilemodel>

 

An optional <walkrestrictions> element can be specified in the <tilemodel> element to specify restrictions used by pedestrians. The type attribute defines the type of walk restrictions, which can be either “walkmap”, “never” or “always”. If the type is given as “walkmap” then the location of a walkmap filename must me specified in an additional “walkmap” attribute. “never” makes the tile is inaccessible; “always” means there are no walk restrictions in the tile. If the walkRestrictions element is not specified, then a type of “always” is assumed.