コード例 #1
0
ファイル: RenderPart.java プロジェクト: Sleaker/Spout
  /**
   * Returns the vertices used for rendering the part.
   *
   * @return vertices of part
   */
  public List<Vertex> getVertices() {
    List<Vertex> face = new ArrayList<>();
    Vector3 p1 = new Vector3(sprite.getX(), sprite.getY(), 0);
    Vector3 p2 = new Vector3(sprite.getX() + sprite.getWidth(), sprite.getY(), 0);
    Vector3 p3 =
        new Vector3(sprite.getX() + sprite.getWidth(), sprite.getY() - sprite.getHeight(), 0);
    Vector3 p4 = new Vector3(sprite.getX(), sprite.getY() - sprite.getHeight(), 0);

    Vector2 t1 = new Vector2(source.getX(), source.getY());
    Vector2 t2 = new Vector2(source.getX() + source.getWidth(), source.getY());
    Vector2 t3 = new Vector2(source.getX() + source.getWidth(), source.getY() + source.getHeight());
    Vector2 t4 = new Vector2(source.getX(), source.getY() + source.getHeight());

    face.add(Vertex.createVertexPositionTexture0(p1, t1));
    face.add(Vertex.createVertexPositionTexture0(p2, t2));
    face.add(Vertex.createVertexPositionTexture0(p3, t3));
    face.add(Vertex.createVertexPositionTexture0(p4, t4));

    for (Vertex v : face) {
      v.color = color;
    }

    return face;
  }