Graphics Programs Reference
In-Depth Information
public void onClick(View v) {
synchronized (this) {
Counter.getUpDownPreviousValue();
}
}
});
}
Combining Translation with Rotation
Now, we want the tank to be able to drive away from the center of the screen (upon
up/down button click), while it is free to rotate about the global z-axis (i.e., the ax-
is normal to the screen and passing through its center). For that, declare a new field
in the Renderer class ( TANK FENCE 3/src/com/apress/android/tank-
fence3/GLES20Renderer.java ) - _tankTMatrix of type float[16] .
After this, replace the following lines of code in the onDrawFrame() method with
the lines of code in Listing 6-7 .
Matrix.setIdentityM(_tankRMatrix, 0);
Matrix.rotateM(_tankRMatrix, 0, _zAngle, 0, 0, 1);
Matrix.multiplyMM(_tankMVPMatrix, 0, _ViewMatrix, 0,
_tankRMatrix, 0);
Matrix.multiplyMM(_tankMVPMatrix, 0,
_ProjectionMatrix, 0, _tankMVPMatrix, 0);
Listing 6-7. TANK FENCE GAME 2/src/com/apress/android/tankfencegame2/
GLES20Renderer.java
Matrix.setIdentityM(_tankTMatrix, 0);
Matrix.setIdentityM(_tankRMatrix, 0);
Matrix.translateM(_tankTMatrix, 0, 0,
Counter.getUpDownValue(), 0);
Matrix.rotateM(_tankRMatrix, 0, _zAngle, 0, 0, 1);
Matrix.multiplyMM(_tankMVPMatrix, 0, _tankRMatrix, 0,
 
 
Search WWH ::




Custom Search