Final Project readme Jeff Hwang Purpose: My initial idea was to model a complicated car, and maybe have it drive around. However, as my project progressed, I ended up creating a simpler car as it was quite difficult and time consuming to model. My second goal was to have the car drive around simulating that of a real car. However, this did not turn out as I could not figure out how to get the car to accelerate and turn similar to a real car. I then came up with the idea, to use the cars going in straight lines down a street to create the game “frogger”. The purpose of the game is to control the frog, which starts on one side, and have him walk to the other side without hitting any cars. This worked out much better as I implemented controls to have the frog move, put in four cars that would move at different rates along the road, and added street and building textures. I also added 6 light posts along the street in order to show lighting on the environment. Controls: General Controls Case ‘c’ Enables/disables culling of back faces Case ‘w’ Enables/disables wireframe mode Case ‘R’ Increase the rate of movement Case ‘r’ Decreases the rate of movement Case ‘z’ Zoom in Case ‘x’ Zoom out Case ‘ESC’ Exit Game Lighting Controls Case ‘1’ Enable/disable Light 1 Case ‘2’ Enable/disable Light 2 Case ‘3’ Enable/disable Light 3 Case ‘4’ Enable/disable Light 4 Case ‘5’ Enable/disable Light 5 Case ‘6’ Enable/disable Light 6 Frog Controls Case ‘i’ Moves the frog one lane towards destination side of street Case ‘k’ Moves the frog one lane towards starting side of street Case ‘l’ Moves the frog up along the street Case ‘j’ Moves the frog down along the street Case ‘m’ Restart game after winning Techniques: Modeling the car All 4 cars used came from the same model. I originally planned to model something more complicated, then decided on a police car. Basically, it is just put together use many quad strips, quads, and a few triangles. The tires were created with Professor Buss’ cylinder function with endcaps. When I first started, I figured it would be simple as my design only required a few quad strips and triangles, or even fewer polygons. However, I soon ran into the problem of z-fighting when I rotated around the car. I realized this was because of the many t-junctions I created. Therefore, I added more and more quads/quad strips, so the edges would line up and there would be no t-junctions. Before I knew it, the model was getting pretty complicated and it became very tedious getting every single t-junction out of the model. Figuring out the points of each quad was not that tough, but was just tedious and time consuming. I also added some textures to the cars, but only the front and rear side of each car. The model took a lot longer than expected. Lighting the car Lighting the car was probably another one of the tougher tasks of my project. Since my car was pretty simple, many of the normals were straightforward and did not need to be calculated. However, there were some more complicated ones, so I wrote a function to calculate the normal given 3 points of the quad. It will get 2 vectors from these 3 points, and then find the cross product of the two vectors. Then it normalizes by dividing by the magnitude of the new vector, giving us the normal in unit length. A problem I ran into came with quad strips. Since 2 quads will share points, if they had different normals I wasn’t sure how to specify the normals for the points. For example, if I drew a box with quad strips, minus 2 sides, then the side quad would have normal pointing straight out, and the top quad would have normals pointing straight up. Therefore, I wasn’t sure how to specify the normal of the 2 shared points. Thus I ended up breaking some quad strips up into quads to solve this problem. Generating the environment To generate the roads and buildings, I basically, drew quads, and applied texture maps of buildings and roads I found. This was pretty straight forward, the tough part was getting the texture maps. I added some lamp points, which were creating with cylinders and spheres on the top to the side of the road. I added 6 lights to the environment, 4 white, 1 red, and one blue, where each of the lamp points were. I also used linear attenuation, in order to make the scene seem a bit darker. I did this because I was striving for a night time scene with only some light posts providing light. Usually in real life they aren’t that bright and the street still seems somewhat dark. Frogger The frog was created using simple spheres. The frog would move simply pressing keys, which would translate it along the x or z axis. The 4 cars I assigned a variable which determined their speed, and it would continuously increment so that the car would keep moving along the road by itself. I had it check so that once the car hit a certain distance, it would start from the beginning again. To check to see if a frog and a car collided, first I had variable keep track of which lane the frog was in. The frog could either be on the sidewalk or one of the 4 lanes, and each lane only had one car, so if the frog was in a certain lane I only had to check if it was colliding with a specific car. Next I had a variable keep track of where along the sidewalk or lane the frog would. I knew the length of each car (which are the same), and I knew the very front point of each car, which is given by the variable that increments it along the road. Therefore, I just need to take the frog position along the road, and check if the car is within a certain range, and if it is, that means the car is colliding with the frog. If this happens, have to frog go back to the starting point. If you happen to reach the other side of the sidewalk without colliding with a car, the frog will turn around and hold up a sign, which says “YOU WIN, ‘m’ to restart”. That is basically all there is to the game. Other notes There were several other things I hoped on implementing, but due to time restraints, I just couldn’t add them all in. These include • sirens for the police car • headlights for the cars • transparency for the light posts (which I tried adding but had some problems with) • all sides of the textured buildings • random car speeds for each lane each time the car restarts • more cars per lane The main reason I chose this project is because I enjoy the modeling side of graphics design. However, it seems much too complicated doing it in only opengl, and hope to learn the use of 3rd party programs to do this.