WorldBoundBox Class
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScipt (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
This class serves to construct the bounding box in double precision coordinates.
Bounding boxes has better precision quality but it takes more time for calculation in comparison with bounding spheres.
By using this class you can easily find the common bounding box for several objects by expanding the bounding box.
WorldBoundBox Class
Members
static WorldBoundBox ( ) #
Default constructor. Creates an empty bounding box.WorldBoundBox ( dvec3 min, dvec3 max ) #
Constructor. Initializes new bounding box by minimum and maximum coordinates of the bounding box.Arguments
- dvec3 min - The bounding box minimum coordinates.
- dvec3 max - The bounding box maximum coordinates.
WorldBoundBox ( WorldBoundBox bb ) #
Constructor. Initializes new bounding box by using given bounding box.Arguments
- WorldBoundBox bb - Bounding box.
WorldBoundBox ( WorldBoundSphere bs ) #
Constructor. Initializes new bounding box by the using given bounding sphere.Arguments
- WorldBoundSphere bs - Bounding sphere.
WorldBoundBox ( BoundBox bb, dmat4 transform ) #
Arguments
- BoundBox bb
- dmat4 transform
void clear ( ) #
Clears the bounding box.void set ( dvec3 min, dvec3 max ) #
Sets the bounding box by its minimum and maximum coordinates.Arguments
- dvec3 min - Minimum coordinates of the bounding box.
- dvec3 max - Maximum coordinates of the bounding box.
void set ( dvec3[] points ) #
Sets the bounding box by the coordinates of points in space to be enclosed by it.Arguments
- dvec3[] points - Array of points to be enclosed by the bounding box.
void set ( BoundBox bb, dmat4 transform ) #
Sets the bounding box by the given bounding box with the given transformation matrix taken into account.Arguments
- BoundBox bb - Source bounding box.
- dmat4 transform - Transformation matrix.
void set ( WorldBoundSphere bs ) #
Sets the bounding box by the bounding sphere.Arguments
- WorldBoundSphere bs - The bounding sphere.
void set ( WorldBoundBox bb ) #
Sets the bounding box.Arguments
- WorldBoundBox bb - The bounding box.
void setTransform ( dmat4 transform ) #
Sets the given transformation matrix to the bounding box.Arguments
- dmat4 transform - Transformation matrix.
int compare ( WorldBoundBox bb ) #
Compares the current bounding box with the given one.Arguments
- WorldBoundBox bb - The bounding box to compare with.
Return value
1 if the size and position of both bounding boxes are equal; otherwise, 0.void expand ( dvec3 point ) #
Expands the current bounding box to include the given point.Arguments
- dvec3 point - Coordinates of the point.
void expand ( dvec3[] points ) #
Expands the current bounding box to enclose all given points.Arguments
- dvec3[] points - Array of points to be enclosed by the bounding box.
void expand ( WorldBoundSphere bs ) #
Expands the current bounding box to include the given bounding sphere.Arguments
- WorldBoundSphere bs - The bounding sphere.
void expand ( WorldBoundBox bb ) #
Expands the current bounding box to include the given bounding box.Arguments
- WorldBoundBox bb - The bounding box.
int inside ( dvec3 point ) #
Checks if the specified point is inside the current bounding box.Arguments
- dvec3 point - Coordinates of the point.
Return value
1 if the point is inside the bounding box; otherwise, 0.int inside ( dvec3 point, double radius ) #
Checks if the specified sphere is inside the current bounding box.Arguments
- dvec3 point - The coordinates of the center of the sphere.
- double radius - The sphere radius.
Return value
1 if the sphere is inside the bounding box; otherwise, 0.int inside ( dvec3 min, dvec3 max ) #
Checks if the given box is inside the current bounding box.Arguments
- dvec3 min - Minimum coordinates of the box.
- dvec3 max - Maximum coordinates of the box.
Return value
1 if the box is inside the bounding box; otherwise, 0.int inside ( WorldBoundSphere bs ) #
Checks if the specified bounding sphere is inside the current bounding box.Arguments
- WorldBoundSphere bs - The bounding sphere.
Return value
1 if the bounding sphere is inside the bounding box; otherwise, 0.int inside ( WorldBoundBox bb ) #
Checks if the given bounding box is inside the current bounding box.Arguments
- WorldBoundBox bb - The bounding box.
Return value
1 if the bounding box is inside the bounding box; otherwise, 0.int insideAll ( WorldBoundSphere bs ) #
Checks if the whole given bounding sphere is inside the current bounding box.Arguments
- WorldBoundSphere bs - The bounding sphere.
Return value
1 if the whole sphere is inside the bounding box; otherwise, 0.int insideAll ( WorldBoundBox bb ) #
Checks if the whole given bounding box is inside the current bounding box.Arguments
- WorldBoundBox bb - The bounding box.
Return value
1 if the whole box is inside the bounding box; otherwise, 0.int insideCube ( int face, dvec3 point ) #
Checks if a face of the current bounding box is inside the cube represented by minimum and maximum coordinates of the bounding box.Arguments
- int face - The face index from 0 to 5.
- dvec3 point - Offset.
Return value
1 if the face is inside the bounding cube; otherwise, 0.int irayIntersectionValid ( dvec3 p, dvec3 idirection ) #
Checks for an intersection between a ray and the current bounding box. This function uses the inverse direction of the ray, which increases performance.Arguments
- dvec3 p - Starting point of the ray.
- dvec3 idirection - Inverse direction of the ray.
Return value
1 if the given ray intersects the bounding box; otherwise, 0.double distanceValid ( dvec3 point ) #
Returns the distance from the given point to the closest vertex of the bounding box.Arguments
- dvec3 point - Coordinates of the point.
Return value
Distance from the given point to the closest vertex of the bounding box, in units.bool isValid ( ) #
Checks if the bounding box coordinates are valid (minimum coordinate along the X axis is less or equal to the maximum coordinate along the X axis).Return value
true if the bounding box minimum and maximum coordinates are valid, otherwise, false.dvec3 getMin ( ) #
Returns the minimum coordinates of the bounding box.Return value
Bounding box minimum coordinates.dvec3 getMax ( ) #
Returns the maximum coordinates of the bounding box.Return value
Bounding box maximum coordinates.dvec3 getCenter ( ) #
Returns the center point of the current bounding box.Return value
Center point.Last update:
2020-07-31
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)