Node connectors and data

What is a node “connector”?

A connector represents an input, optional input or an output of a node. It also has a type of data it accepts.

// Create an instance
InstantTerraApi::InstantTerra it = InstantTerraApi::CreateInstantTerra();

// Get the current graph
InstantTerraApi::Graph graph = it.GetProject().GetGraph();

// Get the first node of the graph
InstantTerraApi::Node node = graph.GetNode(0);

// Get the first connector
InstantTerraApi::Connector connector = node.GetConnector(0);

Getting the connector name

// Get the length of the name
size_t nameLength = connector.GetNameLength();

// Get the name
wchar_t *name = Malloc(nameLength * sizeof(wchar_t));
connector.GetName(name, nameLength);

See GetNameLength() and GetName(wchar_t *buffer, size_t bufferSize) in the documentation.

Getting the connector mode

// Get connector mode
ConnectorMode mode = connector.GetConnectorMode();

See GetConnectorMode() and ConnectorMode in the documentation.

Getting the connector type

// Get connector type
ConnectorType type = connector.GetConnectorType();

See GetConnectorType() and ConnectorType in the documentation.


What is a node “Data”?

A data represents the data of the node, at a specific connector.

// Create an instance
InstantTerraApi::InstantTerra it = InstantTerraApi::CreateInstantTerra();

// Get the current graph
InstantTerraApi::Graph graph = it.GetProject().GetGraph();

// Get the first node of the graph
InstantTerraApi::Node node = graph.GetNode(0);

// Get the first connector
InstantTerraApi::Connector connector = node.GetConnector(0);

// Get the data
InstantTerraApi::Data data = node.GetData(connector);

Getting the data type

// Get data type
DataType type = data.GetType();

See GetType() and DataType in the documentation.

Getting grid width and height

Warning

Those two methods work only on the following DataType: Terrain, Mask, Color Map, Vector Map.

// Get the grid width
int width = data.GetWidth();

// Get the grid height
int height = data.GetHeight();

See GetWidth() and GetHeight() in the documentation.

Getting the float content of a terrain or a mask

Warning

This method works only on the following DataType: Terrain, Mask.

Warning

The node should be computed before calling this method. Use the method ForceDataToBeComputed() to compute it.

Note

The size of the buffer should be egal to or bigger than: width * height * sizeof(float) .

// We want to get the top-left part of 128 x 128 in full resolution of our terrain
const int top  = 0; // 0 == top of the terrain
const int left = 0; // 0 == left of the terrain
const int widthPart  = 128;
const int heightPart = 128;
const int resolution = 0;  // 0 == Full resolution

const int bufferSize = widthPart * heightPart * sizeof(float);
float buffer[widthPart * heightPart];

// Get the float content, it will fill the buffer
data.GetFloatContent(buffer, bufferSize, left, top, widthPart, heightPart, resolution);

See GetFloatContent(float*buffer, int bufferSize, int startingX, int startingY, ...) in the documentation.