June 2013
Intermediate to advanced
346 pages
8h 42m
English
With a new point in the middle of the table, we’ll end up with four triangles instead of two. We’ll center the new point at (0, 0). Let’s open up AirHockeyRenderer in the new project that we created at the beginning of this chapter and update the triangles as follows:
| AirHockey2/src/com/airhockey/android/AirHockeyRenderer.java | |
| | // Triangle Fan |
| | 0, 0, |
| | -0.5f, -0.5f, |
| | 0.5f, -0.5f, |
| | 0.5f, 0.5f, |
| | -0.5f, 0.5f, |
| | -0.5f, -0.5f, |
The first question you might be asking is, “Why did we only define six points? Don’t we need to define three vertices per triangle?” While it’s true that we need three vertices per triangle, we can sometimes reuse the same vertex in more than one triangle. Let’s take a look at our new structure again, ...
Read now
Unlock full access