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 theVertices
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.
package com.badlogic.androidgames.framework.gl;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.IntBuffer;
import java.nio.ShortBuffer; ...
Get Beginning Android 4 Games Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.