Graphics Programs Reference
In-Depth Information
_tankTMatrix, 0);
Matrix.multiplyMM(_tankMVPMatrix, 0, _ViewMatrix, 0,
_tankMVPMatrix, 0);
Matrix.multiplyMM(_tankMVPMatrix, 0,
_ProjectionMatrix, 0, _tankMVPMatrix, 0);
The call to translateM() method will translate matrix _tankTMatrix (by the
value returned by Counter.getUpDownValue() ) along the global y-axis. To
combine rotation with translation in the specified manner ( Figure 6-2 ), the following
call is made: Matrix.multiplyMM(_tankMVPMatrix, 0, _tankRMat-
rix, 0, _tankTMatrix, 0) , which will translate the tank along the global
y-axis and then rotate it about the global z-axis. Please note that to achieve this, the
order is important - i.e., translation comes ahead of rotation.
Figure 6-2 . Combined translation and rotation transformations
To see these steps in action, import the archive file tankfencegame2.zip from
the source code for this chapter. This will load the TANK FENCE GAME 2 applic-
ation into your Eclipse workspace. Some additional changes are also made to this
application:
Shader code in the Renderer class does not make use of attributes
to provide colors. The color is directly written to the
gl_FragColor variable.
 
 
Search WWH ::




Custom Search