示例#1
0
  @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();
  }
示例#2
0
  public void dispose() {
    for (Mesh mesh : getMeshes()) {
      Material material = mesh.getMaterial();

      if (material.getDiffuseMap() != Texture.EMPTY)
        if (!(material.getDiffuseMap() instanceof SubTexture)) material.getDiffuseMap().dispose();

      if (material.getNormalMap() != Texture.EMPTY)
        if (!(material.getNormalMap() instanceof SubTexture)) material.getNormalMap().dispose();

      if (material.getSpecularMap() != Texture.EMPTY)
        if (!(material.getSpecularMap() instanceof SubTexture)) material.getSpecularMap().dispose();
    }
  }
示例#3
0
  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();
  }