This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::BoundSphere Class

Header: #include <UnigineBounds.h>

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

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

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

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

BoundSphere Class

Members


BoundSphere ( ) #

Constructor. Creates an empty bounding sphere.

BoundSphere ( const Math::vec3 & center, float radius ) #

Initialization by the center and radius of the bounding sphere.

Arguments

  • const Math::vec3 & center - The bounding sphere center.
  • float radius - The bounding sphere radius.

BoundSphere ( const Math::vec3 * points, int num_points, int optimal ) #

Initialization by the vector of points.

Arguments

  • const Math::vec3 * points - Vector of points.
  • int num_points - Number of points in the vector.
  • int optimal - Flag defining if the optimal sphere should be used. If 0, the sphere will be expanded for including all the given points.

BoundSphere ( const BoundSphere & bs ) #

Initialization by the bounding sphere.

Arguments

  • const BoundSphere & bs - The bounding sphere.

BoundSphere ( const BoundSphere & bs, const Math::mat4 & transform ) #

Initialization by the bounding sphere and setting the given transformation matrix to the new bounding sphere.

Arguments

  • const BoundSphere & bs - The bounding sphere.
  • const Math::mat4 & transform - Transformation matrix.

explicit BoundSphere ( const BoundBox & bb ) #

Initialization by the bounding box.

Arguments

BoundSphere & operator= ( const BoundSphere & bs ) #

Assignment operator for the bounding sphere.

Arguments

  • const BoundSphere & bs - The bounding sphere.

void clear ( ) #

Clears the bounding sphere.

void set ( const Math::vec3 & center, float radius ) #

Sets the bounding sphere by its center and radius.

Arguments

  • const Math::vec3 & center - Center of the bounding sphere.
  • float radius - Radius of the bounding sphere.

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

Set the bounding sphere by a vector of points.

Arguments

  • const Math::vec3 * points - Vector of points.
  • int num_points - Number of points in the vector.
  • int optimal - Flag defining if the optimal sphere should be used. If 0, the sphere will be expanded for including all the given points.

void set ( const BoundSphere & bs ) #

Sets the bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere.

void set ( const BoundSphere & bs, const Math::mat4 & transform ) #

Sets the bounding sphere by a bounding sphere with a transformation matrix taken into account.

Arguments

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

void set ( const BoundBox & bb ) #

Sets the bounding sphere by the bounding box.

Arguments

void setTransform ( const Math::mat4 & transform ) #

Sets the given transformation matrix to bounding sphere.

Arguments

  • const Math::mat4 & transform - Transformation matrix.

void setTransform ( const Math::dmat4 & transform ) #

Sets the given transformation matrix to bounding sphere.

Arguments

  • const Math::dmat4 & transform - Transformation matrix.

int compare ( const BoundSphere & bs ) #

Compares the bounding sphere with the given one. The degree of precision is equal to 1.0e-6f.

Arguments

  • const BoundSphere & bs - The bounding sphere to compare with.

Return value

1 if the radii and the centers of both bounding spheres are equal; otherwise, 0.

int operator== ( const BoundSphere & bs ) const#

Compares the bounding sphere with the given one according to the degree of precision equal to 1.0e-6f.

Arguments

  • const BoundSphere & bs - The bounding sphere to compare with.

Return value

1 if the radii and the centers of both bounding spheres are equal; otherwise, 0.

int operator!= ( const BoundSphere & bs ) const#

Bounding spheres not equal comparison operator.

Arguments

  • const BoundSphere & bs - The bounding sphere to compare with.

Return value

1 if the radii and the centers of both bounding spheres are not equal; otherwise, 0.

void expand ( const Math::vec3 & point ) #

Expands the current bounding sphere to include the given point.

Arguments

  • const Math::vec3 & point - Coordinates of the point.

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

Expands the current bounding sphere for including all points in the vector.

Arguments

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

void expand ( const BoundSphere & bs ) #

Expands the current bounding sphere to include the given bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere to be included.

void expand ( const BoundBox & bb ) #

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

Arguments

  • const BoundBox & bb - Bounding box to be included.

void expandRadius ( const Math::vec3 & point ) #

Expands the radius of the bounding sphere.
Source code (C++)
float r = length(center - point);
if (center.w < r)
	radius = r;

Arguments

  • const Math::vec3 & point - Point coordinates setting the end point of radius.

void expandRadius ( const Math::vec3 * points, int num_points ) #

Expands the radius of the current bounding sphere for including all points in the vector.

Arguments

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

void expandRadius ( const BoundSphere & bs ) #

Expands the radius of the bounding sphere by using the radius of the given bounding sphere.
Source code (C++)
float r = length(bs.center - center) + bs.radius;
if (center.w < r)
	radius = r;

Arguments

  • const BoundSphere & bs - Bounding sphere.

void expandRadius ( const BoundBox & bb ) #

Expands the radius of the bounding sphere by using the max and min points of the given bounding box. It uses the expandRadius method.
Source code (C++)
const vec3 &min = bb.getMin();
const vec3 &max = bb.getMax();
expandRadius(vec3(min.x, min.y, min.z));
expandRadius(vec3(max.x, min.y, min.z));
expandRadius(vec3(min.x, max.y, min.z));
expandRadius(vec3(max.x, max.y, min.z));
expandRadius(vec3(min.x, min.y, max.z));
expandRadius(vec3(max.x, min.y, max.z));
expandRadius(vec3(min.x, max.y, max.z));
expandRadius(vec3(max.x, max.y, max.z));

Arguments

int inside ( const Math::vec3 & point ) const#

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

Arguments

  • const Math::vec3 & point - Point coordinates.

Return value

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

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

Checks if the sphere is inside the bounding sphere.

Arguments

  • const Math::vec3 & point - Center of the sphere.
  • float radius - Radius of the sphere.

Return value

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

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

Checks if the box is inside the bounding sphere.

Arguments

  • const Math::vec3 & min - The box minimum coordinates.
  • const Math::vec3 & max - The box maximum coordinates.

Return value

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

int inside ( const BoundSphere & bs ) const#

Checks if the specified bounding sphere is inside the bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

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

int inside ( const BoundBox & bb ) const#

Checks if the bounding box is inside the bounding sphere.

Arguments

Return value

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

int insideValid ( const Math::vec3 & point ) const#

Checks if the given point is inside the current bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

  • const Math::vec3 & point - Point.

Return value

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

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

Checks if the given sphere is inside the current bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

  • const Math::vec3 & point - Cente of the sphere.
  • float radius - Radius of the sphere.

Return value

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

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

Checks if the box is inside the bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

  • const Math::vec3 & min - The box minimum coordinates.
  • const Math::vec3 & max - The box maximum coordinates.

Return value

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

int insideValid ( const BoundSphere & bs ) const#

Checks if the bounding sphere is inside the bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

  • const BoundSphere & bs - The bounding sphere.

Return value

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

int insideValid ( const BoundBox & bb ) const#

Checks if the bounding box is inside the bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

Return value

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

int insideAll ( const BoundSphere & bs ) const#

Checks if the whole specified bounding sphere is inside the current bounding sphere.

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

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

int insideAll ( const BoundBox & bb ) const#

Checks if the whole specified bounding box is inside the current bounding sphere.

Arguments

Return value

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

int insideAllValid ( const BoundSphere & bs ) const#

Checks if the whole given bounding sphere is inside the current bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

  • const BoundSphere & bs - Bounding sphere.

Return value

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

int insideAllValid ( const BoundBox & bb ) const#

Checks if the whole given bounding box is inside the current bounding sphere.
Notice
The method doesn't check if the bounding sphere is valid (has a positive radius).

Arguments

Return value

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

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

Checks for an intersection of a ray with the current bounding sphere.

Arguments

  • const Math::vec3 & point - The starting point of the ray.
  • const Math::vec3 & direction - The direction vector of the ray.

Return value

1 if an intersection has occurred; otherwise, 0.

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

Checks for an intersection of a line with the current bounding sphere.

Arguments

  • const Math::vec3 & p0 - The starting point of the line.
  • const Math::vec3 & p1 - The ending point of the line.

Return value

1 if an intersection has occurred; otherwise, 0.

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

Checks for an intersection of a ray with the current bounding sphere.
Notice
This method doesn't check if the current bounding sphere is valid (has a positive radius).

Arguments

  • const Math::vec3 & point - The starting point of the ray.
  • const Math::vec3 & direction - The direction vector of the ray.

Return value

1 if an intersection has occurred; otherwise, 0.

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

Checks for an intersection of a line with the current bounding sphere.
Notice
This method doesn't check if the current bounding sphere is valid (has a positive radius).

Arguments

  • const Math::vec3 & p0 - The starting point of the line.
  • const Math::vec3 & p1 - The ending point of the line.

Return value

1 if an intersection has occurred; otherwise, 0.

float distance ( ) const#

Returns the distance from the origin of coordinates to the closest point of the current bounding sphere.

Return value

Distance from the origin, in units.

float distance ( const Math::vec3 & point ) const#

Returns the distance from the given point to the closest point of the current bounding sphere.

Arguments

  • const Math::vec3 & point - Coordinates of the point.

Return value

Distance from the point, in units.

float distanceValid ( ) const#

Returns the distance from the origin of coordinates to the closest point of the current bounding sphere.

Return value

Distance from the origin, in units.

float distanceValid ( const Math::vec3 & point ) const#

Returns the distance from the given point to the closest point of the current bounding sphere.

Arguments

  • const Math::vec3 & point - Point

Return value

Distance from the point, in units.

Math::vec3 getCenter ( ) const#

Returns the bounding sphere center.

Return value

Bounding sphere center.

float getRadius ( ) const#

Returns the bounding sphere radius.

Return value

The bounding sphere radius.

bool isValid ( ) const#

Checks the bounding sphere status.

Return value

true if the bounding sphere radius has a positive value; otherwise, false.
Last update: 2021-04-09
Build: ()