Game Development Reference
In-Depth Information
Figure 7-21. Bob in 3D
Since we haven't defined z coordinates for Bob's vertices, he is embedded in the x-y plane of
our 3D space (which is actually the model space, remember?). If we want to rotate Bob, we
can do so around any axis we can think of: the x, y, or z axis, or even a totally crazy axis like
(0.75,0.75,0.75). However, for our 2D graphics programming needs, it makes sense to rotate Bob
in the x-y plane; hence, we'll use the positive z axis as our rotation axis, which can be defined
as (0,0,1). The rotation will be counterclockwise around the z axis. A call to glRotatef() like the
following would cause the vertices of Bob's model to be rotated as shown in Figure 7-22 :
gl.glRotatef(45, 0, 0, 1);
Figure 7-22. Bob, rotated around the z axis by 45 degrees
Scaling
We can also scale Bob's model with glScalef() , like this:
glScalef(2, 0.5f, 1);
Given Bob's original model pose, this would result in the new orientation depicted in Figure 7-23 .
 
Search WWH ::




Custom Search