AABB

From MyGamingTalk
Jump to navigation Jump to search
Script Reference AABB Functions

CenterPoint

Gets the center of the bounding box.

Parameters: none

Returns: Vector3 - center point of the AABB.

Example:

 b = AABB();
 v = b.CenterPoint();

Contains

Checks if the bounding box contains a point.

Parameters: (Vector3)

Returns: true if Vector3 parameter is contained within AABB, false if not.

Example:

 b = AABB();
 v = Vector3();
 if(b.Contains(v))
 {
 	print("v is inside b");
 }

Expand

Expands the bounding box to contain a position.

Parameters: (Vector3)

Returns: none

Example:

 b = AABB();
 v1 = Vector3(40,50,60);
 v2 = Vector3(30,10,90);
 b.Expand(v1);
 b.Expand(v2);

FindIntersection

Gets the AABB overlap of 2 bounding boxes.

Parameters: (AABB)

Returns: AABB the bounds that overlaps the bounding box. Null if there is no overlap.

Example:

 b = AABB();
 b2 = AABB();
 overlapAABB = b.FindIntersection(b2);
 if(overlapAABB)
 {
 	print("b overlaps b2");
 }

GetAxisLength

Gets the length of an axis of the bounding box.

Parameters: ("x"),("y"),or ("z")

Returns: float - length of requested AABB axis.

Example:

 b = AABB();
 xlen = b.GetAxisLength("x");

Intersects

Checks if 2 AABBs intersect.

Parameters: (AABB)

Returns: true if AABB overlaps this AABB, false if not.

Example:

 b = AABB();
 b2 = AABB();
 if(b.Intersects(b2))
 {
 	print("b touches b2");
 }

IsZero

Checks if the AABB is has no volume.

Parameters: none

Returns: true if the AABB is not defined(0,0,0 for mins and maxs)

Example:

 b = AABB();
 if(b.IsZero())
 {
 }

Scale

Scales the AABB by some amount in every direction.

Parameters: (float)

Returns: none

Example:

 b = AABB();
 b.Scale(10);

Set

Initializes the AABB mins and maxs.

Parameters: (Vector3, Vector3)

Returns: none

Example:

 b = AABB();
 min = Vector3(-10, -10, -10);
 max = Vector3(10, 10, 10);
 b.Set(min, max);

SetCenter

Translates the bounding box to some position. Usually used to move a local space bounding box to world space.

Parameters: (Vector3)

Returns: none

Example:

 b = AABB();
 c = Vector3(10, 10, 10);
 b.SetCenter(c);