/** Constructs the new bounding box using the given minimum and maximum vector. * * @param minimum The minimum vector * @param maximum The maximum vector */ public BoundingBox (Vector3 minimum, Vector3 maximum) { this.set(minimum, maximum); }
/** Returns whether the given bounding box is contained in this bounding box. * @param b The bounding box * @return Whether the given bounding box is contained */ public boolean contains (BoundingBox b) { return !isValid() || (min.x <= b.min.x && min.y <= b.min.y && min.z <= b.min.z && max.x >= b.max.x && max.y >= b.max.y && max.z >= b.max.z); }
/** Extends the bounding box by the given vector. * * @param x The x-coordinate * @param y The y-coordinate * @param z The z-coordinate * @return This bounding box for chaining. */ public BoundingBox ext (float x, float y, float z) { return this.set(min.set(min(min.x, x), min(min.y, y), min(min.z, z)), max.set(max(max.x, x), max(max.y, y), max(max.z, z))); }
/** Updates the bounding box using the position channel. */ protected void calculateBoundingBox () { boundingBox.clr(); FloatChannel positionChannel = particles.getChannel(ParticleChannels.Position); for (int pos = 0, c = positionChannel.strideSize * particles.size; pos < c; pos += positionChannel.strideSize) { boundingBox.ext(positionChannel.data[pos + ParticleChannels.XOffset], positionChannel.data[pos + ParticleChannels.YOffset], positionChannel.data[pos + ParticleChannels.ZOffset]); } }
/** @return a copy of this controller, should be used after the particle effect has been loaded. */ public BoundingBox getBoundingBox () { if (boundingBox == null) boundingBox = new BoundingBox(); calculateBoundingBox(); return boundingBox; }
/** @return a copy of this ray. */ public Ray cpy () { return new Ray(this.origin, this.direction); }
/** Constructs a new bounding box with the minimum and maximum vector set to zeros. */ public BoundingBox () { clr(); }
/** Constructs a new bounding box from the given bounding box. * * @param bounds The bounding box to copy */ public BoundingBox (BoundingBox bounds) { this.set(bounds); }
/** @return a copy of this ray. */ public Ray cpy () { return new Ray(this.origin, this.direction); }
/** Returns whether the given bounding box is contained in this bounding box. * @param b The bounding box * @return Whether the given bounding box is contained */ public boolean contains (BoundingBox b) { return !isValid() || (min.x <= b.min.x && min.y <= b.min.y && min.z <= b.min.z && max.x >= b.max.x && max.y >= b.max.y && max.z >= b.max.z); }
/** Constructs a new bounding box with the minimum and maximum vector set to zeros. */ public BoundingBox () { clr(); }
/** Constructs a new bounding box from the given bounding box. * * @param bounds The bounding box to copy */ public BoundingBox (BoundingBox bounds) { this.set(bounds); }
/** Constructs the new bounding box using the given minimum and maximum vector. * * @param minimum The minimum vector * @param maximum The maximum vector */ public BoundingBox (Vector3 minimum, Vector3 maximum) { this.set(minimum, maximum); }
/** Sets the given bounding box. * * @param bounds The bounds. * @return This bounding box for chaining. */ public BoundingBox set (BoundingBox bounds) { return this.set(bounds.min, bounds.max); }
/** Sets the given bounding box. * * @param bounds The bounds. * @return This bounding box for chaining. */ public BoundingBox set (BoundingBox bounds) { return this.set(bounds.min, bounds.max); }
/** Sets the minimum and maximum vector to zeros. * @return This bounding box for chaining. */ public BoundingBox clr () { return this.set(min.set(0, 0, 0), max.set(0, 0, 0)); }