diff options
author | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2024-09-26 21:21:36 +0100 |
---|---|---|
committer | Lucas Fryzek <lucas.fryzek@fryzekconcepts.com> | 2024-09-26 21:21:36 +0100 |
commit | f87b54a8a1cb8dba0c8fd85f9e00665a85bdace3 (patch) | |
tree | 8a4b6080b51458d3ae79d25e430f561f157581af /scripts/bsp_level_generator.gd | |
parent | 9efec0230fff03e97047cacc89e28eb2d096cab4 (diff) |
bsp_level_generator: Add more models and textures
Diffstat (limited to 'scripts/bsp_level_generator.gd')
-rw-r--r-- | scripts/bsp_level_generator.gd | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/scripts/bsp_level_generator.gd b/scripts/bsp_level_generator.gd index 664b7a5..f8b850d 100644 --- a/scripts/bsp_level_generator.gd +++ b/scripts/bsp_level_generator.gd @@ -9,7 +9,9 @@ extends Node3D ## Geometry generation config @export var wall_thickness: float = 1 -@onready var mesh: MeshInstance3D = $MeshInstance3D +var wall_inst = preload("res://models/wall.blend") +var level_geo: Node3D + enum Direction {LEFT, RIGHT} signal grid_generated(grid: Array[Tile], p_grid_width: int, p_grid_height: int) @@ -148,11 +150,22 @@ func generate_geo(grid: Array[Tile.Tile], array: Array) -> void: if tile == Tile.Tile.FLOOR or tile == Tile.Tile.DOOR: generate_plane(array, Vector3(x, 0, y), [Vector3(1, 0, 0), Vector3(0, 0, 1)], Vector3.UP) + var floor_tile: Node3D = level_geo.get_node("./Floor").duplicate() + floor_tile.position = Vector3(x, 0, y) + add_child(floor_tile) + + var ciel_tile: Node3D = level_geo.get_node("./Floor").duplicate() + ciel_tile.rotate_z(deg_to_rad(180)) + ciel_tile.position = Vector3(x+1, 2, y) + add_child(ciel_tile) elif tile == Tile.Tile.WALL: generate_plane(array, Vector3(x, 2, y), [Vector3(0, 0, 1), Vector3(0, -2, 0)], Vector3.LEFT) generate_plane(array, Vector3(x, 2, y+1), [Vector3(1, 0, 0), Vector3(0, -2, 0)], Vector3.BACK) generate_plane(array, Vector3(x+1, 2, y+1), [Vector3(0, 0, -1), Vector3(0, -2, 0)], Vector3.RIGHT) generate_plane(array, Vector3(x+1, 2, y), [Vector3(-1, 0, 0), Vector3(0, -2, 0)], Vector3.FORWARD) + var wall: Node3D = level_geo.get_node("./Wall").duplicate() + wall.position = Vector3(x, 0, y) + add_child(wall) func _ready() -> void: var starting_axis = randi_range(0, 1) @@ -172,11 +185,12 @@ func _ready() -> void: generate_grid(map, grid) grid_generated.emit(grid, grid_width, grid_height) + level_geo = wall_inst.instantiate() generate_geo(grid, surface_array) - mesh.mesh = ArrayMesh.new() - mesh.mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, surface_array) - var tri_mesh = mesh.mesh.create_trimesh_shape() + var mesh = ArrayMesh.new() + mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, surface_array) + var tri_mesh = mesh.create_trimesh_shape() $NavigationRegion3D/StaticBody3D/CollisionShape3D.shape = tri_mesh #$NavigationRegion3D.navigation_mesh = NavigationMesh.new() #$NavigationRegion3D.navigation_mesh.radius |