List of usage examples for com.badlogic.gdx.graphics Mesh setVertices
public Mesh setVertices(float[] vertices, int offset, int count)
From source file:com.badlogic.gdx.tests.g3d.voxel.VoxelWorld.java
License:Apache License
@Override public void getRenderables(Array<Renderable> renderables, Pool<Renderable> pool) { renderedChunks = 0;/*from w w w. java2 s . c o m*/ for (int i = 0; i < chunks.length; i++) { VoxelChunk chunk = chunks[i]; Mesh mesh = meshes[i]; if (dirty[i]) { int numVerts = chunk.calculateVertices(vertices); numVertices[i] = numVerts / 4 * 6; mesh.setVertices(vertices, 0, numVerts * VoxelChunk.VERTEX_SIZE); dirty[i] = false; } if (numVertices[i] == 0) continue; Renderable renderable = pool.obtain(); renderable.material = materials[i]; renderable.mesh = mesh; renderable.meshPartOffset = 0; renderable.meshPartSize = numVertices[i]; renderable.primitiveType = GL20.GL_TRIANGLES; renderables.add(renderable); renderedChunks++; } }
From source file:com.doom.render.QuadBatch.java
License:Apache License
@Override public void flush() { if (idx == 0) return;//from w w w . j av a 2 s . co m renderCalls++; totalRenderCalls++; int spritesInBatch = idx / 20; if (spritesInBatch > maxSpritesInBatch) maxSpritesInBatch = spritesInBatch; int count = spritesInBatch * 6; lastTexture.bind(); Mesh mesh = this.mesh; mesh.setVertices(vertices, 0, idx); mesh.getIndicesBuffer().position(0); mesh.getIndicesBuffer().limit(count); if (blendingDisabled) { Gdx.gl.glDisable(GL20.GL_BLEND); } else { Gdx.gl.glEnable(GL20.GL_BLEND); if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc); } mesh.render(customShader != null ? customShader : shader, GL20.GL_TRIANGLES, 0, count); idx = 0; }
From source file:com.esotericsoftware.spine.utils.TwoColorPolygonBatch.java
License:Open Source License
@Override public void flush() { if (vertexIndex == 0) return;//w ww . j a v a2 s. com totalRenderCalls++; lastTexture.bind(); Mesh mesh = this.mesh; mesh.setVertices(vertices, 0, vertexIndex); mesh.setIndices(triangles, 0, triangleIndex); Gdx.gl.glEnable(GL20.GL_BLEND); if (blendSrcFunc != -1) Gdx.gl.glBlendFuncSeparate(blendSrcFunc, blendDstFunc, blendSrcFuncAlpha, blendDstFuncAlpha); mesh.render(shader, GL20.GL_TRIANGLES, 0, triangleIndex); vertexIndex = 0; triangleIndex = 0; }
From source file:gaia.cu9.ari.gaiaorbit.util.g3d.MeshBuilder2.java
License:Apache License
/** End building the mesh and returns the mesh */ public Mesh end() { if (this.attributes == null) throw new RuntimeException("Call begin() first"); endpart();/*from w ww. j a v a2 s. co m*/ final Mesh mesh = new Mesh(true, vertices.size / stride, indices.size, attributes); mesh.setVertices(vertices.items, 0, vertices.size); mesh.setIndices(indices.items, 0, indices.size); for (MeshPart p : parts) p.mesh = mesh; parts.clear(); attributes = null; vertices.clear(); indices.clear(); return mesh; }
From source file:graphics.widgets.WidgetsPass.java
License:Open Source License
public void flush() { if (idx == 0 || lastTexture == null) return;//from www .ja v a 2s . c om int spritesInBatch = idx / 20; int count = spritesInBatch * 6; lastTexture.bind(0); Mesh mesh = this.mesh; mesh.setVertices(vertices, 0, idx); mesh.getIndicesBuffer().position(0); mesh.getIndicesBuffer().limit(count); if (blendingDisabled) { Gdx.gl.glDisable(GL20.GL_BLEND); } else { Gdx.gl.glEnable(GL20.GL_BLEND); if (blendSrcFunc != -1) Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc); } mesh.render(shader, GL20.GL_TRIANGLES, 0, count); idx = 0; }