June 2013
Intermediate to advanced
346 pages
8h 42m
English
We’ll now switch to using the perspective projection matrix. Open up AirHockeyRenderer and remove all of the code from onSurfaceChanged, except for the call to glViewport. Add the following code:
| AirHockey3D/src/com/airhockey/android/AirHockeyRenderer.java | |
| | MatrixHelper.perspectiveM(projectionMatrix, 45, (float) width |
| | / (float) height, 1f, 10f); |
This will create a perspective projection with a field of vision of 45 degrees. The frustum will begin at a z of -1 and will end at a z of -10.
After adding the import for MatrixHelper, go ahead and run the program. You’ll probably notice that our air hockey table has disappeared! Since we didn’t specify a z position for our table, it’s located at a z of 0 by default. ...
Read now
Unlock full access