Created
November 6, 2022 10:04
-
-
Save aokcubcg/4a138b0fbeb3347f9bcaa08f2529017a to your computer and use it in GitHub Desktop.
Create a node by RPC and make linkage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import terragen_rpc as tg | |
try: | |
root = tg.root() | |
# add easy cloud | |
new_cloud = tg.create_child(root, 'easy_cloud') | |
# link Planet Atmosphere and easy cloud created before. | |
atmos = root.children_filtered_by_class('planet_atmosphere')[0] | |
new_cloud.set_param_from_string('input_node', atmos.name()) | |
new_cloud.set_param_from_string('gui_group', atmos.get_param_as_string('gui_group')) | |
# make the position of the added node just below right of Planet Atmosphere. | |
base_pos = atmos.get_param_as_list('gui_node_pos') | |
print("Base position is: " + str(base_pos)) | |
cloud_pos = base_pos | |
cloud_pos[0] = cloud_pos[0] + 80 | |
cloud_pos[1] = cloud_pos[1] - 50 | |
new_cloud.set_param('gui_node_pos', cloud_pos) | |
new_pos = new_cloud.get_param_as_list('gui_node_pos') | |
print("gui_node_pos is set to: " + str(new_pos)) | |
# link Planet and easy cloud. | |
planet = root.children_filtered_by_class('planet')[0] | |
planet.set_param_from_string('atmosphere_shader', new_cloud.name()) | |
except ConnectionError as e: | |
print("Terragen RPC connection error: " + str(e)) | |
except TimeoutError as e: | |
print("Terragen RPC timeout error: " + str(e)) | |
except tg.ReplyError as e: | |
print("Terragen RPC server reply error: " + str(e)) | |
except tg.ApiError: | |
print("Terragen RPC API error") | |
raise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment