Final Graphics Project

CSC 471 Wood

Project by: Christopher Pauley

Introduction:

Robots styled after Google's Android mascot walk around the 3D world. When they bump into objects such as tree trunks and other androids,

they change direction and head in a different path.

 

Goals:

Controls:

W A S D to move camera

Mouse to rotate camera

p to toggle phong shading. Default is off.

 

Details:

 

Hierarchical Modelling: The androids and trees were created using hierarchical models. The androids were built with quartics (spheres, cylinders).

The trees were built with solid cubes, scaled to form a tree-like structure.

 

Animation:

In order to make the world animate, I ran everything using the timer feature in one of the earlier labs. Using rotations and hierarchical animations,

I was able to make an android model that walked around convincingly. The arms of each android rotate independently of each other. The legs also move opposite of each other as well, in an up-and-down motion. The androids were animated by pushing and popping each shape of the android as its own matrix. The matrix at the root of the stack is the rotation matrix.

 

Movement:

Movement was probably the part I spent the most time on with this project. My goal was to make the androids move in the direction they were facing. At first, I thought that I could just rotate the androids and translate them forward, but this created a problem since all of the androids were moving around the center position of the world, or rotating while moving in a straight line, which wasn't quite what I wanted. Everyone I talked to suggested that I try implementing a look vector based method of movement. I used the current position of the android along with its current angle to get the current direction of the look vector. At each step, I compute a new vector and move the android along it.

 

new x = current_x + sin(angle);

new z = current_z + cos(angle);

look = current_position - new;

 

I also had to convert the radians to degrees, as the rotations were happening too fast. Getting the entire movement

process to work required me to strip out the time and just use the keyboard to move one android around.

 

Lighting/Shading

 

The application supports smooth and phong shading. I used the default normals (gl_normal) for each shape as the normals for the lighting shaders. The implementations

are based on Program 3 and the dynamic lighting lab.

 

Collision Detection:

Collision detection was the final piece of the puzzle. I borrowed a sphere-based collision algorithm from online and modified it to fit my needs. I wasn't planning to have realistic physics with my collision, I just wanted to see some sort of interactivity happen.

 

Implementing android collision detection was surprisingly simple. In the collision algorithm, I check to see if any android has collided with the other when their spheres intersect. If so, I change its direction and make a slight adjustment to the angle so that the movement is a bit less predictable. When complete, the androids almot looked like bumper cars bumping into each other, which was amusing to see.

 

Collision with the trees, however, was not. My first attempt was to include an array of tree structs similar to what I had with the androids, but when I initialized the structs in Initialize, weird and inexplicable graphics glitches happened despte the fact that I didn't touch the drawing code at all.

 

 

 

Everything seemed to converge into a single triangular point when trying to introduce the trees this way. I gave up on this and implemented an alternate solution by passing in the positions I had aready calculated for the trees into the collision function. This worked well, though it does limit any sort of tree randomization.

 

Final results:

1. No Phong shading

2. Phong shading

 

 

References:

 

Collision Algorithm

http://www.gamedev.net/page/resources/_/technical/math-and-physics/simple-bounding-sphere-collision-detection-r1234

 

Enjoy!