CPE 471

Soccer in the City

Overview

I've always dreamed of playing soccer in the middle of the city, just imagine the city landscape in the background as you play the most popular game in the world. This is what my project gives you, enjoy yourself.

Controls:

"Mouse": Pitch and Yaw controls for the camera while in camera mode.

"WASD": Strafe and Zoom controls for the camera while in camera mode.

"IJKL": Player movement.

"Space Bar": Kick ball, hold down the key to increase kick power.

"esc": Exit the program.

Implementation Details:

Lighting

The Blinn-Phong lighting model is used here. The light source is kept relatively dim and out of the way. With the city scape surrounding, I did not find extensive lighting necessary to my scene.

The lighting effect can be seen on the player.

Collision Detection

The player, the player right foot, ball, and goal posts all have the ability to do collision detection. A bounding sphere is calculated based on the dimensions of the object and given a center point and a radius. Using a simple sphere collision detection formula, collisions are detected and acted upon.

Texturing

The ball is textured with a soccer texture. The plane is textured with a soccer field texture.

Cube Map

Cube map used for city sky box, which provides the illusion of a 3d city background behind the scenery.

Shot Physics:

When the ball is released a vector, let's call it the shot vector, is created in the direction that was aimed. This vector is calculated from the direction the player was moving, because we want the ball to move in the direction the player kicked. The magnitude of the shot vector is based on an arbitrary kick power which can be incremented by holding down the spacebar. There is a cutoff to maximum power. This vector is applied to the balls position causing it to translate across the plane in the direction aimed.

During each render call the shot vector is added to the current position of the ball. The ball stops as the power is decreased from the rolling, acting like a deceleration. The player must then walk to the ball to interact with it at its new position. If the ball is scored in the goal, an exclamation point the color of the goal post is rendered above it.

As the ball is translated it is rotated along the z axis to simulate the backspin that occurs when dribbling or shooting a soccer ball.

Player

The player is hierarchically modeled using the multi-shape obj dummy provided in previous labs. The player's arms and legs hierarchically move with the walking motion. The kicking motion also has a hierarchical movement of the right leg.

Resources:

Obj's

Player Movement

Cube Map Tutorial

Dr. Zoe Wood, CPE 471 Labs and Projects