Example usage for com.badlogic.gdx.math ConvexHull computePolygon

List of usage examples for com.badlogic.gdx.math ConvexHull computePolygon

Introduction

In this page you can find the example usage for com.badlogic.gdx.math ConvexHull computePolygon.

Prototype

public FloatArray computePolygon(float[] polygon, boolean sorted) 

Source Link

Usage

From source file:com.github.skittishSloth.openSkies.maps.generation.voronoi.Cell.java

public Polygon calculateConvexHull() {
    final float[] coords = new float[tiles.size() * 2];

    int idx = 0;/*from ww  w .j  a  v  a2s.co m*/
    for (final VoronoiTile tile : tiles) {
        if ((tile.getX() == 0) && (tile.getY() == 0)) {
            containsCorner = true;
        }
        coords[idx++] = tile.getX();
        coords[idx++] = tile.getY();
    }

    if (containsCorner == null) {
        containsCorner = false;
    }

    final ConvexHull ch = new ConvexHull();
    final FloatArray vertices = ch.computePolygon(coords, false);
    final Polygon polygon = new Polygon(vertices.items);
    return polygon;
}