/** Starts a new MeshPart. The mesh part is not usable until end() is called. This will reset the current color and vertex * transformation. * @param id The id (name) of the part * @param primitiveType e.g. {@link GL20#GL_TRIANGLES} or {@link GL20#GL_LINES} * @param meshPart The part to receive the result */ public MeshPart part (final String id, final int primitiveType, MeshPart meshPart) { if (this.attributes == null) throw new RuntimeException("Call begin() first"); endpart(); part = meshPart; part.id = id; this.primitiveType = part.primitiveType = primitiveType; parts.add(part); setColor(null); setVertexTransform(null); setUVRange(null); return part; }
/** Starts a new MeshPart. The mesh part is not usable until end() is called. This will reset the current color and vertex * transformation. * @param id The id (name) of the part * @param primitiveType e.g. {@link GL20#GL_TRIANGLES} or {@link GL20#GL_LINES} * @param meshPart The part to receive the result */ public MeshPart part (final String id, final int primitiveType, MeshPart meshPart) { if (this.attributes == null) throw new RuntimeException("Call begin() first"); endpart(); part = meshPart; part.id = id; this.primitiveType = part.primitiveType = primitiveType; parts.add(part); setColor(null); setVertexTransform(null); setUVRange(null); return part; }
/** End building the mesh and returns the mesh * @param mesh The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold * the data, any existing data will be overwritten. */ public Mesh end (Mesh mesh) { endpart(); if (attributes == null) throw new GdxRuntimeException("Call begin() first"); if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Mesh attributes don't match"); if ((mesh.getMaxVertices() * stride) < vertices.size) throw new GdxRuntimeException("Mesh can't hold enough vertices: " + mesh.getMaxVertices() + " * " + stride + " < " + vertices.size); if (mesh.getMaxIndices() < indices.size) throw new GdxRuntimeException("Mesh can't hold enough indices: " + mesh.getMaxIndices() + " < " + indices.size); 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; }
/** End building the mesh and returns the mesh * @param mesh The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold * the data, any existing data will be overwritten. */ public Mesh end (Mesh mesh) { endpart(); if (attributes == null) throw new GdxRuntimeException("Call begin() first"); if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Mesh attributes don't match"); if ((mesh.getMaxVertices() * stride) < vertices.size) throw new GdxRuntimeException("Mesh can't hold enough vertices: " + mesh.getMaxVertices() + " * " + stride + " < " + vertices.size); if (mesh.getMaxIndices() < indices.size) throw new GdxRuntimeException("Mesh can't hold enough indices: " + mesh.getMaxIndices() + " < " + indices.size); 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; }
/** Starts a new MeshPart. The mesh part is not usable until end() is called. This will reset the current color and vertex * transformation. * @param id The id (name) of the part * @param primitiveType e.g. {@link GL20#GL_TRIANGLES} or {@link GL20#GL_LINES} * @param meshPart The part to receive the result */ public MeshPart part (final String id, final int primitiveType, MeshPart meshPart) { if (this.attributes == null) throw new RuntimeException("Call begin() first"); endpart(); part = meshPart; part.id = id; this.primitiveType = part.primitiveType = primitiveType; parts.add(part); setColor(null); setVertexTransform(null); setUVRange(null); return part; }
/** End building the mesh and returns the mesh * @param mesh The mesh to receive the built vertices and indices, must have the same attributes and must be big enough to hold * the data, any existing data will be overwritten. */ public Mesh end (Mesh mesh) { endpart(); if (attributes == null) throw new GdxRuntimeException("Call begin() first"); if (!attributes.equals(mesh.getVertexAttributes())) throw new GdxRuntimeException("Mesh attributes don't match"); if ((mesh.getMaxVertices() * stride) < vertices.size) throw new GdxRuntimeException("Mesh can't hold enough vertices: " + mesh.getMaxVertices() + " * " + stride + " < " + vertices.size); if (mesh.getMaxIndices() < indices.size) throw new GdxRuntimeException("Mesh can't hold enough indices: " + mesh.getMaxIndices() + " < " + indices.size); 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; }