Adds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color, u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be specified as 6 vertices.
(Texture texture, float[] vertices, int offset, int length)
| 250 | * u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be |
| 251 | * specified as 6 vertices. */ |
| 252 | public void add (Texture texture, float[] vertices, int offset, int length) { |
| 253 | if (currentCache == null) throw new IllegalStateException("beginCache must be called before add."); |
| 254 | |
| 255 | int verticesPerImage = mesh.getNumIndices() > 0 ? 4 : 6; |
| 256 | int count = length / (verticesPerImage * VERTEX_SIZE) * 6; |
| 257 | int lastIndex = textures.size - 1; |
| 258 | if (lastIndex < 0 || textures.get(lastIndex) != texture) { |
| 259 | textures.add(texture); |
| 260 | counts.add(count); |
| 261 | } else |
| 262 | counts.incr(lastIndex, count); |
| 263 | |
| 264 | mesh.getVerticesBuffer(true).put(vertices, offset, length); |
| 265 | } |
| 266 | |
| 267 | /** Adds the specified texture to the cache. */ |
| 268 | public void add (Texture texture, float x, float y) { |