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

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

Introduction

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

Prototype

public BoundingBox ext(BoundingBox a_bounds) 

Source Link

Document

Extends this bounding box by the given bounding box.

Usage

From source file:com.github.fauu.helix.graphics.ParticleEffect.java

License:Apache License

/** Returns the bounding box for all active particles. z axis will always be zero. */
public BoundingBox getBoundingBox() {
    if (bounds == null)
        bounds = new BoundingBox();

    BoundingBox bounds = this.bounds;
    bounds.inf();//from   w  w w .j  a v a  2  s  . c om
    for (ParticleEmitter emitter : this.emitters)
        bounds.ext(emitter.getBoundingBox());
    return bounds;
}

From source file:com.lyeeedar.Roguelike3D.Graphics.Models.StillModel.java

License:Open Source License

public void getBoundingBox(BoundingBox bbox) {
    bbox.inf();/*  w  ww. ja  va 2  s  . c  o  m*/
    for (int i = 0; i < subMeshes.length; i++) {
        subMeshes[i].mesh.calculateBoundingBox(tmpBox);
        bbox.ext(tmpBox);
    }
}

From source file:net.guerra24.voxel.client.world.physics.PhysicsSystem.java

License:Open Source License

public void move(Vector3f dir, BoundingBox currentBox, Vector3f velocity) {

    BoundingBox newBox = currentBox.set(
            new Vector3(currentBox.min.x + dir.x, currentBox.min.y + dir.y, currentBox.min.z + dir.z),
            new Vector3(currentBox.max.x + dir.x, currentBox.max.y + dir.y, currentBox.max.z + dir.z));
    List<BoundingBox> boxes = world.getGlobalBoundingBox(currentBox.ext(newBox));
    Vector3 temp = new Vector3(0, 0, 0);
    Vector3 end = new Vector3(0, 0, 0);
    float precision = (float) dir.length() * 99 + 1;
    boolean colisionX = false, colisionY = false, colisionZ = false;

    for (int i = 1; i < precision; i++) {
        float avance = (i / precision);
        if (!colisionX) {
            temp.set(avance * dir.getX(), end.y, end.z);
            BoundingBox check = currentBox.set(
                    new Vector3(currentBox.min.x + temp.x, currentBox.min.y + temp.y,
                            currentBox.min.z + temp.z),
                    new Vector3(currentBox.max.x + temp.x, currentBox.max.y + temp.y,
                            currentBox.max.z + temp.z));

            for (BoundingBox box : boxes) {
                if (check.intersects(box) || box.intersects(check)) {
                    colisionX = true;//w  w  w  .  ja v  a  2  s .  c o m
                    break;
                }
            }

            if (!colisionX) {
                end.set(temp.x, end.y, end.z);
            }
        }

        if (!colisionY) {
            temp.set(end.x, avance * dir.getY(), end.z);
            BoundingBox check = currentBox.set(
                    new Vector3(currentBox.min.x + temp.x, currentBox.min.y + temp.y,
                            currentBox.min.z + temp.z),
                    new Vector3(currentBox.max.x + temp.x, currentBox.max.y + temp.y,
                            currentBox.max.z + temp.z));

            for (BoundingBox box : boxes) {
                if (check.intersects(box) || box.intersects(check)) {
                    colisionY = true;
                    break;
                }
            }

            if (!colisionY) {
                end.set(end.x, temp.y, end.z);
            }
        }
        if (!colisionZ) {
            temp.set(end.x, end.y, avance * dir.getZ());
            BoundingBox check = currentBox.set(
                    new Vector3(currentBox.min.x + temp.x, currentBox.min.y + temp.y,
                            currentBox.min.z + temp.z),
                    new Vector3(currentBox.max.x + temp.x, currentBox.max.y + temp.y,
                            currentBox.max.z + temp.z));

            for (BoundingBox box : boxes) {
                if (check.intersects(box) || box.intersects(check)) {
                    colisionZ = true;
                    break;
                }
            }

            if (!colisionZ) {
                end.set(end.x, end.y, temp.z);
            }
        }
    }
    if (colisionX)
        velocity.x = 0;
    if (colisionY)
        velocity.y = 0;
    if (colisionZ)
        velocity.z = 0;
}