Package engine.geometry

Examples of engine.geometry.Polygon


                default:
                    throw new UnsupportedOperationException("Unknown tile!");
            }

            if (!vertices.isEmpty()) {
                polygon = new Polygon(vertices);
                Transform.translate(polygon, column, row);
                Transform.scale(polygon, WIDTH, HEIGHT);
            }
        }
        return polygon;
View Full Code Here


        } else if (shape instanceof Circle) {
            Circle circle = (Circle) shape;
            circle.setX(circle.getX() + x);
            circle.setY(circle.getY() + y);
        } else if (shape instanceof Polygon) {
            Polygon polygon = (Polygon) shape;
            final int size = polygon.getSize();
            for (int i = 0; i < size; i++) {
                polygon.setVertex(i, polygon.getX(i) + x, polygon.getY(i) + y);
            }
        } else {
            throw new UnsupportedOperationException();
        }
    }
View Full Code Here

            rectangle.setX(rectangle.getX() * x);
            rectangle.setY(rectangle.getY() * y);
            rectangle.setWidth(rectangle.getWidth() * x);
            rectangle.setHeight(rectangle.getHeight() * y);
        } else if (shape instanceof Polygon) {
            Polygon polygon = (Polygon) shape;
            final int size = polygon.getSize();
            for (int i = 0; i < size; i++) {
                polygon.setVertex(i, polygon.getX(i) * x, polygon.getY(i) * y);
            }
        } else {
            throw new UnsupportedOperationException();
        }
    }
View Full Code Here

        } else if (shape instanceof Line) {
            Line line = (Line) shape;
            line.setStart(line.getX1() + x * line.getY1(), line.getY1() + y * line.getX1());
            line.setEnd(line.getX2() + x * line.getY2(), line.getY2() + y * line.getX2());
        } else if (shape instanceof Polygon) {
            Polygon polygon = (Polygon) shape;
            final int size = polygon.getSize();
            for (int i = 0; i < size; i++) {
                polygon.setVertex(i, polygon.getX(i) + x * polygon.getY(i), polygon.getY(i) + y * polygon.getX(i));
            }
        } else {
            throw new UnsupportedOperationException();
        }
    }
View Full Code Here

        }
        outside = new ObjectPolygonHashMap();
    }

    public Polygon putObject(Object object, Polygon polygon) {
        Polygon oldPolygon = null;
        if (all.containsKey(object)) {
            oldPolygon = removeObject(object);
        }
        all.put(object, new Polygon(polygon));
        int r1 = (int) Math.floor(polygon.getMinY() / CELL_HEIGHT);
        int r2 = (int) Math.ceil(polygon.getMaxY() / CELL_HEIGHT);
        int c1 = (int) Math.floor(polygon.getMinX() / CELL_WIDTH);
        int c2 = (int) Math.ceil(polygon.getMaxX() / CELL_WIDTH);
        boolean outsideHandled = false;
View Full Code Here

        }
        return oldPolygon;
    }

    public Polygon removeObject(Object object) {
        Polygon polygon = all.remove(object);
        if (polygon == null) {
            return null;
        }
        int r1 = (int) Math.floor(polygon.getMinY() / CELL_HEIGHT);
        int r2 = (int) Math.ceil(polygon.getMaxY() / CELL_HEIGHT);
        int c1 = (int) Math.floor(polygon.getMinX() / CELL_WIDTH);
        int c2 = (int) Math.ceil(polygon.getMaxX() / CELL_WIDTH);
        boolean outsideHandled = false;
        for (int r = r1; r < r2; r++) {
            for (int c = c1; c < c2; c++) {
                try {
                    grid[r][c].remove(object);
View Full Code Here

    @Override
    protected void onBeforeMove(Keyboard keyboard, Mouse mouse, Clock clock) {
        if (mouse.isDown(Button.MB_LEFT)) {
            PlayerActor pa = getLayer().findActor(PlayerActor.class);
            Polygon p = pa.findHabit(DynamicHabit.class).getPolygon();
            metal.applyImpulse(p.getMid().subtract(dynamic.getPolygon().getMid()).divide(1000));
        }
    }
View Full Code Here

TOP

Related Classes of engine.geometry.Polygon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.