Graph Editor

From TrainzOnline
Jump to: navigation, search

The Graph Editor is a pre-release feature of Trainz. It has been discussed publicly in the TrainzDev forums and is summarised on this page, however users should understand that no release schedule has been provided for this feature. All discussions and details are speculative in nature and may not accurately reflect the final form of this feature.

Contents

Broad Overview

The Graph Editor offers a new way of interacting with various components in the Trainz environment. The editor itself offers generic capabilities allowing various types of node to be created in the graph, inputs and outputs to be connected together, and properties to be viewed and set on each node. The Graph Editor itself does not define any node types, nor does it define any outcomes from the individual nodes or the overall graph. It is simply a generic editor. Context is provided by the specific environment in which the graph is composed and used.

A given graph is comprised of "Nodes" and "Connections". Each Node may offer some number of inputs and/or outputs. The user may create any number of nodes in the graph and then connect the inputs and output together to form a simple program. Each node is of a pre-defined type, selected by the user from a library of Node Types relevant to the editing context.

Conceptually, the Graph Editor provides a method of building a "circuit" or "program" by connecting building blocks. Programs take a small number of inputs and produce a small number of outputs.


Editing

The graph editor is typically opened by right clicking on an asset in Content Manager and selecting "Open > Show in Graph Editor". This will open a graph editor window for the asset in question and load the "default.nodegraph" file from that asset. Like config files, the format of the node graph is common across Asset Kinds, but the specific interpretation of the various components varies.

The graph editor window is divided horizontally into two panels; the left shows the graph itself and the right shows editable properties of the selected node(s). The divider can be dragged horizontally to vary the space available to each panel. The Graph (left) panel can be scrolled horizontally and vertically using scroll bars, scroll wheels, or by holding the space key and dragging.

Nodes

Right-clicking on any empty space in the left panel shows a contextual menu which includes the ability to add a new Node. Various Node Types are available depending on the context in which the Graph Editor is operating. Some nodes are output-only; some have both inputs and outputs, and some are input-only. Typically, a graph starts with one or more output-only nodes, works through a number of in-out nodes, and ends in one or more input-only nodes. Each Node Type may have its own visualisation in the graph, although all nodes share some basic visual features.

Nodes may be selected by clicking on them. The selected node is shown with a colored border.

Nodes may be assigned a label. This is used for display purposes only and is not used by the logic processing in the graph. If not customised, a default label is applied based on the Node Type.

Connectors

Node inputs and output connectors are visible on the outside edge of each node as small squares. Connections can be created between nodes by dragging from an Input connection to an Output connection on a different node (or vice versa). Adding a connection will remove any existing connection(s) from both connectors unless the option/alt key is held during the connection process.

Properties

The selected node's properties are shown in the Properties (right) panel. The available properties are dependant on the Node Type. Different nodes offer different properties according to their function. Some nodes perform a fixed function on their inputs, whereas others are heavily customisable with large numbers of parameters. Any parameter changes take effect immediately.


Use Cases

There are many use cases for the Graph Editor. Some of the more obvious potential uses include:

  • Building custom material shaders.
  • Building custom post-process shaders.
  • Building procedural physics models.
  • Building Procedural Engine Sound synthesisers.
Personal tools