Search in sources :

Example 1 with NavNodePolygonal

use of com.bladecoder.engine.polygonalpathfinder.NavNodePolygonal in project bladecoder-adventure-engine by bladecoder.

the class CanvasDrawer method drawBBoxWalkZone.

public void drawBBoxWalkZone(Scene scn, boolean lineOfSight) {
    if (scn.getPolygonalNavGraph() != null) {
        drawer.setProjectionMatrix(camera.combined);
        drawer.setTransformMatrix(new Matrix4());
        drawer.begin(ShapeType.Line);
        drawer.setColor(Scene.WALKZONE_COLOR);
        drawer.polygon(scn.getPolygonalNavGraph().getWalkZone().getTransformedVertices());
        // DRAW LINEs OF SIGHT
        if (lineOfSight) {
            drawer.setColor(Color.WHITE);
            ArrayList<NavNodePolygonal> nodes = scn.getPolygonalNavGraph().getGraphNodes();
            for (NavNodePolygonal n : nodes) {
                for (NavNodePolygonal n2 : n.neighbors) {
                    drawer.line(n.x, n.y, n2.x, n2.y);
                }
            }
        }
        drawer.end();
    }
}
Also used : NavNodePolygonal(com.bladecoder.engine.polygonalpathfinder.NavNodePolygonal) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 2 with NavNodePolygonal

use of com.bladecoder.engine.polygonalpathfinder.NavNodePolygonal in project bladecoder-adventure-engine by bladecoder.

the class Scene method drawBBoxLines.

public void drawBBoxLines(ShapeRenderer renderer) {
    // renderer.begin(ShapeType.Rectangle);
    renderer.begin(ShapeType.Line);
    for (BaseActor a : actors.values()) {
        Polygon p = a.getBBox();
        if (p == null) {
            EngineLogger.error("ERROR DRAWING BBOX FOR: " + a.getId());
        }
        if (a instanceof ObstacleActor) {
            renderer.setColor(OBSTACLE_COLOR);
            renderer.polygon(p.getTransformedVertices());
        } else if (a instanceof AnchorActor) {
            renderer.setColor(Scene.ANCHOR_COLOR);
            renderer.line(p.getX() - Scene.ANCHOR_RADIUS, p.getY(), p.getX() + Scene.ANCHOR_RADIUS, p.getY());
            renderer.line(p.getX(), p.getY() - Scene.ANCHOR_RADIUS, p.getX(), p.getY() + Scene.ANCHOR_RADIUS);
        } else {
            renderer.setColor(ACTOR_BBOX_COLOR);
            renderer.polygon(p.getTransformedVertices());
        }
    // Rectangle r = a.getBBox().getBoundingRectangle();
    // renderer.rect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
    }
    if (polygonalNavGraph != null) {
        renderer.setColor(WALKZONE_COLOR);
        renderer.polygon(polygonalNavGraph.getWalkZone().getTransformedVertices());
        // DRAW LINEs OF SIGHT
        renderer.setColor(Color.WHITE);
        ArrayList<NavNodePolygonal> nodes = polygonalNavGraph.getGraphNodes();
        for (NavNodePolygonal n : nodes) {
            for (NavNodePolygonal n2 : n.neighbors) {
                renderer.line(n.x, n.y, n2.x, n2.y);
            }
        }
    }
    renderer.end();
}
Also used : NavNodePolygonal(com.bladecoder.engine.polygonalpathfinder.NavNodePolygonal) Polygon(com.badlogic.gdx.math.Polygon)

Aggregations

NavNodePolygonal (com.bladecoder.engine.polygonalpathfinder.NavNodePolygonal)2 Matrix4 (com.badlogic.gdx.math.Matrix4)1 Polygon (com.badlogic.gdx.math.Polygon)1