Accessing node data

What is a graph "node"?

A node represents an operation in InstantTerra, i.e. the generation of a terrain using a noise or even an erosion simulation.

These nodes and their parameters are accessible directly via the API.

// 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);

Getting the node name

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

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

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

Getting the node comment

// Get the length of the comment
size_t commentLength = node.GetCommentLength();

// Get the comment
wchar_t *comment = Malloc(commentLength * sizeof(wchar_t));
node.GetComment(comment, commentLength);

See GetCommentLength() and GetComment(wchar_t *buffer, size_t bufferSize) in the documentation.

Getting the node model

NodeModel model = node.GetNodeModel();

See GetNodeModel() in the documentation.

Getting the parameters count

// Returns the number of node parameters
int parameterCount = node.GetParameterCount();

See GetParameterCount() in the documentation.

Determining if a parameter exists

// Returns true if the parameter exist
bool hasParameter = node.HasParameter(L"ParameterName"))

See HasParameter(wchar_t *name) in the documentation.

Retrieving the parameter name

// Get the length of the parameter name
size_t parameterNameLength = node.GetParameterNameLength();

// Get the first parameter name
wchar_t *name = Malloc(parameterNameLength * sizeof(wchar_t));
node.GetParameterName(0, name, parameterNameLength);

See GetParameterNameLength(int parameterIndex) and GetParameterName(int parameterIndex, wchar_t *buffer, size_t bufferSize) in the documentation.

Retrieving the parameter value

 wchar_t parameterName[] = L"ParameterName";

// Get the length of the parameter value
size_t parameterValueLength = node.GetParameterValueLength(parameterName);

// Get the parameter value
wchar_t *value = Malloc(parameterValueLength * sizeof(wchar_t));
node.GetParameterValue(parameterName, value, parameterValueLength);

See GetParameterValueLength(wchar_t *name) and GetParameterValue(wchar_t *name, wchar_t *buffer, size_t bufferSize) in the documentation.

Getting the node connector count

// Returns the number of node connectors
int connectorCount = node.GetConnectorCount();

See GetConnectorCount() in the documentation.

Retrieving the node connector

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

See GetConnector(int index) in the documentation.

Retrieving node data

// Get the node data of the first connector
Connector firstConnector = node.GetConnector(0);

// Get the data
Data data = node.GetData(firstConnector);

See GetData(Connector connector) in the documentation.


Copyright © 2022 · All Rights Reserved · Wysilab