In the previous chapter, you created a framework to render OpenGL in 3D. At the very end of that chapter, we added a block of code that rendered a cube. In this chapter, you will learn how to create 3D objects in Open GL, first using code, and then using a 3D modeling program. In this chapter, we will cover the following:
Until now, we have been working only in a two-dimensional space. This means that we were able create game objects with height and width. This works well because our computer screens are also two-dimensional. As we move into three-dimensional space, we need the ability to add another dimension to our objects: depth. As computer screens don't physically have a third dimension in which to display pixels, this is all accomplished by mathematical wizardry!
In Chapter 8, Expanding Your Horizons we discussed several methods that have been used (and are still used) to simulate three-dimensions in a two-dimensional display:
These three techniques have one major shortcoming: they all required the programmer to write code that makes each visual effect work. For example, the programmer has to make sure that objects that are receding from the player are constantly scaled down so that they become increasingly smaller.
In a true 3D game, the only thing that the programmer has to worry about is placing each object at the right coordinates in 3D space. A special graphics card takes care of performing all of the calculations to take care of size, speed, and parallax. This frees the programmer up from doing these calculations, but it actually adds a whole new set of requirements related to positing and rotating objects in three-dimensional space.
18.118.28.200