Interface IReadOnlyHudSpaceNode
- Namespace
- RichHudFramework.UI
- Assembly
- RichHudClient.dll
Interface for all HUD nodes that define their own custom coordinate space.
public interface IReadOnlyHudSpaceNode : IReadOnlyHudParent
- Inherited Members
Remarks
The coordinate system for all UI elements within the framework is defined by the HudSpace property, which uses this interface. Fundamentally, every UI element is rendered on the X/Y (Right/Up) plane of the matrix transform defined by PlaneToWorld.
For a comprehensive overview of the concepts regarding coordinate systems in this framework, refer to the article on HUD Spaces.
Implementations
Several classes implement this interface to provide specific coordinate systems:
Root and HighDpiRoot: Managed by HudMain, these are specialized implementations optimized for standard screen-space emulation.
CustomSpaceNode: This node offers maximum flexibility by allowing the world matrix to be defined via a delegate callback. It is particularly useful for attaching UI elements to dynamic entities (see: IMyEntity.WorldMatrix) where the transform matrix changes every frame.
CamSpaceNode: Generates its coordinate system based directly on the camera matrix. It allows for custom rotation, translation offsets, and optional screen-space scaling, enabling the creation of HUDs that follow the player's view but with specific modifications.
ScaledSpaceNode: Modifies an existing HUD space by applying a uniform scalar to the coordinate system. This is primarily used to implement uniform scaling for all child UI elements attached to that node.
HudSpaceNodeBase: The abstract base class for most concrete implementations of this interface. It handles the necessary boilerplate for API integration and manages cursor position projection. This ensures that every node within the space's subtree receives accurate cursor coordinates relative to its local coordinate system.
Properties
CursorPos
Position of the HUD cursor projected onto this node's plane.
X/Y = local plane coordinates Z = approximate squared distance from the camera to the intersection point (for depth sorting).
Vector3 CursorPos { get; }
Property Value
DrawCursorInHudSpace
If true, when a child of this node captures the cursor, the cursor will be drawn using this node's PlaneToWorld matrix instead of the default screen-space matrix. Useful for 3D / diegetic UI where the cursor should appear on the custom plane.
bool DrawCursorInHudSpace { get; }
Property Value
GetHudSpaceFunc
Delegate used by the cursor system to query this node's current HUD space properties. Returns (drawCursorInThisSpace, cursorBillboardScale, planeToWorldMatrix).
Func<MyTuple<bool, float, MatrixD>> GetHudSpaceFunc { get; }
Property Value
GetNodeOriginFunc
Function that returns the current world-space position of this node's origin.
Func<Vector3D> GetNodeOriginFunc { get; }
Property Value
IsFacingCamera
True if the node is in front of the camera AND its forward vector roughly faces the camera (dot product > 0). Used for culling back-facing HUD elements.
bool IsFacingCamera { get; }
Property Value
IsInFront
True if the node's origin is in front of the camera (i.e. in the camera's forward hemisphere).
bool IsInFront { get; }
Property Value
PlaneToWorld
Current Plane-to-World transformation matrix used for drawing this subtree. Transforms from local coordinates to world space.
MatrixD PlaneToWorld { get; }
Property Value
PlaneToWorldRef
Reference to the current Plane-to-World matrix as a single-element array.
MatrixD[] PlaneToWorldRef { get; }
Property Value
- MatrixD[]