Game Development Reference
In-Depth Information
Figure 12-8.
The ship model in Wings3D (ship.obj) and its texture (ship.png, 256×256 pixels)
The crucial thing is that the ship in Figure
12-8
has roughly the “radius� outlined in the previous
section. We don't need to scale anything or transform sizes and positions from one coordinate
system to the other. The ship's model is defined with the same units as its bounding sphere!
Figure
12-9
shows the invader model and its texture.
Figure 12-9.
The invader model (invader.obj) and its texture (invader.png, 256×256 pixels)
The invader model follows the same principles as the ship model. We have one OBJ file storing
the vertex positions, texture coordinates, normals and faces, and a texture image.
The shield blocks and shots are modeled as cubes and are stored in the files
shield.obj
and
shot.obj
. Although they have texture coordinates assigned, we don't actually use texture
mapping when rendering them. We just draw them as (translucent) objects with a specific color
(blue in the case of the shield blocks, yellow for the shots).
Finally, we have our explosions (see Figure
12-3
again). How do we model those? We don't. We
do what we did in 2D and simply draw a rectangle with a proper z position in our 3D world, texture
mapping it with a frame from a texture image containing an explosion animation. It's the same
principle we used for the animated objects in Super Jumper. The only difference is that we draw
the rectangle at a z position less than 0 (wherever the exploding object is located). We can even
abuse the
SpriteBatcher
class to do this. Hurray for OpenGL ES! Figure
12-10
shows the texture.