Matrices and Transformations Again

In Chapter 6 we talked a little bit about matrices. Let's summarize some of their properties as a little refresher:

■ A matrix translates points (or vertices in our case) to a new position. This is achieved by multiplying the matrix with the point's position.

■ A matrix can translate points on each axis by some amount.

■ A matrix can scale points, meaning that it multiplies each coordinate of a point by some constant.

■ A matrix can rotate a point around an axis.

■ Multiplying an identity matrix with a point has no effect on that point.

■ Multiplying one matrix with another matrix results in a new matrix. Multiplying a point with this new matrix will apply both transformations encoded in the original matrices to that point.

■ Multiplying a matrix with an identity matrix has no effect on the matrix. OpenGL ES provides us with three types of matrices:

■ Projection matrix: We use this to set up our view frustum's shape and size, which governs the type of projection and how much of our world is shown to us.

■ Model-view matrix: We use this to transform our models in model space, and to place a model in world space.

■ Texture matrix: We keep ignoring this, as it is broken on many devices.

Now that we are working in 3D we have more options at our disposal. We can, for example, not only rotate a model around the z-axis like we did with Bob, but around any arbitrary axis. The only thing that really changes, though, is the additional z-axis we can now use to place our objects. We were actually already working in 3D when we rendered Bob back in Chapter 6; we just ignored the z-axis. But there's more we can do.

Was this article helpful?

0 0

Post a comment