OpenGL ES Tutorial for Android – Part III
– Transformations
Last tutorial was about building your polygons. This tutorial is all about transformations,
how to move the polygons around. I will continue this tutorial from where the previous
ended so you can use that source code or make a copy of it.
I am not going to bore you with a lot of mathematics but I believe it is important to know
that when OpenGL render a mesh it multiplies all vertices with a matrix. All the
transformations you do are about manipulating the vertices in different ways by modifying
this matrix. You can think of the matrix as a paper and that you never move the pen
before you start to draw. You always draw in the center. But by doing a translation on the
matrix you are moving the paper and also the center. A rotation is like rotating the paper
around the center. And a scale is a bit harder to visualize with the paper view but it is like
changing the unit size regarding to how you translate your meshes. Usually you talk
about transformations according to the mesh not the world, but it is still important to know
about.
Coordinate System
OpenGL uses a so called right-handed coordinate
system. A system is called right-handed if you
look from the positive end towards the origin of
the axis the counter-clockwise rotation is
considered to be a positive rotation.
When you have started up your view and haven't applied any
transformations the axis are aligned like this: The x-axis goes
from left to right, the y-axis comes from the bottom and goes up
and the z-axis is moving from the back of the screen towards the
front of the screen.
- 1
- 2
前往页