Class HudSpaceNodeBase
- Namespace
- RichHudFramework.UI
- Assembly
- RichHudClient.dll
Abstract base for all HUD nodes that define their own custom coordinate space (replacing the default screen-space Pixel-to-World transform with an arbitrary world matrix).
Provides cursor projection, facing/in-front detection, and origin retrieval for derived classes.
public abstract class HudSpaceNodeBase : HudNodeBase, IReadOnlyHudNode, IReadOnlyHudSpaceNode, IReadOnlyHudParent
- Inheritance
-
HudSpaceNodeBase
- Implements
- Derived
- Inherited Members
Remarks
HudSpaceNodeBase is the abstract base class for all HUD nodes that define a custom coordinate system, by replacing the default screen-space Pixel-to-World transformation with an arbitrary world matrix.
This class provides a default implementation of the IReadOnlyHudSpaceNode interface, handling the complex boilerplate required for 3D interaction. Its features include:
- Cursor Projection: Automatically projects the screen-space cursor onto the node's custom plane to calculate accurate local cursor coordinates.
- Visibility Checks: Includes logic for determining if the node is in front of the camera and facing towards it (culling back-facing elements).
- API Integration: Provides default callbacks for the cursor system to query the node's current HUD space properties.
Common derived implementations include CamSpaceNode for camera-relative offsets and CustomSpaceNode for user-defined world matrices.
Constructors
HudSpaceNodeBase(HudParentBase)
public HudSpaceNodeBase(HudParentBase parent = null)
Parameters
parentHudParentBase
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).
public Vector3 CursorPos { get; protected set; }
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.
public bool DrawCursorInHudSpace { get; set; }
Property Value
GetHudSpaceFunc
Delegate used by the cursor system to query this node's current HUD space properties. Returns (drawCursorInThisSpace, cursorBillboardScale, planeToWorldMatrix).
public Func<MyTuple<bool, float, MatrixD>> GetHudSpaceFunc { get; protected set; }
Property Value
GetNodeOriginFunc
Function that returns the current world-space position of this node's origin. Default implementation returns PlaneToWorldRef[0].Translation.
public Func<Vector3D> GetNodeOriginFunc { get; protected set; }
Property Value
HudSpace
This node itself defines the HUD space for itself and its children.
public override IReadOnlyHudSpaceNode HudSpace { 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.
public bool IsFacingCamera { get; protected set; }
Property Value
IsInFront
True if the node's origin is in front of the camera (i.e. in the camera's forward hemisphere).
public bool IsInFront { get; protected set; }
Property Value
PlaneToWorld
Current Plane-to-World transformation matrix used for drawing this subtree. Transforms from local coordinates to world space.
public MatrixD PlaneToWorld { get; }
Property Value
PlaneToWorldRef
Reference to the current Plane-to-World matrix as a single-element array.
public MatrixD[] PlaneToWorldRef { get; }
Property Value
- MatrixD[]
Methods
Layout()
Updates visibility flags (IsInFront, IsFacingCamera) and projects the current cursor ray onto this node's plane to calculate CursorPos. Called automatically every frame before drawing.
protected override void Layout()