UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
FAQ
编程
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
应用程序接口
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes

Unigine::BoundBox Class

Header: #include <UnigineBounds.h>

This class serves to construct the bounding box in single precision coordinates.

Notice
Instances of this class are deleted automatically when it is necessary.

In case of double precision coordinates, the bounding box should be constructed by using the WorldBoundBox class. It includes the same functions as the BoundBox class, but its functions deal with the double precision coordinates.

Notice
To support both single and double precision builds, you can use the WorldBoundBox class only. The engine will automatically substitute it with the BoundBox if it is required.

BoundBox Class

Members


BoundBox ( ) #

Constructor. Creates an empty bounding box.

BoundBox ( const vec3 & min, const vec3 & max ) #

Initialization by minimum and maximum coordinates of the bounding box.

Arguments

  • const vec3 & min - Bounding box minimum coordinates.
  • const vec3 & max - Bounding box maximum coordinates.

BoundBox ( const BoundBox & bb ) #

Initialization by the bounding box.

Arguments

  • const BoundBox & bb - Bounding box.

explicit BoundBox ( const BoundSphere & bs ) #

Initialization by the bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere.

BoundBox ( const BoundBox & bb, const mat4 & transform ) #

Initialization by the bounding box with the transformation matrix taken into account.

Arguments

  • const BoundBox & bb -
  • const mat4 & transform -

BoundBox ( const vec3 * points, int num_points ) #

Initialization by the vector of points.

Arguments

  • const vec3 * points - Vector of points.
  • int num_points - Number of points.

void set ( const vec3 & min, const vec3 & max ) #

Sets the bounding box by its minimum and maximum coordinates.

Arguments

  • const vec3 & min - Bounding box minimum coordinates.
  • const vec3 & max - Bounding box maximum coordinates.

void set ( const BoundSphere & bs ) #

Sets the bounding box by the bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere.

void set ( const BoundBox & bb ) #

Sets the bounding box equal to the specified source bounding box.

Arguments

  • const BoundBox & bb - Source bounding box.

void set ( const vec3 * points, int num_points ) #

Sets the bounding box by the coordinates of points in space to be enclosed by it.

Arguments

  • const vec3 * points - List of points to be enclosed by the bounding box.
  • int num_points - Number of points to be enclosed by the bounding box.

void set ( const BoundBox & bb, const mat4 & transform ) #

Sets the bounding box by the given bounding box with the given transformation matrix taken into account.

Arguments

  • const BoundBox & bb - Bounding box.
  • const mat4 & transform - Transformation matrix.

const vec3 & getMax ( ) # const

Returns the maximum coordinates of the bounding box.

Return value

Bounding box maximum coordinates.

const vec3 & getMin ( ) # const

Returns the minimum coordinates of the bounding box.

Return value

Bounding box minimum coordinates.

void setTransform ( const mat4 & transform ) #

Sets the given transformation matrix to the bounding box.

Arguments

  • const mat4 & transform - Transformation matrix.

void setTransform ( const dmat4 & transform ) #

Sets the given transformation matrix to the bounding box.

Arguments

  • const dmat4 & transform - Transformation matrix.

void setTransform ( const BoundSphere & bs, const mat4 & transform ) #

Sets the transformation matrix of the current bounding box for including the given bounding sphere with the given tranformation matrix taken into account.

Arguments

  • const BoundSphere & bs - Bounding sphere.
  • const mat4 & transform - Transformation matrix.

void setTransform ( const BoundSphere & bs, const dmat4 & transform ) #

Sets the transformation matrix of the current bounding box for including the given bounding sphere with the given tranformation matrix taken into account.

Arguments

  • const BoundSphere & bs - Bounding sphere.
  • const dmat4 & transform - Transformation matrix.

int isValid ( ) # const

Checks the bounding box status.

Return value

1 if the bounding box minimum and maximum coordinates are valid; otherwise, 0.

void clear ( ) #

Clears the bounding box.

void expand ( const BoundSphere & bs ) #

Expands the current bounding box to enclose the given bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere.

void expand ( const BoundBox & bb ) #

Expands the current bounding box to enclose the given bounding box.

Arguments

  • const BoundBox & bb - Bounding box.

void expand ( const vec3 & point ) #

Expands the current bounding box to enclose the given point.

Arguments

  • const vec3 & point - Point coordinates.

void expand ( const vec3 * points, int num_points ) #

Expands the current bounding box to enclose all given points.

Arguments

  • const vec3 * points - List of points to be enclosed by the bounding box.
  • int num_points - Number of points to be enclosed by the bounding box.

int inside ( const vec3 & point, float radius ) # const

Checks if the sphere is inside the bounding box.

Arguments

  • const vec3 & point - Coordinates of the center of the sphere.
  • float radius - Sphere radius.

Return value

1 if the sphere is inside the bounding box; otherwise, 0.

int insideValid ( const vec3 & point, float radius ) #

Checks if the sphere is inside the bounding box.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

Arguments

  • const vec3 & point - Coordinates of the center of the sphere.
  • float radius - Sphere radius.

Return value

1 if the sphere is inside the bounding box; otherwise, 0.

int inside ( const vec3 & min, const vec3 & max ) # const

Checks if the box is inside the bounding box.

Arguments

  • const vec3 & min - Box minimum coordinates.
  • const vec3 & max - Box maximum coordinates.

Return value

1 if the box is inside the bounding box; otherwise, 0.

int insideValid ( const vec3 & min, const vec3 & max ) #

Checks if the box is inside the bounding box.

Arguments

  • const vec3 & min - Box minimum coordinates.
  • const vec3 & max - Box maximum coordinates.

Return value

1 if the box is inside the bounding box; otherwise, 0.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

int inside ( const BoundSphere & bs ) # const

Checks if the bounding sphere is inside the bounding box.

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

1 if the bounding sphere is inside the bounding box; otherwise, 0.

int insideValid ( const BoundSphere & bs ) #

Checks if the bounding sphere is inside the bounding box.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

1 if the bounding sphere is inside the bounding box; otherwise, 0.

int inside ( const BoundBox & bb ) # const

Checks if the bounding box is inside the bounding box.

Arguments

  • const BoundBox & bb - Bounding box.

Return value

1 if the bounding box is inside the bounding box; otherwise, 0.

int insideValid ( const BoundBox & bb ) #

Checks if the bounding box is inside the bounding box.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

Arguments

  • const BoundBox & bb - Bounding box.

Return value

1 if the bounding box is inside the bounding box; otherwise, 0.

int inside ( const vec3 & point ) #

Checks if the given point is inside the bounding box.

Arguments

  • const vec3 & point - Point.

Return value

1 if the point is inside the bounding box; otherwise, 0.

int insideValid ( const vec3 & point ) #

Checks if the given point is inside the bounding box.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

Arguments

  • const vec3 & point - Point.

Return value

1 if the point is inside the bounding box; otherwise, 0.

int insideAll ( const BoundBox & bb ) #

Checks if the whole given bounding box is inside the current bounding box.

Arguments

  • const BoundBox & bb - Bounding box.

Return value

1 if the whole bounding box is inside the bounding box; otherwise, 0.

int insideAllValid ( const BoundBox & bb ) #

Checks if the whole given bounding box is inside the current bounding box.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

Arguments

  • const BoundBox & bb - Bounding box.

Return value

1 if the whole bounding box is inside the bounding box; otherwise, 0.

int insideAll ( const BoundSphere & bs ) #

Checks if the given bounding sphere is inside the current bounding box.

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

1 if the whole bounding sphere is inside the bounding box; otherwise, 0.

int insideAllValid ( const BoundSphere & bs ) #

Checks if the given bounding sphere is inside the current bounding box.
Notice
The method doesn't check if the minimum and maximum coordinates of the current bounding box are valid.

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

1 if the whole bounding sphere is inside the bounding box; otherwise, 0.

int insideCube ( int face, const vec3 & offset ) #

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.
  • const vec3 & offset - Offset.

Return value

1 if the face is inside the bounding cube; otherwise, 0.

int compare ( const BoundBox & bb ) #

Compares the current bounding box with the given one.

Arguments

  • const BoundBox & bb - The bounding box to compare with.

Return value

1 if the size and position of both bounding boxes are equal; otherwise, 0.

int operator== ( const BoundBox & bb ) #

Compares the current bounding box with the given one.

Arguments

  • const BoundBox & bb - The bounding box to compare with.

Return value

1 if the size and position of both bounding boxes are equal; otherwise, 0.

int operator!= ( const BoundBox & bb ) #

Bounding boxes not equal comparison operator.

Arguments

  • const BoundBox & bb - The bounding box to compare with.

Return value

1 if the size and position of both bounding boxes are not equal; otherwise, 0.

BoundBox & operator= ( const BoundBox & bb ) #

Assignment operator for the bounding box.

Arguments

  • const BoundBox & bb - Bounding box.

Return value

Bounding box.

int rayIntersection ( const vec3 & point, const vec3 & direction ) #

Checks for an intersection between a ray and the current bounding box.

Arguments

  • const vec3 & point - Starting point of the ray.
  • const vec3 & direction - Direction vector of the ray.

Return value

1 if the given ray intersects the bounding box; otherwise, 0.

int irayIntersection ( const vec3 & point, const vec3 & 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

  • const vec3 & point - Starting point of the ray.
  • const vec3 & idirection - Inverse direction of the ray.

Return value

1 if the given ray intersects the bounding box; otherwise, 0.

int getIntersection ( const vec3 & p0, const vec3 & p1 ) #

Checks for an intersection between a line and the current bounding box.

Arguments

  • const vec3 & p0 - Starting point of the line.
  • const vec3 & p1 - Enging point of the line.

Return value

1 if the given line intersects the bounding box; otherwise, 0.

int rayIntersectionValid ( const vec3 & point, const vec3 & direction ) #

Checks for an intersection between a ray and the current bounding box.
Notice
This function doesn't check if the minimum and maximum coordinates of the bounding box are valid.

Arguments

  • const vec3 & point - Starting point of the ray.
  • const vec3 & direction - Direction vector of the ray.

Return value

1 if the given ray intersects the bounding box; otherwise, 0.

int irayIntersectionValid ( const vec3 & point, const vec3 & 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.
Notice
This function doesn't check if the minimum and maximum coordinates of the bounding box are valid.

Arguments

  • const vec3 & point - Starting point of the ray.
  • const vec3 & idirection - Inverse direction of the ray.

Return value

1 if the given ray intersects the bounding box; otherwise, 0.

int getIntersectionValid ( const vec3 & p0, const vec3 & p1 ) #

Checks for an intersection between a line and the current bounding box.
Notice
This function doesn't check if the minimum and maximum coordinates of the bounding box are valid.

Arguments

  • const vec3 & p0 - Starting point of the line.
  • const vec3 & p1 - Enging point of the line.

Return value

1 if the given line intersects the bounding box; otherwise, 0.

float distance ( ) #

Returns the distance from the origin of coordinates to the closest vertex of the bounding box.

Return value

Distance in units if the minimum and maximum coordinated of the bounding box are valid; otherwise, UNIGINE_INFINITY.

float distance ( const vec3 & point ) #

Returns the distance from the given point to the closest vertex of the bounding box.

Arguments

  • const vec3 & point - Point.

Return value

Distance in units if the minimum and maximum coordinated of the bounding box are valid; otherwise, UNIGINE_INFINITY.

float distanceValid ( ) #

Returns the distance from the origin of coordinates to the closest vertex of the bounding box.

Return value

Distance, in units.

float distanceValid ( const vec3 & point ) #

Returns the distance from the given point to the closest vertex of the bounding box.

Arguments

  • const vec3 & point - Point.

Return value

Distance, in units.

void getPoints ( vec3 * points, int num_points ) #

Puts the vertices of the current bounding box into the given vector.

Arguments

  • vec3 * points - Target vector.
  • int num_points - Number of points, must be equal to 8.

void getPlanes ( vec4 * planes, int num_planes ) #

Puts the planes created based on the vertices of the current bounding box into the given vector.

Arguments

  • vec4 * planes - Target vector.
  • int num_planes - Number of planes, must be equal to 6.

vec3 getCenter ( ) #

Returns the center point of the current bounding box.

Return value

Center point.
Last update: 2019-11-28