mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-11 13:51:11 +01:00
Implement texture mapping for the dungeon.
This commit is contained in:
parent
8997fae8c2
commit
a95b386d01
2
HEADS
2
HEADS
@ -1 +1 @@
|
||||
{"engine": {"3.2": "89f57ae12244f3269c9e3fe4684e16ec1fd2c989", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "882008ac7f0b6edf3a1de4481cd41b23f621d25b"}, "entity_spell_system": {"master": "af1bd74fbf38d0ac42d3cf203feb3c7212d01849"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "c9ee935af3ee1bc463e6ae0b96d23667232123b1"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "85417ebee9198be3cd7cc643e0e0e934db64a620"}, "procedural_animations": {"master": "9226d21781ea05828570e592874aa319df0dc53d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "544654f49b13af2d25ac14152c8a5014474e6333"}, "mesh_utils": {"master": "4f69ec67b861ce4475cfd17946dfaa586c888d94"}, "broken_seals_module": {"master": "0e5c54a70f8e90f95cbf11419b959a5f67562d48"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}
|
||||
{"engine": {"3.2": "c79ec3951b44df4d794c3076e10c67a35b9d662d", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "59dde526b9d10079ca61b50ee2b619db31bfb32d"}, "entity_spell_system": {"master": "af1bd74fbf38d0ac42d3cf203feb3c7212d01849"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "e9dc7d18dd65b699781c383305fb45efbfb9d53c"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "85417ebee9198be3cd7cc643e0e0e934db64a620"}, "procedural_animations": {"master": "9226d21781ea05828570e592874aa319df0dc53d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "544654f49b13af2d25ac14152c8a5014474e6333"}, "mesh_utils": {"master": "4f69ec67b861ce4475cfd17946dfaa586c888d94"}, "broken_seals_module": {"master": "0e5c54a70f8e90f95cbf11419b959a5f67562d48"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}
|
@ -33,6 +33,10 @@ export(MeshDataResource) var dung_wall_xn : MeshDataResource = null
|
||||
export(MeshDataResource) var dung_wall_zp : MeshDataResource = null
|
||||
export(MeshDataResource) var dung_wall_zn : MeshDataResource = null
|
||||
|
||||
export(Texture) var wall_texture : Texture
|
||||
export(Texture) var floor_texture : Texture
|
||||
export(Texture) var ceiling_texture : Texture
|
||||
|
||||
export(MeshDataResource) var dung_entrance_mdr : MeshDataResource = null
|
||||
export(PackedScene) var dung_entrance_scene : PackedScene = null
|
||||
|
||||
@ -74,26 +78,19 @@ func _setup():
|
||||
posy = 7
|
||||
|
||||
build()
|
||||
#
|
||||
#func _setup_library(library):
|
||||
# ._setup_library(library)
|
||||
#
|
||||
# for i in range(get_dungeon_start_room_count()):
|
||||
# get_dungeon_start_room(i).setup_library(library)
|
||||
|
||||
func _setup_library(library):
|
||||
._setup_library(library)
|
||||
|
||||
if library is VoxelmanLibraryMerger:
|
||||
library.get_prop_packer().add_texture(wall_texture)
|
||||
library.get_prop_packer().add_texture(floor_texture)
|
||||
library.get_prop_packer().add_texture(ceiling_texture)
|
||||
|
||||
func _generate_chunk(chunk, spawn_mobs):
|
||||
# if chunk.position_y == 1:
|
||||
# for x in range(chunk.size_x):
|
||||
# for z in range(chunk.size_z):
|
||||
# chunk.add_mesh_data_resourcev(Vector3(x, 5, z), dung_ceiling)
|
||||
|
||||
var aabb : AABB = AABB(Vector3(posx, posy, posz) * chunk.get_voxel_scale(), Vector3(sizex, sizey, sizez) * chunk.get_voxel_scale())
|
||||
var chunk_aabb : AABB = AABB(chunk.get_position() * Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * chunk.get_voxel_scale(), Vector3(chunk.size_x, chunk.size_y, chunk.size_z) * chunk.get_voxel_scale())
|
||||
|
||||
# if dung_entrance_mdr && chunk_aabb.has_point(entrance_position.origin):
|
||||
#todo chunk needs an add func that takes global coords
|
||||
# chunk.add_mesh_data_resource(entrance_position, dung_entrance_mdr)
|
||||
|
||||
if dung_entrance_scene && chunk_aabb.has_point(entrance_position.origin):
|
||||
call_deferred("spawn_teleporter_scene", dung_entrance_scene, entrance_position, chunk, inner_entrance_position)
|
||||
|
||||
@ -131,7 +128,7 @@ func _generate_chunk(chunk, spawn_mobs):
|
||||
for x in range(px, tox):
|
||||
for z in range(pz, toz):
|
||||
var tile : int = map[x][z]
|
||||
#we can safely check like this as wall is 0
|
||||
#we can safely check like this
|
||||
if tile > Tile.Wall:
|
||||
#grab the wall data, by just right shifting it back. (binary) XXXXYYYY -> 0000XXXX
|
||||
var walls : int = tile >> 4
|
||||
@ -139,26 +136,26 @@ func _generate_chunk(chunk, spawn_mobs):
|
||||
if walls > 0:
|
||||
#(binary) XXXX & 0001 -> 000X
|
||||
if walls & NeighbourCaseCodeFlags.WallXP != 0:
|
||||
add_wall(chunk, xx, zz, floor_pos, ceiling_pos, dung_wall_xp)
|
||||
add_wall(chunk, xx, zz, floor_pos, ceiling_pos, dung_wall_xp, wall_texture)
|
||||
|
||||
#(binary) XXXX & 0010 -> 00X0
|
||||
if walls & NeighbourCaseCodeFlags.WallXN != 0:
|
||||
#+ 1 offsets it to be at the proper place
|
||||
add_wall(chunk, xx + 1, zz, floor_pos, ceiling_pos, dung_wall_xn)
|
||||
add_wall(chunk, xx + 1, zz, floor_pos, ceiling_pos, dung_wall_xn, wall_texture)
|
||||
|
||||
#etc
|
||||
if walls & NeighbourCaseCodeFlags.WallZP != 0:
|
||||
add_wall(chunk, xx, zz - 1, floor_pos, ceiling_pos, dung_wall_zp)
|
||||
add_wall(chunk, xx, zz - 1, floor_pos, ceiling_pos, dung_wall_zp, wall_texture)
|
||||
|
||||
if walls & NeighbourCaseCodeFlags.WallZN != 0:
|
||||
#+ 1 offsets it to be at the proper place
|
||||
add_wall(chunk, xx, zz, floor_pos, ceiling_pos, dung_wall_zn)
|
||||
add_wall(chunk, xx, zz, floor_pos, ceiling_pos, dung_wall_zn, wall_texture)
|
||||
|
||||
if draw_floor:
|
||||
chunk.add_mesh_data_resourcev(Vector3(xx, floor_pos, zz), dung_floor)
|
||||
chunk.add_mesh_data_resourcev(Vector3(xx, floor_pos, zz), dung_floor, floor_texture)
|
||||
|
||||
if draw_ceiling:
|
||||
chunk.add_mesh_data_resourcev(Vector3(xx, ceiling_pos, zz), dung_ceiling)
|
||||
chunk.add_mesh_data_resourcev(Vector3(xx, ceiling_pos, zz), dung_ceiling, ceiling_texture)
|
||||
|
||||
zz += 1
|
||||
xx += 1
|
||||
@ -167,10 +164,9 @@ func _generate_chunk(chunk, spawn_mobs):
|
||||
# for i in range(get_dungeon_start_room_count()):
|
||||
# get_dungeon_start_room(i).generate_chunk(chunk, spawn_mobs)
|
||||
|
||||
func add_wall(chunk : VoxelChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource):
|
||||
func add_wall(chunk : VoxelChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource, tex : Texture):
|
||||
for y in range(floor_pos, ceiling_pos):
|
||||
chunk.add_mesh_data_resourcev(Vector3(x, y, z), wall)
|
||||
|
||||
chunk.add_mesh_data_resourcev(Vector3(x, y, z), wall, tex)
|
||||
|
||||
func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk : VoxelChunk, teleports_to : Vector3):
|
||||
var s = scene.instance()
|
||||
@ -225,8 +221,6 @@ func build_level():
|
||||
|
||||
enemies.clear()
|
||||
|
||||
# nav_graph = AStar2D.new()
|
||||
|
||||
for x in range(sizex):
|
||||
map.append([])
|
||||
for y in range(sizez):
|
||||
@ -243,10 +237,6 @@ func build_level():
|
||||
connect_rooms()
|
||||
|
||||
#post process walls, so they have the correct type
|
||||
#0 : xn
|
||||
#1 : xp
|
||||
#2 : zn
|
||||
#3 : zp
|
||||
var neighbours : int = 0
|
||||
for x in range(sizex):
|
||||
for z in range(sizez):
|
||||
@ -472,30 +462,7 @@ func cut_regions(free_regions, region_to_remove):
|
||||
|
||||
for region in addition_queue:
|
||||
free_regions.append(region)
|
||||
#
|
||||
#func clear_path(tile):
|
||||
# var new_point = nav_graph.get_available_point_id()
|
||||
# nav_graph.add_point(new_point, Vector2(tile.x, tile.y))
|
||||
#
|
||||
# var points_to_conect = []
|
||||
#
|
||||
# if tile.x > 0 && map[tile.x - 1][tile.y] == Tile.Floor:
|
||||
# points_to_conect.append(nav_graph.get_closest_point(Vector2(tile.x - 1, tile.y)))
|
||||
#
|
||||
# if tile.y > 0 && map[tile.x][tile.y - 1] == Tile.Floor:
|
||||
# points_to_conect.append(nav_graph.get_closest_point(Vector2(tile.x, tile.y - 1)))
|
||||
#
|
||||
# if tile.x < 0 && map[tile.x + 1][tile.y] == Tile.Floor:
|
||||
# points_to_conect.append(nav_graph.get_closest_point(Vector2(tile.x + 1, tile.y)))
|
||||
#
|
||||
# if tile.y < 0 && map[tile.x][tile.y + 1] == Tile.Floor:
|
||||
# points_to_conect.append(nav_graph.get_closest_point(Vector2(tile.x, tile.y + 1)))
|
||||
#
|
||||
# for point in points_to_conect:
|
||||
# nav_graph.connect_points(point, new_point)
|
||||
|
||||
func set_tile(x, y, type):
|
||||
map[x][y] = type
|
||||
|
||||
# if type == Tile.Floor:
|
||||
# clear_path(Vector2(x, y))
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_resource type="Dungeon" load_steps=10 format=2]
|
||||
[gd_resource type="Dungeon" load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://modules/planets/test_planet/dungeons/dungeon.gd" type="Script" id=1]
|
||||
[ext_resource path="res://modules/species/Human/Female/character_models/huf_calf_left.gltf" type="MeshDataResource" id=2]
|
||||
@ -9,6 +9,8 @@
|
||||
[ext_resource path="res://modules/core_models/floor.gltf" type="MeshDataResource" id=7]
|
||||
[ext_resource path="res://modules/core_models/wall_zn.gltf" type="MeshDataResource" id=8]
|
||||
[ext_resource path="res://modules/core_models/wall_zp.gltf" type="MeshDataResource" id=9]
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_1_albedo.png" type="Texture" id=10]
|
||||
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=11]
|
||||
|
||||
[resource]
|
||||
sizex = 40
|
||||
@ -25,5 +27,8 @@ dung_wall_xp = ExtResource( 5 )
|
||||
dung_wall_xn = ExtResource( 6 )
|
||||
dung_wall_zp = ExtResource( 9 )
|
||||
dung_wall_zn = ExtResource( 8 )
|
||||
wall_texture = ExtResource( 11 )
|
||||
floor_texture = ExtResource( 10 )
|
||||
ceiling_texture = ExtResource( 10 )
|
||||
dung_entrance_mdr = ExtResource( 2 )
|
||||
dung_entrance_scene = ExtResource( 3 )
|
||||
|
@ -53,21 +53,6 @@ func _setup():
|
||||
#
|
||||
# add_dungeon(dung)
|
||||
|
||||
func _setup_library(library):
|
||||
._setup_library(library)
|
||||
|
||||
for i in range(get_biome_count()):
|
||||
var b : Biome = get_biome(i)
|
||||
|
||||
if b != null:
|
||||
b.setup_library(library)
|
||||
|
||||
for i in range(get_dungeon_count()):
|
||||
var d : Dungeon = get_dungeon(i)
|
||||
|
||||
if d != null:
|
||||
d.setup_library(library)
|
||||
|
||||
func _generate_chunk(chunk, spawn_mobs):
|
||||
if (get_biome_count() == 0):
|
||||
return
|
||||
|
@ -36,14 +36,14 @@ func _setup():
|
||||
b.setup()
|
||||
add_biome(b)
|
||||
|
||||
func _setup_library(library):
|
||||
._setup_library(library)
|
||||
|
||||
for i in range(get_biome_count()):
|
||||
var b : Biome = get_biome(i)
|
||||
|
||||
if b != null:
|
||||
b.setup_library(library)
|
||||
#func _setup_library(library):
|
||||
# ._setup_library(library)
|
||||
#
|
||||
# for i in range(get_biome_count()):
|
||||
# var b : Biome = get_biome(i)
|
||||
#
|
||||
# if b != null:
|
||||
# b.setup_library(library)
|
||||
|
||||
func _generate_chunk(chunk, spawn_mobs):
|
||||
if (get_biome_count() == 0):
|
||||
|
@ -43,9 +43,7 @@ func setup(world : VoxelWorld, level_seed : int, spawn_mobs : bool, library: Vox
|
||||
_planet = planet.instance()
|
||||
_planet.current_seed = _level_seed
|
||||
_planet.setup()
|
||||
|
||||
# This crashes, still need to figure out why
|
||||
# _planet.setup_library(_library)
|
||||
_planet.setup_library(_library)
|
||||
|
||||
# create_planet()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user