This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Физика
Браузер SDK 2
Лицензирование и типы лицензий
Дополнения (Add-Ons)
Демонстрационные проекты
API Samples
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
Унифицированный язык шейдеров UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
Справочник API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Matrix
Textures
Art Samples
Учебные материалы

Cross Node


Description

This node computes the cross product of two float3 vectors A and B, resulting in a vector that is perpendicular to both and serves as the normal to the plane they define.

This operation is fundamental in 3D graphics and physics calculations. Use it to:

  • Generate normal vectors
  • Calculate surface normals
  • Find the area of a triangle
  • Handle rotational effects in simulations
  • Determine the orientation of objects in 3D space, such as aligning a camera or defining the axis of rotation.

Functionality

The Cross node takes two vectors as input and calculates their cross product using the formula:

Vresult = A x B

Where:

  • A and B are the input vectors.
  • The result is a vector perpendicular to both A and B, following the right-hand rule.
  • The order of input vectors matters: A x B and B x A return different results.

To Avoid Unexpected Results:

  • Ensure input vectors are not parallel, as this would result in a zero vector.
  • Normalize input vectors to ensure consistent output scaling.
  • Remember that the physical position of the object does not change (i.e. its bound is stable) - only the material behavior creates the visual illusion of rotation.

Usage Examples

Creating A Material Always Facing The Camera

To make an object always face the camera, we need to construct a local coordinate system based on the camera's position relative to the object.

  1. Compute the Unit Vector from the object to the camera:

    • Use the Camera Position node and normalize the vector to maintain consistent scaling.
  2. Determine the Side Vector:

    • Use the Cross Node to calculate a perpendicular vector by crossing the unit vector (computed in Step 1) with a fixed up vector.
    • Normalize the result vector.
  3. Compute the Final Orientation:

    • Perform another cross product between the computed side vector (computed in Step 2) and the unit vector (computed in Step 1) to get the final perpendicular vector.
    • Use the three orthogonal vectors to construct a transformation matrix that aligns the object to face the camera.

By using the Cross node in this way, we ensure the object dynamically orients itself toward the camera regardless of its movement, making it ideal for billboards, particles, and UI elements in 3D environments.

The information on this page is valid for UNIGINE 2.20 SDK.

Last update: 04.04.2025
Build: ()