This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
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
Tutorials

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: 2025-04-04
Build: ()