@Override public void draw (Batch batch, float parentAlpha) { batch.end(); Gdx.gl.glLineWidth(10); for (PolygonRegion region : polygonRegions) { this.batch.begin(); this.batch.draw(region, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); this.batch.end(); Polyline line = new Polyline(region.getVertices()); line.setScale(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); shapeRenderer.begin(ShapeRenderer.ShapeType.Line); shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix()); shapeRenderer.setColor(Color.BROWN); shapeRenderer.polyline(line.getTransformedVertices()); shapeRenderer.end(); } batch.begin(); }
@Override public void write (Kryo kryo, Output output, Polyline polyline) { output.writeInt(polyline.getVertices().length); output.writeFloats(polyline.getVertices()); output.writeFloat(polyline.getX()); output.writeFloat(polyline.getY()); output.writeFloat(polyline.getOriginX()); output.writeFloat(polyline.getOriginY()); output.writeFloat(polyline.getRotation()); output.writeFloat(polyline.getScaleX()); output.writeFloat(polyline.getScaleY()); }
@Override public Polyline read (Kryo kryo, Input input, Class<Polyline> type) { int length = input.readInt(); float[] vertices = input.readFloats(length); Polyline polyline = new Polyline(vertices); polyline.setPosition(input.readFloat(), input.readFloat()); polyline.setOrigin(input.readFloat(), input.readFloat()); polyline.setRotation(input.readFloat()); polyline.setScale(input.readFloat(), input.readFloat()); return polyline; }
private static Shape getPolylineShape(MapObject object) { Polyline polyline = ((PolylineMapObject)object).getPolyline(); float[] vertices = polyline.getTransformedVertices(); for (int i = 0; i < vertices.length; i++) { vertices[i] *= MainCamera.getInstance().getTileMapScale(); } ChainShape shape = new ChainShape(); shape.createChain(vertices); return shape; }
/** * * @param world * @param polylineObject * @param density * @param friction * @param restitution */ private void createPolyline(World world, PolylineMapObject polylineObject, float density, float friction, float restitution){ Polyline polyline = polylineObject.getPolyline(); ChainShape shape = new ChainShape(); float[] vertices = polyline.getTransformedVertices(); float[] worldVertices = new float[vertices.length]; for(int i = 0; i < vertices.length; i++){ worldVertices[i] = vertices[i] / SupaBox.PPM; } shape.createChain(worldVertices); BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyType.StaticBody; Body body = world.createBody(bodyDef); FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = shape; fixtureDef.density = density; fixtureDef.friction = friction; fixtureDef.restitution = restitution; body.createFixture(fixtureDef); shape.dispose(); }
public FixtureUserData(UserDataType type, String id, Polyline polyline) { this(type, id); this.polyline = polyline; }
public Polyline polyline(float[] vertices) { return new Polyline(vertices); }
/** @return polyline shape */ public Polyline getPolyline () { return polyline; }
/** @param polyline new object's polyline shape */ public void setPolyline (Polyline polyline) { this.polyline = polyline; }
/** @param vertices polyline defining vertices */ public PolylineMapObject (float[] vertices) { polyline = new Polyline(vertices); }
/** @param polyline the polyline */ public PolylineMapObject (Polyline polyline) { this.polyline = polyline; }