/** @return the size of a single vertex in bytes */ public int getVertexSize () { return vertices.getAttributes().vertexSize; }
/** @return the backing FloatBuffer holding the vertices. Does not have to be a direct buffer on Android! */ public FloatBuffer getVerticesBuffer () { return vertices.getBuffer(); }
/** @return the maximum number of vertices this mesh can hold */ public int getMaxVertices () { return vertices.getNumMaxVertices(); }
if (numVertices == 0) throw new GdxRuntimeException("No vertices defined"); final FloatBuffer verts = vertices.getBuffer(); bbox.inf(); final VertexAttribute posAttrib = getVertexAttribute(Usage.Position); final int offset = posAttrib.offset / 4; final int vertexSize = vertices.getAttributes().vertexSize / 4; int idx = offset;
/** Sets the vertices of this Mesh. The attributes are assumed to be given in float format. * * @param vertices the vertices. * @return the mesh for invocation chaining. */ public Mesh setVertices (float[] vertices) { this.vertices.setVertices(vertices, 0, vertices.length); return this; }
/** Update (a portion of) the vertices. Does not resize the backing buffer. * @param targetOffset the offset in number of floats of the mesh part. * @param source the vertex data to update the mesh part with * @param sourceOffset the offset in number of floats within the source array * @param count the number of floats to update */ public Mesh updateVertices (int targetOffset, float[] source, int sourceOffset, int count) { this.vertices.updateVertices(targetOffset, source, sourceOffset, count); return this; }
/** Frees all resources associated with this Mesh */ public void dispose () { if (meshes.get(Gdx.app) != null) meshes.get(Gdx.app).removeValue(this, true); vertices.dispose(); indices.dispose(); }
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
/** Binds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} if indices where given. Use this with OpenGL * ES 2.0 and when auto-bind is disabled. * * @param shader the shader (does not bind the shader) * @param locations array containing the attribute locations. */ public void bind (final ShaderProgram shader, final int[] locations) { vertices.bind(shader, locations); if (indices.getNumIndices() > 0) indices.bind(); }
/** @return the number of defined vertices */ public int getNumVertices () { return vertices.getNumVertices(); }
/** Invalidates all meshes so the next time they are rendered new VBO handles are generated. * @param app */ public static void invalidateAllMeshes (Application app) { Array<Mesh> meshesArray = meshes.get(app); if (meshesArray == null) return; for (int i = 0; i < meshesArray.size; i++) { meshesArray.get(i).vertices.invalidate(); meshesArray.get(i).indices.invalidate(); } }
if (numVertices == 0) throw new GdxRuntimeException("No vertices defined"); final FloatBuffer verts = vertices.getBuffer(); bbox.inf(); final VertexAttribute posAttrib = getVertexAttribute(Usage.Position); final int offset = posAttrib.offset / 4; final int vertexSize = vertices.getAttributes().vertexSize / 4; int idx = offset;
/** Sets the vertices of this Mesh. The attributes are assumed to be given in float format. * * @param vertices the vertices. * @return the mesh for invocation chaining. */ public Mesh setVertices (float[] vertices) { this.vertices.setVertices(vertices, 0, vertices.length); return this; }
/** Update (a portion of) the vertices. Does not resize the backing buffer. * @param targetOffset the offset in number of floats of the mesh part. * @param source the vertex data to update the mesh part with * @param sourceOffset the offset in number of floats within the source array * @param count the number of floats to update */ public Mesh updateVertices (int targetOffset, float[] source, int sourceOffset, int count) { this.vertices.updateVertices(targetOffset, source, sourceOffset, count); return this; }
/** Frees all resources associated with this Mesh */ public void dispose () { if (meshes.get(Gdx.app) != null) meshes.get(Gdx.app).removeValue(this, true); vertices.dispose(); indices.dispose(); }
/** Unbinds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} is indices were given. Use this with OpenGL * ES 1.x and when auto-bind is disabled. * * @param shader the shader (does not unbind the shader) * @param locations array containing the attribute locations. */ public void unbind (final ShaderProgram shader, final int[] locations) { vertices.unbind(shader, locations); if (indices.getNumIndices() > 0) indices.unbind(); }
/** Binds the underlying {@link VertexBufferObject} and {@link IndexBufferObject} if indices where given. Use this with OpenGL * ES 2.0 and when auto-bind is disabled. * * @param shader the shader (does not bind the shader) * @param locations array containing the attribute locations. */ public void bind (final ShaderProgram shader, final int[] locations) { vertices.bind(shader, locations); if (indices.getNumIndices() > 0) indices.bind(); }
/** @return the number of defined vertices */ public int getNumVertices () { return vertices.getNumVertices(); }
/** Invalidates all meshes so the next time they are rendered new VBO handles are generated. * @param app */ public static void invalidateAllMeshes (Application app) { Array<Mesh> meshesArray = meshes.get(app); if (meshesArray == null) return; for (int i = 0; i < meshesArray.size; i++) { meshesArray.get(i).vertices.invalidate(); meshesArray.get(i).indices.invalidate(); } }
if (offset < 0 || count < 1 || offset + count > numIndices) throw new GdxRuntimeException("Not enough indices"); final FloatBuffer verts = vertices.getBuffer(); final ShortBuffer index = indices.getBuffer(); final VertexAttribute posAttrib = getVertexAttribute(Usage.Position); final int posoff = posAttrib.offset / 4; final int vertexSize = vertices.getAttributes().vertexSize / 4; final int end = offset + count;