Virtual Town Tour
CSC 471 Final Project, Spring 2006
By: Clyde Sy
Professor: Zoë J. Wood

Description

For this projected, I created a 3-Dimensional town. Within the walls of this town there are houses, trees, a pool, and a maze. The user can navigate around this town in a first-person-view by using the keyboard and mouse. My goal is to create a town that looks real, and this is done by using texture mapping and collision detection.

Major Concepts

The major concepts that this project emphasized on are collision detetion, hierarchical modelling, and texture mapping. All of the objects that you find in this 3D town are a hierarchical model that built from the openGL primitives. For example, the house is built by using a single unit cube that's scaled to appropriate size and rotate and translate to an appropriate location to made the house's walls and roof. Once the house hierarchical model is completed, it can be place at any location in the town.

To make everything around the town look realistic, I applied texture mapping to all the objects that I created. An important thing to do texture mapping is to try to match the size of your object to the size of the texture image as close as possible. Applying a small texture to a large object would make the texture image looks very stretchy and fuzzy. To keep the details of the texture on my ground for example, I created a small 2x2 pixels piece of plane and place a bunch of them to each other to create a larger plane. This way I get the affect a single large plane with the detail of the texture preserved.

Another thing that makes a 3D environment realistic is collision detection. That means the camera shouldn't be able to go straight through an y object that you place in your 3D world. To put a restriction so that your camera doesn't go through a object you have set up a method for collision detection. Once the collision is detected, you must then decide what to do to avoid having your camera colliding with a particular object.

Collision Detection

My method of collision is to create four planes boundary for every object that I have. For each plane I calculated a normal using the vertices on those planes. Figure 1 shows the nornals for a wall.


Figure 1: Example of Normals for a wall

To calculate a normal of each of the face I used the vertices at the corner to compute for two vectors. Once you have two vectors (these two vectors are on the same plane), the normal is calculated by taking the cross product on the two vectors. An example of normal calculation is shown on figure 2. Note that the right hand rule on the cross product. If the cross product was reverse the normal would face in the opposite direction (opposite sign). You should also normalize the normal vector for each face.


Figure 2: Normal Calculation

To detect collision, I set use the center vertex of my camera and calculate with a vector with a point on the one of the plane. With this vector I can compute the distance from the center of my camera to the plane by computing the dot product with the plane's normal. If the distance is less than the radius of my camera's sphere then there is a collision. Figure 3 shows how this distance is computed.


Figure 3: Computing the distance from the camera a plane

The handling of a collision is dependent on your specific calculation. For this project, I simply restrict the movement in the same the direction if the collision is detected.

Usage

The navigation is done with the mouse and the keyboard. Below list these commands.

Note that movements are restricted on the x-z plane.

SnapShots

Here are some of the snapshots from the town. Note that some the shots are taken from a bird-eye-view, this view is disable in the actual program (the program only allow the user to navigate on the ground).


Snapshot 1


Snapshot 2



Snapshot 3


Snapshot 4

References

Mayang's Free Texture Library: http://www.mayang.com/textures/
The Elder Scrolls IV: Oblivion