Example usage for com.badlogic.gdx.math.collision BoundingBox BoundingBox

List of usage examples for com.badlogic.gdx.math.collision BoundingBox BoundingBox

Introduction

In this page you can find the example usage for com.badlogic.gdx.math.collision BoundingBox BoundingBox.

Prototype

public BoundingBox(Vector3 minimum, Vector3 maximum) 

Source Link

Document

Constructs the new bounding box using the given minimum and maximum vector.

Usage

From source file:com.dsaw.hophome.GameObject.java

License:Apache License

public GameObject(float x, float y, float z, float width, float height, float depth) {
    this.position = new Vector3(x, y, z);
    Vector3 near = new Vector3(x - width / 2.0f, y - height / 2.0f, z + depth / 2.0f);
    Vector3 far = new Vector3(x + width / 2.0f, y + height / 2.0f, z - depth / 2.0f);
    this.bound = new BoundingBox(near, far);
    this.bounds = new Rectangle(x - width / 2, y - height / 2, width, height);
    this.width = width;
    this.height = height;
    this.depth = depth;
}

From source file:com.github.fauu.helix.editor.system.TileHighlightingSystem.java

License:Open Source License

@Override
protected void process(Entity e) {
    if (!mouseMoved()) {
        return;/*from w w w .j av  a2  s.c o m*/
    }

    Entity highlight = tagManager.getEntity("tileHighlight");

    Tile[][] tiles = tilesMapper.get(e).get();

    Ray ray = camera.getPickRay(Gdx.input.getX(), Gdx.input.getY());

    boolean hovering = false;

    for (int y = 0; y < tiles.length; y++) {
        for (int x = 0; x < tiles[y].length; x++) {
            BoundingBox boundingBox = new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 0));

            Matrix4 transformation = new Matrix4();
            transformation.translate(new Vector3(x, y, 0));

            boundingBox.mul(transformation);

            if (Intersector.intersectRayBoundsFast(ray, boundingBox)) {
                if (tiles[y][x] != highlightedTile) {
                    // FIXME
                    //            ModelDisplayable highlightDisplayable
                    //                = (ModelDisplayable) displayableMapper.get(highlight).get();
                    //            highlightDisplayable.updateTranslation(new Vector3(x, y, 0));

                    //            highlight.edit().create(VisibilityComponent.class);

                    highlightedTile = tiles[y][x];
                }

                hovering = true;

                break;
            }
        }
    }

    if (!hovering) {
        highlightedTile = null;

        highlight.edit().remove(VisibilityComponent.class);
    }
}

From source file:net.guerra24.voxel.client.world.block.types.BlockDimOre.java

License:Open Source License

@Override
public BoundingBox getBoundingBox(Vector3f pos) {
    return new BoundingBox(new Vector3(pos.x, pos.y, pos.z), new Vector3(pos.x + 1, pos.y + 1, pos.z + 1));
}

From source file:net.guerra24.voxel.client.world.block.types.BlockPortal.java

License:Open Source License

@Override
public BoundingBox getBoundingBox(Vector3f pos) {
    return new BoundingBox(new Vector3(pos.x, pos.y + 0.2f, pos.z),
            new Vector3(pos.x + 1, pos.y + 0.8f, pos.z + 1));
}