Game Development Reference
In-Depth Information
Figure 7-23. Bob, scaled by a factor of 2 on the x axis and a factor of 0.5 on the y axis . . . ouch!
Combining Transformations
Now, we also discussed that we can combine the effect of multiple matrices by multiplying them
together to form a new matrix. All the methods— glTranslatef() , glScalef() , glRotatef() , and
glOrthof() —do just that. They multiply the current active matrix by the temporary matrix they
create internally based on the parameters we pass to them. So, let's combine the rotation and
scaling of Bob:
gl.glRotatef(45, 0, 0, 1);
gl.glScalef(2, 0.5f, 1);
This would make Bob's model look like Figure 7-24 (remember, we are still in model space).
Figure 7-24. Bob, first scaled and then rotated (still not looking happy)
What would happen if we applied the transformations the other way around?
gl.glScalef(2, 0.5, 0);
gl.glRotatef(45, 0, 0, 1)
Figure 7-25 gives you the answer.
Search WWH ::




Custom Search