O'Reilly logo

Beginning Android 4 Games Development by Robert Green, Mario Zechner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Vertices in 3D

In Chapter 7, you learned that a vertex has a few attributes:

  • Position
  • Color (optional)
  • Texture coordinates (optional)
  • You created a helper class called Vertices, which handles all the dirty details for you. You limited the vertex positions to have only x- and y-coordinates. All you need to do to go 3D is modify the Vertices class so that it supports 3D vertex positions.

Vertices3: Storing 3D Positions

Let's write a new class called Vertices3 to handle 3D vertices based on your original Vertices class. Listing 10–1 shows the code.

Listing 10–1. Vertices3.java, Now with More Coordinates.

package com.badlogic.androidgames.framework.gl; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; import java.nio.ShortBuffer; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required