TruWorlds

BoundsBox

Represents an axis-aligned bounding box (AABB) in 3D space.

Fields

Start Vector3

The minimum corner of the bounding box.

End Vector3

The maximum corner of the bounding box.

Functions

CreateFromAnchorPoint(origin: Vector3, position: Vector3, size: Vector3) Returns BoundsBox

Creates a bounding box centered at the specified position with the given size.

origin
The origin point for the position, where 0 is relative to start, 0.5 is center, and 1 is end.
position
The position of the bounding box at the specified origin.
size
The size of the bounding box.

Returns: A new bounding box of the requested size positioned at using as the anchor.

Transform(cMatrix: CMatrix) Returns BoundsBox

Transforms the bounding box's eight corners by and returns the axis-aligned box that contains all of them.

cMatrix
The transform to apply to each corner.

Returns: A new axis-aligned bounding box that encloses the transformed corners.

GetSize() Returns Vector3

Gets the size of the bounding box (dimensions along each axis).

Returns: A vector representing the size of the bounding box.

GetCenter() Returns Vector3

Gets the center point of the bounding box.

Returns: A vector representing the center of the bounding box.

SetCenter(center: Vector3)

Sets the center point of the bounding box, keeping its size unchanged.

center
The new center point for the bounding box.
Contains(point: Vector3) Returns bool

Determines whether this bounding box contains the specified point.

point
The point to test.

Returns: True if the point is inside or on the boundary of the bounding box; otherwise, false.

Contains(other: BoundsBox) Returns bool

Determines whether this bounding box contains another bounding box entirely.

other
The other bounding box to test.

Returns: True if the other bounding box is completely inside this one; otherwise, false.

Intersects(other: BoundsBox) Returns bool

Determines whether this bounding box intersects with another bounding box.

other
The other bounding box to test.

Returns: True if the bounding boxes overlap; otherwise, false.

Encapsulate(other: BoundsBox) Returns BoundsBox

Expands this bounding box to contain another bounding box.

other
The bounding box to include.

Returns: This bounding box, expanded to contain the other bounding box.

Encapsulate(point: Vector3) Returns BoundsBox

Expands this bounding box to contain a point.

point
The point to include.

Returns: This bounding box, expanded to contain the point.

Grow(margin: float) Returns BoundsBox

Grows the bounding box by the specified margin on all sides.

margin
The amount to grow each side by.

Returns: This bounding box, grown by the specified margin.

Grow(margins: Vector3) Returns BoundsBox

Grows the bounding box by the specified margins on each axis.

margins
The amount to grow each side by for each axis.

Returns: This bounding box, grown by the specified margins.

Grown(margin: float) Returns BoundsBox

Returns a copy of this bounding box that has been grown by the specified margin.

margin
The amount to grow each side by.

Returns: A new bounding box grown by the specified margin.

Grown(margins: Vector3) Returns BoundsBox

Returns a copy of this bounding box that has been grown by the specified margins.

margins
The amount to grow each side by for each axis.

Returns: A new bounding box grown by the specified margins.

GetIntersection(other: BoundsBox) Returns BoundsBox?

Computes the intersection of this bounding box with another bounding box.

other
The other bounding box to intersect with.

Returns: A new bounding box representing the intersection, or null if they don't intersect.