@Override protected MeshPart newObject () { return new MeshPart(); } };
renderable.meshPart.update();
/** Convenience method to set the material, mesh, meshPartOffset, meshPartSize, primitiveType and bones members of the specified * Renderable. The other member of the provided {@link Renderable} remain untouched. Note that the material, mesh and bones * members are referenced, not copied. Any changes made to those objects will be reflected in both the NodePart and Renderable * object. * @param out The Renderable of which to set the members to the values of this NodePart. */ public Renderable setRenderable (final Renderable out) { out.material = material; out.meshPart.set(meshPart); out.bones = bones; return out; }
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(); }
@Override public void render (Renderable renderable) { set(u_worldTrans, renderable.worldTransform); TestAttribute testAttr = (TestAttribute)renderable.material.get(TestAttribute.ID); set(u_test, testAttr.value); if (withColor) { ColorAttribute colorAttr = (ColorAttribute)renderable.material.get(ColorAttribute.Diffuse); set(u_color, colorAttr.color); } renderable.meshPart.render(program); }
@Override public boolean equals (final Object arg0) { if (arg0 == null) return false; if (arg0 == this) return true; if (!(arg0 instanceof MeshPart)) return false; return equals((MeshPart)arg0); }
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(); }
@Override public void render (Renderable renderable) { set(u_pass, 0f); super.render(renderable); context.setDepthTest(GL20.GL_LESS); if (has(u_pass)) { context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); for (int i = 1; i < passes; ++i) { set(u_pass, (float)i / (float)passes); renderable.meshPart.render(program, false); } } } }
@Override public boolean equals (final Object arg0) { if (arg0 == null) return false; if (arg0 == this) return true; if (!(arg0 instanceof MeshPart)) return false; return equals((MeshPart)arg0); }
@Override protected MeshPart newObject () { return new MeshPart(); } };
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; }
public void render (Renderable renderable, final Attributes combinedAttributes) { for (int u, i = 0; i < localUniforms.size; ++i) if (setters.get(u = localUniforms.get(i)) != null) setters.get(u).set(this, u, renderable, combinedAttributes); if (currentMesh != renderable.meshPart.mesh) { if (currentMesh != null) currentMesh.unbind(program, tempArray.items); currentMesh = renderable.meshPart.mesh; currentMesh.bind(program, getAttributeLocations(renderable.meshPart.mesh.getVertexAttributes())); } renderable.meshPart.render(program, false); }
/** Convenience method to set the material, mesh, meshPartOffset, meshPartSize, primitiveType and bones members of the specified * Renderable. The other member of the provided {@link Renderable} remain untouched. Note that the material, mesh and bones * members are referenced, not copied. Any changes made to those objects will be reflected in both the NodePart and Renderable * object. * @param out The Renderable of which to set the members to the values of this NodePart. */ public Renderable setRenderable (final Renderable out) { out.material = material; out.meshPart.set(meshPart); out.bones = bones; return out; }
renderable.meshPart.update();
@Override public boolean equals (final Object arg0) { if (arg0 == null) return false; if (arg0 == this) return true; if (!(arg0 instanceof MeshPart)) return false; return equals((MeshPart)arg0); }
/** 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()); }
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 render (Renderable renderable, final Attributes combinedAttributes) { for (int u, i = 0; i < localUniforms.size; ++i) if (setters.get(u = localUniforms.get(i)) != null) setters.get(u).set(this, u, renderable, combinedAttributes); if (currentMesh != renderable.meshPart.mesh) { if (currentMesh != null) currentMesh.unbind(program, tempArray.items); currentMesh = renderable.meshPart.mesh; currentMesh.bind(program, getAttributeLocations(renderable.meshPart.mesh.getVertexAttributes())); } renderable.meshPart.render(program, false); }
/** Construct a new MeshPart and set all its values. * @param id The id of the new part, may be null. * @param mesh The mesh which holds all vertices and (optional) indices of this part. * @param offset The offset within the mesh to this part. * @param size The size (in total number of vertices) of the part. * @param type The primitive type of the part (e.g. GL_TRIANGLES, GL_LINE_STRIP, etc.). */ public MeshPart (final String id, final Mesh mesh, final int offset, final int size, final int type) { set(id, mesh, offset, size, type); }
@Override protected void flush (int[] offsets) { // fill vertices if (useGPU) { // if(mode != AlignMode.ParticleDirection) fillVerticesGPU(offsets); // else // fillVerticesToParticleDirectionGPU(offsets); } else { if (mode == AlignMode.Screen) fillVerticesToScreenCPU(offsets); else if (mode == AlignMode.ViewPoint) fillVerticesToViewPointCPU(offsets); // else // fillVerticesToParticleDirectionCPU(offsets); } // send vertices to meshes int addedVertexCount = 0; int vCount = bufferedParticlesCount * 4; for (int v = 0; v < vCount; v += addedVertexCount) { addedVertexCount = Math.min(vCount - v, MAX_VERTICES_PER_MESH); Renderable renderable = renderablePool.obtain(); renderable.meshPart.size = (addedVertexCount / 4) * 6; renderable.meshPart.mesh.setVertices(vertices, currentVertexSize * v, currentVertexSize * addedVertexCount); renderable.meshPart.update(); renderables.add(renderable); } }