This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
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
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Сэмплы материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

Unigine.WorldBoundFrustum Struct

Notice
The functions listed below are the members of the Unigine.MathLib namespace.

This structure serves to construct the bounding frustum in double precision coordinates.

WorldBoundFrustum enables you to check:

  • if the specified bound volume (box, sphere, or other frustum) gets inside the frustum (even partially) - use Inside( bound ) methods for this purpose.
  • if the specified bound volume (box, sphere, or other frustum) is inside the frustum completely - use InsideAll( bound ) methods for this purpose.
  • if certain points of your object are inside the frustum (may be necessary in case more accurate results are required than the ones obtained using the two methods above) - here you should use Inside( point ) methods and check all points of interest.
Notice
Make sure that you use proper aspect-corrected projection for the frustum when necessary. See the picture in the spoiler below: red - default projection matrix, green - aspect-corrected projection matrix.


Usage Example#

For example you can use a WorldBoundFrustum in order to check whether a node is inside the viewing frustum of a camera. Check the component below.

Source code (C#)
using System;
using System.Collections;
using System.Collections.Generic;
using Unigine;

#region Math Variables
#if UNIGINE_DOUBLE
using WorldBoundFrustum = Unigine.WorldBoundFrustum;
using Mat4 = Unigine.dmat4;
#else
using WorldBoundFrustum = Unigine.BoundFrustum;
using Mat4 = Unigine.mat4;
#endif
#endregion

[Component(PropertyGuid = "AUTOGENERATED_GUID")] // <-- this line is generated automatically for a new component
public class FrustumChecker : Component
{
	private void Init()
	{
		// write here code to be called on component initialization
		
	}
	
	private void Update()
	{
		// getting the current camera
		Camera camera = Game.Player.Camera;

		// getting the main window of the application
		EngineWindow main_window = WindowManager.MainWindow;
		if (!main_window)
			Engine.Quit();

		// calculating the current aspect ratio to obtain proper aspect-corrected projection matrix
		// default projection matrix does not take aspect ratio into account
		ivec2 main_size = main_window.Size;
		float aspect = (float)main_size.y / main_size.x;
		mat4 proj = camera.GetAspectCorrectedProjection(aspect);

		// getting model-view matrix of the camera
		Mat4 model_view = camera.Modelview;
		WorldBoundFrustum bfrustum = new WorldBoundFrustum(proj, model_view);

		// checking if the node's bound gets inside the viewing frustum of the camera
		if (bfrustum.Inside(node.WorldBoundBox)){
			Log.Message("Node's bound is visible inside the frustum.");
		
			// checking whether the bound is completely or partially inside the frustum
			Log.Message(bfrustum.InsideAll(node.WorldBoundBox) ? " COMPLETELY!\n": " PARTIALLY!\n");
			
			// checking whether a certain point of the object (WorldPosition here) is inside the frustum
			Log.Message(bfrustum.Inside(node.WorldPosition) ? "(The point is INSIDE)\n": "(The point is OUTSIDE)\n");
		}
		else
			Log.Message("Node's bound is outside the frustum.\n");

		// displaying node's BoundBox, the Bound Frustum, and a point using the Visualizer
		Visualizer.RenderFrustum(proj, MathLib.Inverse(model_view), new vec4(1.0f, 0.0f,0.0f,1.0f));
		Visualizer.RenderBoundBox(node.BoundBox, node.Transform, new vec4(0.0f, 1.0f, 0.0f, 1.0f));
		Visualizer.RenderSphere(0.01f, MathLib.Translate(node.WorldPosition), new vec4(1.0f, 0.0f, 0.0f, 1.0f));
	}
}

WorldBoundFrustum Class

Members


void Set ( mat4 projection, dmat4 modelview ) #

Sets the bounding frustum by the projection and modelview matrices.

Arguments

  • mat4 projection - Projection matrix.
  • dmat4 modelview - Modelview matrix.

void Set ( WorldBoundFrustum bf ) #

Sets the bounding frustum using the specified argument.

Arguments

void Set ( BoundFrustum bf ) #

Sets the bounding frustum using the specified argument.

Arguments

void Set ( WorldBoundFrustum bf, dmat4 itransform ) #

Sets the bounding frustum using the specified arguments.

Arguments

void Set ( BoundFrustum bf, dmat4 itransform ) #

Sets the bounding frustum using the specified arguments.

Arguments

  • BoundFrustum bf - Bounding frustum.
  • dmat4 itransform - The inverse transformation matrix.

void Clear ( ) #

Clears the bounding frustum by setting all components/elements to 0.

bool Equals ( WorldBoundFrustum other ) #

Checks if the current bounding frustum and the specified argument are equal considering the predefined accuracy (epsilon).

Arguments

Return value

true if the current bounding frustum is equal to the given one; otherwise, false.

bool EqualsNearly ( WorldBoundFrustum other, double epsilon ) #

Checks if the current bounding frustum and the specified argument represent the same value with regard to the specified accuracy (epsilon).

Arguments

  • WorldBoundFrustum other - Value to be checked for equality.
  • double epsilon - Epsilon value, that determines accuracy of comparison.

Return value

true if the current bounding frustum is equal to the given one; otherwise, false.

bool Equals ( object obj ) #

Checks if the current bounding frustum and the specified argument are equal considering the predefined accuracy (epsilon).

Arguments

Return value

true if the current bounding frustum is equal to the given object; otherwise, false.

int GetHashCode ( ) #

Returns a hash code for the current bounding frustum. Serves as the default hash function.

Return value

Hash code.

void SetITransform ( dmat4 itransform ) #

Sets the transformation matrix by an inverse transformation matrix.

Arguments

  • dmat4 itransform - The inverse transformation matrix.

void SetTransform ( dmat4 transform ) #

Sets the transformation matrix.

Arguments

  • dmat4 transform - Transformation matrix (dmat4) to be set.

WorldBoundFrustum operator* ( dmat4 m, WorldBoundFrustum bf ) #

Multiplies the matrix by the bounding frustum and returns the resulting bounding frustum.

Arguments

Return value

Resulting bounding frustum.

void Expand ( double radius ) #

Expands the current bounding frustum by the given radius.

Arguments

  • double radius - Radius.

bool Inside ( dvec3 point ) #

Checks if the point is inside the bounding frustum.

Arguments

  • dvec3 point - The coordinates of the point.

Return value

true if the point is inside the bounding frustum; otherwise, false.

bool Inside ( dvec3 point, double radius ) #

Checks if the sphere is inside the bounding frustum.

Arguments

  • dvec3 point - The coordinates of the center of the sphere.
  • double radius - The sphere radius.

Return value

true if the sphere is inside the bounding frustum; otherwise, false.

bool Inside ( dvec3 p_min, dvec3 p_max ) #

Checks if the box is inside the bounding frustum.

Arguments

  • dvec3 p_min - Minimum coordinate of the box.
  • dvec3 p_max - Maximum coordinate of the box.

Return value

true if the box is inside the bounding frustum; otherwise, false.

bool Inside ( dvec3[] points ) #

Checks if the bound specified in the argument is inside the current bound.

Arguments

  • dvec3[] points - Array of points.

Return value

true if the points are inside the bounding frustum; otherwise, false.

bool InsideFast ( dvec3 point ) #

Performs a fast check if the point is inside the bounding frustum.

Arguments

  • dvec3 point - Point coordinates.

Return value

true if the point is inside the bounding frustum; otherwise, false.

bool InsideFast ( dvec3 point, double radius ) #

Performs a fast check if the sphere is inside the bounding frustum.

Arguments

  • dvec3 point - Center point.
  • double radius - Radius.

Return value

true if the sphere is inside the bounding frustum; otherwise, false.

bool InsideFast ( dvec3 p_min, dvec3 p_max ) #

Performs a fast check if the box is inside the bounding frustum.

Arguments

  • dvec3 p_min - Minimum coordinate of the box.
  • dvec3 p_max - Maximum coordinate of the box.

Return value

true if the box is inside the bounding frustum; otherwise, false.

bool InsideFast ( dvec3[] points ) #

Performs a fast check if the set of points is inside the bounding frustum.

Arguments

  • dvec3[] points - Vector of points.

Return value

true if the point is inside the bounding frustum; otherwise, false.

bool Inside ( WorldBoundSphere bs ) #

Checks if the bounding sphere is inside the bounding frustum.

Arguments

Return value

true if the bounding sphere is inside the bounding frustum; otherwise, false.

bool Inside ( WorldBoundBox bb ) #

Checks if the bounding box is inside the bounding frustum.

Arguments

Return value

true if the bounding box is inside the bounding frustum; otherwise, false.

bool Inside ( WorldBoundFrustum bf ) #

Checks if the specified bounding frustum is inside the current bounding frustum.

Arguments

Return value

true if the specified bounding frustum is inside the bounding frustum; otherwise, false.

bool InsideValid ( WorldBoundSphere bs ) #

Checks if the given bounding sphere is inside the bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check if the minimum and maximum coordinates of the current bound are valid.

Arguments

Return value

true if the given bounding sphere is inside the bounding frustum; otherwise, false.

bool InsideValid ( WorldBoundBox bb ) #

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

Arguments

Return value

true if the given bounding box is inside the bounding frustum; otherwise, false.

bool InsideValid ( WorldBoundFrustum bf ) #

Checks if the given bounding frustum is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check if the minimum and maximum coordinates of the current bound are valid.

Arguments

Return value

true if the given bounding frustum is inside the bounding frustum; otherwise, false.

bool InsideValidFast ( WorldBoundSphere bs ) #

Performs a fast check if the given bounding sphere is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding sphere is inside the bounding frustum; otherwise, false.

bool InsideValidFast ( WorldBoundBox bb ) #

Performs a fast check if the given bounding box is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding box is inside the bounding frustum; otherwise, false.

bool InsideValidFast ( WorldBoundFrustum bf ) #

Performs a fast check if the given bounding frustum is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding frustum is inside the bounding frustum; otherwise, false.

bool InsideAll ( WorldBoundSphere bs ) #

Checks if the whole given bounding sphere is inside the current bounding frustum.

Arguments

Return value

true if the whole bounding sphere is inside the bounding frustum; otherwise, false.

bool InsideAll ( WorldBoundBox bb ) #

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

Arguments

Return value

true if the whole bounding box is inside the bounding frustum; otherwise, false.

bool InsideAll ( WorldBoundFrustum bf ) #

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

Arguments

Return value

true if the whole specified bounding frustum is inside the current bounding frustum; otherwise, false.

bool InsideAllValid ( WorldBoundSphere bs ) #

Checks if the whole given bounding sphere is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check if the minimum and maximum coordinates of the current bound are valid.

Arguments

Return value

true if the given bounding sphere is inside the bounding frustum; otherwise, false.

bool InsideAllValid ( WorldBoundBox bb ) #

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

Arguments

Return value

true if the given bounding box is inside the bounding frustum; otherwise, false.

bool InsideAllValid ( WorldBoundFrustum bf ) #

Checks if the whole given bounding frustum is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check if the minimum and maximum coordinates of the current bound are valid.

Arguments

Return value

true if the given bounding frustum is inside the bounding frustum; otherwise, false.

bool InsideAllValidFast ( WorldBoundSphere bs ) #

Performs a fast check if the whole given bounding sphere is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding sphere is inside the bounding frustum; otherwise, false.

bool InsideAllValidFast ( WorldBoundBox bb ) #

Performs a fast check if the whole given bounding box is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding box is inside the bounding frustum; otherwise, false.

bool InsideAllValidFast ( WorldBoundFrustum bf ) #

Performs a fast check if the whole given bounding frustum is inside the current bounding frustum (assuming that the current bound coordinates are valid).
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding frustum is inside the bounding frustum; otherwise, false.

bool InsidePlanes ( WorldBoundSphere bs ) #

Checks if the given bounding sphere is inside the volume defined by the planes of the current bounding frustum.

Arguments

Return value

true if the given bounding sphere is inside the volume; otherwise, false.

bool InsidePlanes ( WorldBoundBox bb ) #

Checks if the given bounding box is inside the volume defined by the planes of the current bounding frustum.

Arguments

Return value

true if the given bounding box is inside the volume; otherwise, false.

bool InsidePlanes ( WorldBoundFrustum bf ) #

Checks if the given bounding frustum is inside the volume defined by the planes of the current bounding frustum.

Arguments

Return value

true if the given bounding frustum is inside the volume; otherwise, false.

bool InsidePlanesValid ( WorldBoundSphere bs ) #

Checks if the given bounding sphere is inside the volume defined by the planes of the current bounding frustum.
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding sphere is inside the volume; otherwise, false.

bool InsidePlanesValid ( WorldBoundBox bb ) #

Checks if the given bounding box is inside the volume defined by the planes of the current bounding frustum.
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding box is inside the volume; otherwise, false.

bool InsidePlanesValid ( WorldBoundFrustum bf ) #

Checks if the given bounding frustum is inside the volume defined by the planes of the current bounding frustum.
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding frustum is inside the volume; otherwise, false.

bool InsidePlanesValidFast ( WorldBoundSphere bs ) #

Performs a fast check if the given bounding sphere is inside the volume defined by the planes of the current bounding frustum.
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding sphere is inside the volume; otherwise, false.

bool InsidePlanesValidFast ( WorldBoundBox bb ) #

Performs a fast check if the given bounding box is inside the volume defined by the planes of the current bounding frustum.
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding box is inside the volume; otherwise, false.

bool InsidePlanesValidFast ( WorldBoundFrustum bf ) #

Performs a fast check if the given bounding frustum is inside the volume defined by the planes of the current bounding frustum.
Notice
The method doesn't check the status of the current bound.

Arguments

Return value

true if the given bounding frustum is inside the volume; otherwise, false.
Last update: 23.06.2023
Build: ()