#!/usr/bin/python3 import math size = 25 # converts from even-q vertical layout to world coords def offset_to_world_coords(offset_coordinate_x, offset_coordinate_y): z_offset = 0 if offset_coordinate_x % 2 != 0: z_offset = -math.sqrt(3) * 0.25 return [ offset_coordinate_x * 0.75, 0., z_offset + offset_coordinate_y * math.sqrt(3) * 0.5] # [gd_scene load_steps=2 format=2] # # [ext_resource path="res://scenes/HexTile3D.tscn" type="PackedScene" id=1] # # [node name="Spatial" type="Spatial"] # # [node name="HexTile3D1" parent="." instance=ExtResource( 1 )] # # [node name="HexTile3D2" parent="." instance=ExtResource( 1 )] # transform = Transform( -1.62921e-07, 0, 1, 0, 1, 0, -1, 0, -1.62921e-07, 0, 0, 0.866 ) print (""" [gd_scene load_steps=2 format=2] [ext_resource path="res://scenes/HexTile3D.tscn" type="PackedScene" id=1] [node name="Spatial" type="Spatial"] """ ) tile_index = 0 for x_i in range (size): for y_i in range (size): coord = offset_to_world_coords(x_i, y_i) print ("[node name=\"HexTile3D{tile_index}\" parent=\".\" instance=ExtResource( 1)]".format(tile_index = tile_index )) print ("transform = Transform( 0, 0, 1, 0, 1, 0, -1, 0, 0, {x_coord}, 0, {z_coord} )".format(x_coord = coord[0], z_coord = coord[2])) tile_index = tile_index + 1