extends SceneTree ## Writes the grotto site of the G1 map for the Blender generators (G2): lane centre lines ## with their corridor half widths near the grotto, and the terrain height field around it ## in the grotto's local frame (origin at the arena centre on the terrace, Godot axes). ## Run: godot --headless --path . -s res://tools/luneraria/dump_grotto_site.gd const OUT := "res://assets-source/luneraria/g2/grotto_site.json" const HALF: float = 18.0 const STEP: float = .5 func _init() -> void: var map := LuneMap.new() var terrain := LuneTerrain.for_map(map) var center: Vector2 = LuneMap.GROTTO var lanes: Array = [] for lane: String in LuneMap.LANES: var path: LuneMap.LanePath = map.lanes[lane] var points: Array = [] var s: float = 0.0 while s <= path.length: for team: int in range(2): var p: Vector2 = map.lane_point(team, lane, s) - center if absf(p.x) < HALF + 6.0 and absf(p.y) < HALF + 6.0: points.append([snappedf(p.x, .001), snappedf(p.y, .001)]) s += .5 lanes.append({"lane": lane, "corridor": float(LuneTerrain.CORRIDOR.get(lane, 3.6)), "points": points}) var heights: Array = [] var count: int = int(HALF * 2.0 / STEP) + 1 for j: int in range(count): var row: Array = [] for i: int in range(count): var p := center + Vector2(-HALF + i * STEP, -HALF + j * STEP) row.append(snappedf(terrain.height_at(p) - LuneTerrain.ARENA_HEIGHT, .001)) heights.append(row) var data := {"note": "local frame: origin = LuneMap.GROTTO at ARENA_HEIGHT; x,z = map axes; heights relative to the terrace", "grotto": [center.x, center.y], "arena_height": LuneTerrain.ARENA_HEIGHT, "arena_radius": LuneTerrain.ARENA_RADIUS, "lanes": lanes, "height_grid": {"origin": [-HALF, -HALF], "step": STEP, "count": count, "rows_along": "z", "values": heights}} var file := FileAccess.open(OUT, FileAccess.WRITE) file.store_string(JSON.stringify(data)) file.close() print("GROTTO_SITE written: ", ProjectSettings.globalize_path(OUT)) quit()