All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.codeandweb.physicseditor.PolygonNode Maven / Gradle / Ivy

The newest version!
package com.codeandweb.physicseditor;

import com.badlogic.gdx.utils.XmlReader;
import com.badlogic.gdx.math.Polygon;
import com.badlogic.gdx.physics.box2d.PolygonShape;

class PolygonNode {

  private final Polygon polygon;
  private final PolygonShape polygonShape = new PolygonShape(); // cache heap object

  PolygonNode(XmlReader.Element data) {
    float[] vertices = Utility.parseFloatsCSV(data.getText());
    polygon = new Polygon(vertices);
  }

  PolygonShape getPolygonShape(float scaleX, float scaleY) {
    polygon.setScale(scaleX, scaleY);
    polygonShape.set(polygon.getTransformedVertices());
    return polygonShape;
  }

  void dispose()
  {
    polygonShape.dispose();
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy