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 of InstantTerra
InstantTerra instantTerra = new InstantTerra();

// Get the current graph and the list of nodes
Graph graph = instantTerra.GetProject().GetGraph();
List<Node> listOfNodes = graph.GetAllNodes();

// Get the first node of the graph
Node myNode = listOfNodes[0];

Changing a node name

myNode.SetName("New name");
Console.WriteLine(myNode.GetName());

To change or retrieve a node name, use the methods SetName(name) and GetName.

Changing a node comment

myNode.SetComment("New comment");
Console.WriteLine(myNode.GetComment());

To change or retrieve a node comment, use the methods SetComment(comment) and GetComment.

Retrieving the node type

Console.WriteLine(myNode.GetNodeType());

To retrieve the node type, use the method GetNodeType.

Retrieving the parameters' list

// Returns the list of node parameters
string[] parameterList = myNode.GetParameterList();
parameterList.ForEach(Console.WriteLine);

The method GetParameterList() returns the list of node parameters.

Determining if a parameter exists

// Returns true if the parameter exists
Console.WriteLine(myNode.HasParameter("ParameterName"));

See HasParameter(parameterName) in the documentation.

Retrieving or setting a parameter value

// Get the value of the parameter
Console.WriteLine(myNode.GetParameterValue("offset_x"));

// Set the value of the parameter
myNode.SetParameterValue("offset_x", "1.0");

See GetParameterValue(parameterName) and SetParameterValue(parameterName, value).

Note

If the parameter name does not exist or if the set value is not valid, C# returns an error message with the description of the problem.


Copyright © 2022 · All Rights Reserved · Wysilab