Again we uncovered a lot of mysteries in the world of game programming. We talked a little bit about vectors in 3D, which turned out to be as simple to use as their 2D counterparts. The general theme: we just add a z-coordinate! We also took a look at lighting in OpenGL ES. With the helper classes we wrote to represent materials and light sources, it is pretty simple to set up the lighting in a scene. For better performance and fewer graphical artifacts we also implemented simple mipmapping as part of our Texture class. We also explored implementing simple Euler and look-at cameras with very little code and a little help from the Matrix class. Since creating 3D meshes by hand in code is tedious, we also looked at one of the most simple and popular 3D file formats: Wavefront OBJ. We revisited our simple physics model and transferred it to the realm of 3D, which turned out to be as simple as creating 3D vectors. The last point on our agenda was to figure out how to cope with bounding shapes and object representation in 3D. Given our modest needs we arrived at very simple solutions for both problems, which are very similar or even identical to those we used in 2D.

While there is a lot more to 3D programming than I can present here, you now have a pretty good idea about what is needed to write a 3D game. The big realization is that there is indeed not a lot of difference between a 2D game and a 3D game (up to a certain degree of complexity, of course). We don't have to be afraid of 3D anymore! In Chapter 12 we'll use our new knowledge to write the final game of this book: Droid Invaders!


0 0

Post a comment