@Override protected MeshPart newObject () { return new MeshPart(); } };
@Override protected MeshPart newObject () { return new MeshPart(); } };
/** Starts a new MeshPart. The mesh part is not usable until end() is called. This will reset the current color and vertex * transformation. * @see #part(String, int, MeshPart) */ public MeshPart part (final String id, int primitiveType) { return part(id, primitiveType, new MeshPart()); }
/** Starts a new MeshPart. The mesh part is not usable until end() is called. This will reset the current color and vertex * transformation. * @see #part(String, int, MeshPart) */ public MeshPart part (final String id, int primitiveType) { return part(id, primitiveType, new MeshPart()); }
/** Adds the specified mesh part to the current node. The Mesh will be managed by the model and disposed when the model is * disposed. The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the * model. * @return The added MeshPart. */ public MeshPart part (final String id, final Mesh mesh, int primitiveType, int offset, int size, final Material material) { final MeshPart meshPart = new MeshPart(); meshPart.id = id; meshPart.primitiveType = primitiveType; meshPart.mesh = mesh; meshPart.offset = offset; meshPart.size = size; part(meshPart, material); return meshPart; }
/** Adds the specified mesh part to the current node. The Mesh will be managed by the model and disposed when the model is * disposed. The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the * model. * @return The added MeshPart. */ public MeshPart part (final String id, final Mesh mesh, int primitiveType, int offset, int size, final Material material) { final MeshPart meshPart = new MeshPart(); meshPart.id = id; meshPart.primitiveType = primitiveType; meshPart.mesh = mesh; meshPart.offset = offset; meshPart.size = size; part(meshPart, material); return meshPart; }
protected NodePart set (NodePart other) { meshPart = new MeshPart(other.meshPart); material = other.material; enabled = other.enabled; if (other.invBoneBindTransforms == null) { invBoneBindTransforms = null; bones = null; } else { if (invBoneBindTransforms == null) invBoneBindTransforms = new ArrayMap<Node, Matrix4>(true, other.invBoneBindTransforms.size, Node.class, Matrix4.class); else invBoneBindTransforms.clear(); invBoneBindTransforms.putAll(other.invBoneBindTransforms); if (bones == null || bones.length != invBoneBindTransforms.size) bones = new Matrix4[invBoneBindTransforms.size]; for (int i = 0; i < bones.length; i++) { if (bones[i] == null) bones[i] = new Matrix4(); } } return this; } }
protected NodePart set (NodePart other) { meshPart = new MeshPart(other.meshPart); material = other.material; enabled = other.enabled; if (other.invBoneBindTransforms == null) { invBoneBindTransforms = null; bones = null; } else { if (invBoneBindTransforms == null) invBoneBindTransforms = new ArrayMap<Node, Matrix4>(true, other.invBoneBindTransforms.size, Node.class, Matrix4.class); else invBoneBindTransforms.clear(); invBoneBindTransforms.putAll(other.invBoneBindTransforms); if (bones == null || bones.length != invBoneBindTransforms.size) bones = new Matrix4[invBoneBindTransforms.size]; for (int i = 0; i < bones.length; i++) { if (bones[i] == null) bones[i] = new Matrix4(); } } return this; } }
protected void convertMesh (ModelMesh modelMesh) { int numIndices = 0; for (ModelMeshPart part : modelMesh.parts) { numIndices += part.indices.length; } VertexAttributes attributes = new VertexAttributes(modelMesh.attributes); int numVertices = modelMesh.vertices.length / (attributes.vertexSize / 4); Mesh mesh = new Mesh(true, numVertices, numIndices, attributes); meshes.add(mesh); disposables.add(mesh); BufferUtils.copy(modelMesh.vertices, mesh.getVerticesBuffer(), modelMesh.vertices.length, 0); int offset = 0; mesh.getIndicesBuffer().clear(); for (ModelMeshPart part : modelMesh.parts) { MeshPart meshPart = new MeshPart(); meshPart.id = part.id; meshPart.primitiveType = part.primitiveType; meshPart.offset = offset; meshPart.size = part.indices.length; meshPart.mesh = mesh; mesh.getIndicesBuffer().put(part.indices); offset += meshPart.size; meshParts.add(meshPart); } mesh.getIndicesBuffer().position(0); for (MeshPart part : meshParts) part.update(); }
protected void convertMesh (ModelMesh modelMesh) { int numIndices = 0; for (ModelMeshPart part : modelMesh.parts) { numIndices += part.indices.length; } VertexAttributes attributes = new VertexAttributes(modelMesh.attributes); int numVertices = modelMesh.vertices.length / (attributes.vertexSize / 4); Mesh mesh = new Mesh(true, numVertices, numIndices, attributes); meshes.add(mesh); disposables.add(mesh); BufferUtils.copy(modelMesh.vertices, mesh.getVerticesBuffer(), modelMesh.vertices.length, 0); int offset = 0; mesh.getIndicesBuffer().clear(); for (ModelMeshPart part : modelMesh.parts) { MeshPart meshPart = new MeshPart(); meshPart.id = part.id; meshPart.primitiveType = part.primitiveType; meshPart.offset = offset; meshPart.size = part.indices.length; meshPart.mesh = mesh; mesh.getIndicesBuffer().put(part.indices); offset += meshPart.size; meshParts.add(meshPart); } mesh.getIndicesBuffer().position(0); for (MeshPart part : meshParts) part.update(); }
builder.begin(); builder.part( new MeshPart("", mesh, 0, mesh.getNumIndices(), GL20.GL_TRIANGLES), new Material(TextureAttribute.createDiffuse(texture), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute .createShininess(64f), IntAttribute.createCullFace(0)));
@Override protected MeshPart newObject () { return new MeshPart(); } };
/** Adds the specified mesh part to the current node. The Mesh will be managed by the model and disposed when the model is * disposed. The resources the Material might contain are not managed, use {@link #manage(Disposable)} to add those to the * model. * @return The added MeshPart. */ public MeshPart part (final String id, final Mesh mesh, int primitiveType, int offset, int size, final Material material) { final MeshPart meshPart = new MeshPart(); meshPart.id = id; meshPart.primitiveType = primitiveType; meshPart.mesh = mesh; meshPart.offset = offset; meshPart.size = size; part(meshPart, material); return meshPart; }
/** Starts a new MeshPart. The mesh part is not usable until end() is called. This will reset the current color and vertex * transformation. * @see #part(String, int, MeshPart) */ public MeshPart part (final String id, int primitiveType) { return part(id, primitiveType, new MeshPart()); }
/** * Adds the specified mesh part to the current node. The Mesh will be * managed by the model and disposed when the model is disposed. The * resources the Material might contain are not managed, use * {@link #manage(Disposable)} to add those to the model. * * @return The added MeshPart. */ public MeshPart part(final String id, final Mesh mesh, int primitiveType, int offset, int size, final Material material) { final MeshPart meshPart = new MeshPart(); meshPart.id = id; meshPart.primitiveType = primitiveType; meshPart.mesh = mesh; meshPart.offset = offset; meshPart.size = size; part(meshPart, material); return meshPart; }
/** Starts a new MeshPart. The mesh part is not usable until end() is called */ public MeshPart part(final String id, int primitiveType) { if (this.attributes == null) throw new RuntimeException("Call begin() first"); endpart(); part = new MeshPart(); part.id = id; this.primitiveType = part.primitiveType = primitiveType; parts.add(part); setColor(null); return part; }
protected NodePart set (NodePart other) { meshPart = new MeshPart(other.meshPart); material = other.material; enabled = other.enabled; if (other.invBoneBindTransforms == null) { invBoneBindTransforms = null; bones = null; } else { if (invBoneBindTransforms == null) invBoneBindTransforms = new ArrayMap<Node, Matrix4>(true, other.invBoneBindTransforms.size, Node.class, Matrix4.class); else invBoneBindTransforms.clear(); invBoneBindTransforms.putAll(other.invBoneBindTransforms); if (bones == null || bones.length != invBoneBindTransforms.size) bones = new Matrix4[invBoneBindTransforms.size]; for (int i = 0; i < bones.length; i++) { if (bones[i] == null) bones[i] = new Matrix4(); } } return this; } }
@Deprecated public static Model createFromMesh(final Mesh mesh, int indexOffset, int vertexCount, int primitiveType, final Material material) { Model result = new Model(); MeshPart meshPart = new MeshPart(); meshPart.id = "part1"; meshPart.offset = indexOffset; meshPart.size = vertexCount; meshPart.primitiveType = primitiveType; meshPart.mesh = mesh; NodePart partMaterial = new NodePart(); partMaterial.material = material; partMaterial.meshPart = meshPart; Node node = new Node(); node.id = "node1"; node.parts.add(partMaterial); result.meshes.add(mesh); result.materials.add(material); result.nodes.add(node); result.meshParts.add(meshPart); result.manageDisposable(mesh); return result; }
protected void convertMesh (ModelMesh modelMesh) { int numIndices = 0; for (ModelMeshPart part : modelMesh.parts) { numIndices += part.indices.length; } VertexAttributes attributes = new VertexAttributes(modelMesh.attributes); int numVertices = modelMesh.vertices.length / (attributes.vertexSize / 4); Mesh mesh = new Mesh(true, numVertices, numIndices, attributes); meshes.add(mesh); disposables.add(mesh); BufferUtils.copy(modelMesh.vertices, mesh.getVerticesBuffer(), modelMesh.vertices.length, 0); int offset = 0; mesh.getIndicesBuffer().clear(); for (ModelMeshPart part : modelMesh.parts) { MeshPart meshPart = new MeshPart(); meshPart.id = part.id; meshPart.primitiveType = part.primitiveType; meshPart.offset = offset; meshPart.size = part.indices.length; meshPart.mesh = mesh; mesh.getIndicesBuffer().put(part.indices); offset += meshPart.size; meshParts.add(meshPart); } mesh.getIndicesBuffer().position(0); for (MeshPart part : meshParts) part.update(); }
public void init() { final int numVertices = this.vertexResolution * vertexResolution; final int numIndices = (this.vertexResolution - 1) * (vertexResolution - 1) * 6; mesh = new Mesh(true, numVertices, numIndices, attribs); this.vertices = new float[numVertices * stride]; mesh.setIndices(buildIndices()); buildVertices(); mesh.setVertices(vertices); MeshPart meshPart = new MeshPart(null, mesh, 0, numIndices, GL20.GL_TRIANGLES); meshPart.update(); ModelBuilder mb = new ModelBuilder(); mb.begin(); mb.part(meshPart, material); model = mb.end(); modelInstance = new ModelInstance(model); modelInstance.transform = transform; }