Transform (Flowgraph Node)
- **Node Name:** `Transform`
Overview
- Node Name:
Transform - Category:
provider - File:
extensions/flowgraph/nodes/types/transform.lua - Icon:
d_rotation
Manages a position, rotation, and scale in 3D space. Supports interactive gizmo editing or reading transforms from a scene object by ID.
Pin Schema
Input Pins (when mode = fromID)
| Pin | Type | Description |
|---|---|---|
objID | number | Scene object ID to read transform from |
Output Pins
| Pin | Type | Description |
|---|---|---|
pos | vec3 | Position of the transform |
rot | quat | Rotation of the transform |
scl | vec3 | Scale of the transform |
Internals
| Field | Purpose |
|---|---|
self.position | vec3 - current position (defaults to 15m in front of camera) |
self.rotation | quat - current rotation (defaults to identity) |
self.scale | vec3 - current scale (defaults to 1,1,1) |
self.mode | 'gizmo' or 'fromID' - input source |
self.markerColor | ColorF - debug visualization color |
self.displayMode | One of: default, sphereX/Y/Z, halfBox, fullBox, aproxVehicle |
How It Works
init()- Positions the transform 15m in front of the camera with identity rotation and unit scale.work():- Gizmo mode: Outputs the stored position/rotation/scale as tables.
- fromID mode: Reads position, rotation, and scale from the scene object specified by
objID.
- Gizmo integration - When properties are shown in the editor, integrates with BeamNG's axis gizmo for interactive translate/rotate/scale dragging.
drawMiddle()- Draws debug visualization (axes, spheres, boxes) in the 3D viewport based ondisplayMode.drawCustom()- Editor UI for position/rotation/scale drag inputs, color picker, and helper buttons (move to camera, drop to terrain, copy from selection).
Display Modes
| Mode | Description |
|---|---|
default | Small sphere at position |
sphereX/Y/Z | Sphere with radius from scale.x/y/z |
halfBox | Half-size oriented bounding box |
fullBox | Full-size oriented bounding box |
aproxVehicle | Approximate vehicle-shaped box with direction indicator |
Serialization
Saves position, rotation, scale, marker color, mode, display mode, and quaternion rotation preference.
Example Usage
-- In gizmo mode, drag the transform in the editor viewport.
-- Outputs are tables:
-- pos = {x, y, z}
-- rot = {x, y, z, w}
-- scl = {x, y, z}
-- In fromID mode, connect an object ID:
-- The node reads the object's transform each frame.
local obj = scenetree.findObjectById(objID)
local pos = vec3(obj:getPosition())Additional Methods
C:_executionStarted()
Called when graph execution starts. Used for initialization/reset.
C:_executionStopped()
Called when graph execution stops. Used for cleanup.
C:_onDeserialized(nodeData)
Called after the node is deserialized (loaded from file). Restores runtime state from saved data.
Parameters:
nodeData
C:_onSerialize(res)
Called when the node is serialized (saved to file). Returns data to persist.
Parameters:
res
C:drawAxisBox(corner, x, y, z, clr)
Custom ImGui drawing function for the node editor.
Parameters:
cornerxyzclr
C:drawCustomProperties()
Custom ImGui drawing for the node's properties panel in the editor.
C:gizmoBeginDrag()
Node method.
C:gizmoDragging()
Node method.
C:gizmoEndDrag()
Node method.
C:hideProperties()
Returns a set of property names to hide in the editor.
C:showProperties()
Returns a set of property names to show in the editor.
C:updateTransform()
Node method.
See Also
- Bool (Flowgraph Node) - Related reference
- Color (Flowgraph Node) - Related reference
- Generic Set/Get Variable (Flowgraph Node) - Related reference
- FlowGraph Guide - Guide