Skip to main content

Interface

The Interface plugin manages 2D user interface rendering within a 3D scene or node using a resolution-independent Control system. It supports user interaction through mouse input, control focus tracking, and modal states. All Interface instances share a common root Canvas to efficiently reuse rendering resources, while each instance maintains its own ControlRoot for tracking the state and layout of UI controls.

info

The Interface system creates a MaterialBase material to inject custom dispatches and draw calls into the rendering pipeline.

#include <objects/interface/include/TellusimInterface.h>

Example

// Create a camera-attached interface
Interface interface_0;
if(!interface_0.create(device, sample_camera.getNode(), 5.0f)) return false;
interface_0.getNodeObject().setLocalTransform(Matrix4x3d::translate(-0.7, 0.1, -1.0) * Matrix4x3d::rotateY(60.0));
ControlDialog dialog_0 = ControlDialog(&interface_0.getControlRoot(), 1, 4.0f, 4.0f);
ControlText text_0(&dialog_0, "Attached to Camera");
dialog_0.setAlign(Control::AlignCenter);

// Create a globally positioned interface
Interface interface_1;
if(!interface_1.create(device, graph, 32.0f)) return false;
interface_1.getNodeObject().setGlobalTransform(Matrix4x3d::translate(0.0, -3.0, 0.2) * Matrix4x3d::rotateX(8.0));
ControlDialog dialog_1 = ControlDialog(&interface_1.getControlRoot(), 1, 4.0f, 4.0f);
ControlText text_1(&dialog_1, "Global Transform");
dialog_1.setAlign(Control::AlignCenter);

// Create an interface attached to a scene node
Interface interface_2;
if(!interface_2.create(device, node_box, 32.0f)) return false;
interface_2.getNodeObject().setGlobalTransform(Matrix4x3d::translate(0.0, 0.0, 1.5) * Matrix4x3d::rotateX(90.0));
ControlDialog dialog_2 = ControlDialog(&interface_2.getControlRoot(), 1, 4.0f, 4.0f);
ControlText text_2(&dialog_2, "Attached to Node");
dialog_2.setAlign(Control::AlignCenter);