VoxelGraphFunction

Inherits: Resource

Graph for generating or processing voxels.

Description:

Contains a graph that can be used to generate voxel data (when used as main function of a generator), or to be re-used into other graphs (like a sub-graph).

Currently this class only stores a graph, it cannot run actual processing on its own. To generate voxels with it, see VoxelGeneratorGraph.

Note: node types are identified with the enum VoxelGraphFunction.NodeTypeID. This enum shouldn't be used in persistent contexts (such as save files) as its values may change between versions.

Properties:

Type Name Default
Array input_definitions []
Array output_definitions []

Methods:

Return Signature
void add_connection ( int src_node_id, int src_port_index, int dst_node_id, int dst_port_index )
bool can_connect ( int src_node_id, int src_port_index, int dst_node_id, int dst_port_index ) const
void clear ( )
int create_function_node ( VoxelGraphFunction function, Vector2 position, int id=0 )
int create_node ( int type_id, Vector2 position, int id=0 )
int find_node_by_name ( StringName name ) const
Array get_connections ( ) const
Variant get_node_default_input ( int node_id, int input_index ) const
bool get_node_default_inputs_autoconnect ( int node_id ) const
Vector2 get_node_gui_position ( int node_id ) const
Vector2 get_node_gui_size ( int node_id ) const
PackedInt32Array get_node_ids ( ) const
StringName get_node_name ( int node_id ) const
Variant get_node_param ( int node_id, int param_index ) const
int get_node_type_count ( ) const
int get_node_type_id ( int node_id ) const
Dictionary get_node_type_info ( int type_id ) const
void paste_graph_with_pre_generated_ids ( VoxelGraphFunction graph, PackedInt32Array node_ids, Vector2 gui_offset )
void remove_connection ( int src_node_id, int src_port_index, int dst_node_id, int dst_port_index )
void remove_node ( int node_id )
void set_expression_node_inputs ( int node_id, PackedStringArray names )
void set_node_default_input ( int node_id, int input_index, Variant value )
void set_node_default_inputs_autoconnect ( int node_id, bool enabled )
void set_node_gui_position ( int node_id, Vector2 position )
void set_node_gui_size ( int node_id, Vector2 size )
void set_node_name ( int node_id, StringName name )
void set_node_param ( int node_id, int param_index, Variant value )
void set_node_param_null ( int node_id, int param_index )

Signals:

compiled( )

Emitted after the graph finished compiling, even if compiling failed.

node_name_changed( int node_id )

(This signal has no documentation)

Enumerations:

enum NodeTypeID:

  • NODE_CONSTANT = 0
  • NODE_INPUT_X = 1
  • NODE_INPUT_Y = 2
  • NODE_INPUT_Z = 3
  • NODE_OUTPUT_SDF = 4
  • NODE_CUSTOM_INPUT = 52
  • NODE_CUSTOM_OUTPUT = 53
  • NODE_ADD = 5
  • NODE_SUBTRACT = 6
  • NODE_MULTIPLY = 7
  • NODE_DIVIDE = 8
  • NODE_SIN = 9
  • NODE_FLOOR = 10
  • NODE_ABS = 11
  • NODE_SQRT = 12
  • NODE_FRACT = 13
  • NODE_STEPIFY = 14
  • NODE_WRAP = 15
  • NODE_MIN = 16
  • NODE_MAX = 17
  • NODE_DISTANCE_2D = 18
  • NODE_DISTANCE_3D = 19
  • NODE_CLAMP = 20
  • NODE_MIX = 22
  • NODE_REMAP = 23
  • NODE_SMOOTHSTEP = 24
  • NODE_CURVE = 25
  • NODE_SELECT = 26
  • NODE_NOISE_2D = 27
  • NODE_NOISE_3D = 28
  • NODE_IMAGE_2D = 29
  • NODE_SDF_PLANE = 30
  • NODE_SDF_BOX = 31
  • NODE_SDF_SPHERE = 32
  • NODE_SDF_TORUS = 33
  • NODE_SDF_PREVIEW = 34
  • NODE_SDF_SPHERE_HEIGHTMAP = 35
  • NODE_SDF_SMOOTH_UNION = 36
  • NODE_SDF_SMOOTH_SUBTRACT = 37
  • NODE_NORMALIZE_3D = 38
  • NODE_FAST_NOISE_2D = 39
  • NODE_FAST_NOISE_3D = 40
  • NODE_FAST_NOISE_GRADIENT_2D = 41
  • NODE_FAST_NOISE_GRADIENT_3D = 42
  • NODE_OUTPUT_WEIGHT = 43
  • NODE_OUTPUT_SINGLE_TEXTURE = 45
  • NODE_EXPRESSION = 46
  • NODE_POWI = 47
  • NODE_POW = 48
  • NODE_INPUT_SDF = 49
  • NODE_COMMENT = 50
  • NODE_FUNCTION = 51
  • NODE_RELAY = 54
  • NODE_SPOTS_2D = 55
  • NODE_SPOTS_3D = 56
  • NODE_TYPE_COUNT = 59
  • NODE_FAST_NOISE_2_2D = 57
  • NODE_FAST_NOISE_2_3D = 58

Property Descriptions

Array input_definitions = []

(This property has no documentation)

Array output_definitions = []

(This property has no documentation)

Method Descriptions

void add_connection( int src_node_id, int src_port_index, int dst_node_id, int dst_port_index )

Connects the outputs of a node to the input of another node. Connecting a node to itself, or in a way that can lead it back to itself, is not supported.

bool can_connect( int src_node_id, int src_port_index, int dst_node_id, int dst_port_index )

Tests if two ports can be connected together.

void clear( )

Removes all nodes from the graph. Input and output definitions will not be cleared.

int create_function_node( VoxelGraphFunction function, Vector2 position, int id=0 )

Creates a node based on an existing graph (creates a "sub-graph instance").

int create_node( int type_id, Vector2 position, int id=0 )

Creates a graph node of a given type at a specific visual position.

The position parameter does not affect how the graph will perform, however it helps organizing nodes.

An optional ID can be specified. If left to 0, the ID will be generated.

This function then returns the ID of the node, which may be useful to modify other properties of the node later.

int find_node_by_name( StringName name )

(This method has no documentation)

Array get_connections( )

(This method has no documentation)

Variant get_node_default_input( int node_id, int input_index )

(This method has no documentation)

bool get_node_default_inputs_autoconnect( int node_id )

(This method has no documentation)

Vector2 get_node_gui_position( int node_id )

(This method has no documentation)

Vector2 get_node_gui_size( int node_id )

(This method has no documentation)

PackedInt32Array get_node_ids( )

(This method has no documentation)

StringName get_node_name( int node_id )

(This method has no documentation)

Variant get_node_param( int node_id, int param_index )

(This method has no documentation)

int get_node_type_count( )

Get how many types of nodes exist in the graph system.

int get_node_type_id( int node_id )

Get the ID of the type of a node in the graph.

Dictionary get_node_type_info( int type_id )

Gets information about a node type from VoxelGraphFunction.NodeTypeID.

The returned data has this structure:

{
    "name": String,
    "inputs": [
        {"name": String},
        ...
    ],
    "outputs": [
        {"name": String},
        ...
    ],
    "params": [
        {
            "name": String,
            "type": int (Variant::Type),
            "class_name": String,
            "default_value": Variant
        },
        ...
    ]
}

void paste_graph_with_pre_generated_ids( VoxelGraphFunction graph, PackedInt32Array node_ids, Vector2 gui_offset )

Copies nodes into another graph, and connections between them only.

Resources in node parameters will be duplicated if they don't have a file path.

If node_ids is provided with non-zero size, defines the IDs of copied nodes. Otherwise, they are generated.

void remove_connection( int src_node_id, int src_port_index, int dst_node_id, int dst_port_index )

Removes an existing connection between two nodes of the graph.

void remove_node( int node_id )

Removes a node from the graph.

void set_expression_node_inputs( int node_id, PackedStringArray names )

Configures inputs for an Expression node. names is the list of input names used in the expression.

value must be a float for now.

void set_node_default_input( int node_id, int input_index, Variant value )

(This method has no documentation)

void set_node_default_inputs_autoconnect( int node_id, bool enabled )

Sets wether a node input with no inbound connection will automatically create a default connection when the graph is compiled.

This is only available on specific nodes. On other nodes, it has no effect.

void set_node_gui_position( int node_id, Vector2 position )

Sets the visual position of a node of the graph, as it will appear in the editor.

void set_node_gui_size( int node_id, Vector2 size )

(This method has no documentation)

void set_node_name( int node_id, StringName name )

Sets a custom name for a node.

void set_node_param( int node_id, int param_index, Variant value )

(This method has no documentation)

void set_node_param_null( int node_id, int param_index )

(This method has no documentation)

Generated on Apr 06, 2024