public void render(Batcher batcher, Transform transform) { Mesh m = getMeshes().get(0); Material originalMaterial = SilenceEngine.graphics.getCurrentMaterial(); Texture originalTexture = Texture.CURRENT; SilenceEngine.graphics.useMaterial(m.getMaterial()); m.getMaterial().getDiffuseMap().bind(); if (transform != null) batcher.applyTransform(transform); batcher.begin(m.isWireFrame() ? Primitive.LINES : Primitive.TRIANGLES); { for (Mesh mesh : getMeshes()) { if (!m.getMaterial().equals(mesh.getMaterial())) { batcher.end(); SilenceEngine.graphics.useMaterial(mesh.getMaterial()); mesh.getMaterial().getDiffuseMap().bind(); m = mesh; if (transform != null) batcher.applyTransform(transform); batcher.begin(m.isWireFrame() ? Primitive.LINES : Primitive.TRIANGLES); } Color color = mesh.getMaterial().getDiffuse(); for (Face face : mesh.getFaces()) { batcher.vertex(mesh.getVertices().get((int) face.vertexIndex.x)); batcher.normal(mesh.getNormals().get((int) face.normalIndex.x)); batcher.texCoord(mesh.getTexcoords().get((int) face.texcoordIndex.x)); if (mesh.getMaterial().getDiffuseMap().getID() == Texture.EMPTY.getID()) batcher.color(color.x, color.y, color.z, mesh.getMaterial().getDissolve()); batcher.vertex(mesh.getVertices().get((int) face.vertexIndex.y)); batcher.normal(mesh.getNormals().get((int) face.normalIndex.y)); batcher.texCoord(mesh.getTexcoords().get((int) face.texcoordIndex.y)); if (mesh.getMaterial().getDiffuseMap().getID() == Texture.EMPTY.getID()) batcher.color(color.x, color.y, color.z, mesh.getMaterial().getDissolve()); batcher.vertex(mesh.getVertices().get((int) face.vertexIndex.z)); batcher.normal(mesh.getNormals().get((int) face.normalIndex.z)); batcher.texCoord(mesh.getTexcoords().get((int) face.texcoordIndex.z)); if (mesh.getMaterial().getDiffuseMap().getID() == Texture.EMPTY.getID()) batcher.color(color.x, color.y, color.z, mesh.getMaterial().getDissolve()); } } } batcher.end(); SilenceEngine.graphics.useMaterial(originalMaterial); originalTexture.bind(); }
@Override public boolean equals(Object object) { if (this == object) return true; if (object == null || getClass() != object.getClass()) return false; Mesh mesh = (Mesh) object; return id == mesh.getID() && preferStatic == mesh.prefersStatic() && isWireFrame() == mesh.isWireFrame(); }