Game Development Reference
In-Depth Information
Chapter 10
OpenGL ES: Going 3D
Super Jumper worked out rather well with the 2D OpenGL ES rendering engine. Now it's time to
go full 3D. We actually already worked in a 3D space when we defined our view frustum and the
vertices of our sprites. In the latter case, the z coordinate of each vertex was simply set to 0 by
default. The difference from 2D rendering really isn't all that big:
ï?®
Vertices have not only x and y coordinates, but also a z coordinate.
ï?®
Instead of an orthographic projection, a perspective projection is used.
Objects further away from the camera appear smaller.
ï?®
Transformations, such as rotations, translations, and scales, have more
degrees of freedom in 3D. Instead of just moving the vertices in the x-y
plane, we can now move them around freely on all three axes.
ï?®
We can define a camera with an arbitrary position and orientation in
3D space.
ï?®
The order in which we render the triangles of our objects is now important.
Objects further away from the camera must be overlapped by objects that
are closer to the camera.
The best thing is that we have already laid the groundwork for all of this in our framework. To go
3D, we just need to adjust a couple of classes slightly.
Before We Begin
As in previous chapters, we'll write a couple of examples in this chapter. We'll follow the same
route as before by having a starter activity showing a list of examples. We'll reuse the entire
framework created over the previous three chapters, including the GLGame , GLScreen , Texture ,
and Vertices classes.
The starter activity of this chapter is called GL3DBasicsStarter . We can reuse the code of the
GLBasicsStarter activity from Chapter 7 and just change the package name for the example
classes that we are going to run to com.badlogic.androidgames.gl3d . We also have to add each
493
 
Search WWH ::




Custom Search