Esempio n. 1
0
  /**
   * @param halfWidth half the width of the edges.
   * @return this for chaining.
   */
  public OutlinePolygon setHalfWidth(float halfWidth) {
    this.halfWidth = halfWidth;
    auxVertexFinder.setHalfWidth(this.halfWidth);

    for (int i = 0; i < needsUpdate.size; i++) {
      needsUpdate.items[i] = true;
    }
    changesToStripOrCulling = true;

    return this;
  }
Esempio n. 2
0
  /** Draws anti aliased polygon edges. */
  public OutlinePolygon(OutlinePolygonDef outlinePolygonDef) {

    debugRenderer =
        new DebugRenderer(this) {

          @Override
          public void draw(ShapeRenderer shapeRenderer) {
            if (drawCullingRectangles) drawCullingRectangles(shapeRenderer, Color.GREEN);

            if (drawLineFromFirstToLast) drawLineFromFirstToLast(shapeRenderer, Color.BLUE);

            if (drawTriangleStrips) drawTriangleStrips(shapeRenderer, Color.RED, Color.ORANGE);
          }

          @Override
          void update() {
            super.update();
            boolean enabled = drawLineFromFirstToLast;
            enabled |= drawCullingRectangles;
            enabled |= drawTriangleStrips;

            enabled &= myParents.size == 0;

            boolean change = this.enabled != enabled;
            if (!change) return;

            this.enabled = enabled;

            debugColors.clear();

            if (drawCullingRectangles) {
              debugColors.add(new DebugColor(Color.GREEN, "Bounding box"));
            }
            if (drawLineFromFirstToLast) {
              debugColors.add(
                  new DebugColor(Color.BLUE, "Line from first to last vertex in bounding box"));
            }
            if (drawTriangleStrips) {
              debugColors.add(new DebugColor(Color.RED, "Triangle strip visualization"));
              debugColors.add(new DebugColor(Color.ORANGE, "Triangle strip visualization"));
            }
          }
        };

    auxVertexFinder.setHalfWidth(this.halfWidth);

    if (outlinePolygonDef != null) {

      setDrawOutside(outlinePolygonDef.drawOutside);
      setDrawInside(outlinePolygonDef.drawInside);
      setColor(outlinePolygonDef.color);
      setClosedPolygon(outlinePolygonDef.closedPolygon);
      setHalfWidth(outlinePolygonDef.halfWidth);
      setWeight(outlinePolygonDef.weight);
      setRoundSharpCorners(outlinePolygonDef.roundSharpCorners);

      setDrawLineFromFirstToLast(outlinePolygonDef.drawLineFromFirstToLast);
      setDrawCullingRectangles(outlinePolygonDef.drawBoundingBoxes);
      setDrawTriangleStrips(outlinePolygonDef.drawTriangleStrips);

      setVisible(outlinePolygonDef.visible);
      setVertices(outlinePolygonDef.vertices);
      setScale(outlinePolygonDef.scale);
      setAngle(outlinePolygonDef.angle);
      setPosition(outlinePolygonDef.position);
      setOpacity(outlinePolygonDef.opacity);
    }
  }