diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5b0d1a4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf +*.png filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/Art/Stone_05-128x128.png b/Art/Stone_05-128x128.png new file mode 100644 index 0000000..8815f2d --- /dev/null +++ b/Art/Stone_05-128x128.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09e1d411d9ac763c379bc8057ce0b7099f7feccd3d9139fef470e366c640e3a5 +size 33125 diff --git a/Art/Stone_05-128x128.png.import b/Art/Stone_05-128x128.png.import new file mode 100644 index 0000000..f9739a4 --- /dev/null +++ b/Art/Stone_05-128x128.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://buoupwtftxjse" +path.s3tc="res://.godot/imported/Stone_05-128x128.png-6e57d717d543c3c7c2a521569c0b2f7c.s3tc.ctex" +metadata={ +"imported_formats": ["s3tc_bptc"], +"vram_texture": true +} + +[deps] + +source_file="res://Art/Stone_05-128x128.png" +dest_files=["res://.godot/imported/Stone_05-128x128.png-6e57d717d543c3c7c2a521569c0b2f7c.s3tc.ctex"] + +[params] + +compress/mode=2 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=true +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=0 diff --git a/Art/Stone_06-128x128.png b/Art/Stone_06-128x128.png new file mode 100644 index 0000000..9f5f4a4 --- /dev/null +++ b/Art/Stone_06-128x128.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4b21def63a4bc80e9a1d2fbce687496c902f520aad97748e4404753273a6b376 +size 32058 diff --git a/Art/Stone_06-128x128.png.import b/Art/Stone_06-128x128.png.import new file mode 100644 index 0000000..49e6d29 --- /dev/null +++ b/Art/Stone_06-128x128.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://icmmuqquxhq3" +path="res://.godot/imported/Stone_06-128x128.png-1430bdd7db0c859489b2b90bbc7ac88e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Art/Stone_06-128x128.png" +dest_files=["res://.godot/imported/Stone_06-128x128.png-1430bdd7db0c859489b2b90bbc7ac88e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Scenes/Material.tres b/Scenes/Material.tres deleted file mode 100644 index a41bb13..0000000 --- a/Scenes/Material.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bb47mhgbxy3cw"] - -[ext_resource type="Texture2D" uid="uid://h0skytm8grcu" path="res://icon.svg" id="1_2jq3x"] - -[resource] -albedo_texture = ExtResource("1_2jq3x") -texture_filter = 1 diff --git a/Scenes/RegionMaterial.tres b/Scenes/RegionMaterial.tres new file mode 100644 index 0000000..47d692c --- /dev/null +++ b/Scenes/RegionMaterial.tres @@ -0,0 +1,8 @@ +[gd_resource type="StandardMaterial3D" load_steps=2 format=3 uid="uid://bb47mhgbxy3cw"] + +[ext_resource type="Texture2D" uid="uid://buoupwtftxjse" path="res://Art/Stone_05-128x128.png" id="1_cgxdm"] + +[resource] +shading_mode = 0 +albedo_texture = ExtResource("1_cgxdm") +texture_filter = 0 diff --git a/Scripts/Space/SpaceRegion.gd b/Scripts/Space/SpaceRegion.gd index d8b2cbb..3907326 100644 --- a/Scripts/Space/SpaceRegion.gd +++ b/Scripts/Space/SpaceRegion.gd @@ -5,9 +5,15 @@ class_name SpaceRegion @export var elevation: float = 0.0 @export var height: float = 100.0 +@export var wall_texture: Texture2D +@export var floor_texture: Texture2D func generate_geometry(space: Space) -> Node3D: + return _generate_geometry(space, true) + + +func _generate_geometry(space: Space, looked_from_inside: bool) -> Node3D: var geometry := MeshInstance3D.new() geometry.name = name @@ -19,46 +25,57 @@ func generate_geometry(space: Space) -> Node3D: var vertices = PackedVector3Array() var uvs = PackedVector2Array() for line in polygon_pairs: - vertices.append(Vector3( - line[0][0] * space.unit_scale, elevation * space.unit_scale, - line[0][1] * space.unit_scale - )) - vertices.append(Vector3( - line[1][0] * space.unit_scale, (elevation + height) * space.unit_scale, - line[1][1] * space.unit_scale, - )) - vertices.append(Vector3( - line[1][0] * space.unit_scale, elevation * space.unit_scale, - line[1][1] * space.unit_scale, - )) - vertices.append(Vector3( - line[1][0] * space.unit_scale, (elevation + height) * space.unit_scale, - line[1][1] * space.unit_scale, - )) - vertices.append(Vector3( - line[0][0] * space.unit_scale, elevation * space.unit_scale, - line[0][1] * space.unit_scale, - )) - vertices.append(Vector3( - line[0][0] * space.unit_scale, (elevation + height) * space.unit_scale, - line[0][1] * space.unit_scale, - )) - uvs.append(Vector2(0, 1)) - uvs.append(Vector2(1, 0)) - uvs.append(Vector2(1, 1)) - uvs.append(Vector2(1, 0)) - uvs.append(Vector2(0, 1)) - uvs.append(Vector2(0, 0)) + _push_line(space, line, vertices, uvs, looked_from_inside) - var arrays = Array() + var arrays := Array() arrays.resize(Mesh.ARRAY_MAX) arrays[Mesh.ARRAY_VERTEX] = vertices arrays[Mesh.ARRAY_TEX_UV] = uvs - var mesh = ArrayMesh.new() + var mesh := ArrayMesh.new() mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, arrays) - mesh.surface_set_material(0, preload("res://Scenes/Material.tres")) + + var new_material := preload("res://Scenes/RegionMaterial.tres") + new_material.albedo_texture = wall_texture + + mesh.surface_set_material(0, new_material) geometry.mesh = mesh + for child in get_children(): + if child is SpaceRegion: + geometry.add_child(child._generate_geometry(space, not looked_from_inside)) + return geometry + + +func _push_line(space: Space, + line: Array, + vertices: PackedVector3Array, + uvs: PackedVector2Array, + looked_from_inside: bool +): + var v0 := Vector3( + line[0][0] * space.unit_scale, elevation * space.unit_scale, + line[0][1] * space.unit_scale) + var v1 := Vector3( + line[1][0] * space.unit_scale, (elevation + height) * space.unit_scale, + line[1][1] * space.unit_scale) + var v2 := Vector3( + line[1][0] * space.unit_scale, elevation * space.unit_scale, + line[1][1] * space.unit_scale) + var v3 := Vector3( + line[0][0] * space.unit_scale, (elevation + height) * space.unit_scale, + line[0][1] * space.unit_scale) + + if looked_from_inside: + vertices.append_array([v0, v1, v2, v1, v0, v3]) + else: + vertices.append_array([v0, v2, v1, v1, v3, v0]) + + uvs.append(Vector2(0, 1)) + uvs.append(Vector2(1, 0)) + uvs.append(Vector2(1, 1)) + uvs.append(Vector2(1, 0)) + uvs.append(Vector2(0, 1)) + uvs.append(Vector2(0, 0)) diff --git a/Spaces/Dungeon.tscn b/Spaces/Dungeon.tscn index 2bd43d9..ebf81b1 100644 --- a/Spaces/Dungeon.tscn +++ b/Spaces/Dungeon.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://deff7lt34nj0h"] +[gd_scene load_steps=7 format=3 uid="uid://deff7lt34nj0h"] [ext_resource type="Script" path="res://Scripts/Space/Space.gd" id="1_ckp7u"] [ext_resource type="Script" path="res://Scripts/Space/SpaceRegion.gd" id="2_s3h7s"] [ext_resource type="Texture2D" uid="uid://h0skytm8grcu" path="res://icon.svg" id="3_7vff1"] +[ext_resource type="Texture2D" uid="uid://icmmuqquxhq3" path="res://Art/Stone_06-128x128.png" id="3_ondo6"] +[ext_resource type="Texture2D" uid="uid://buoupwtftxjse" path="res://Art/Stone_05-128x128.png" id="3_r08k8"] [ext_resource type="Script" path="res://Scripts/Space/SpaceSpawn.gd" id="4_rhl23"] [node name="Dungeon" type="Node2D"] @@ -12,6 +14,16 @@ script = ExtResource("1_ckp7u") position = Vector2(-30, -8) polygon = PackedVector2Array(30, 72, 262, 32, 497, 192, 286, 328, 94, 264) script = ExtResource("2_s3h7s") +wall_texture = ExtResource("3_ondo6") +floor_texture = ExtResource("3_r08k8") + +[node name="Column" type="Polygon2D" parent="Room"] +position = Vector2(78, -8) +color = Color(0.665891, 0.820479, 1, 1) +polygon = PackedVector2Array(222, 168, 272, 136, 318, 184, 294, 232, 230, 216) +script = ExtResource("2_s3h7s") +wall_texture = ExtResource("3_r08k8") +floor_texture = ExtResource("3_r08k8") [node name="Spawn" type="Sprite2D" parent="."] position = Vector2(72, 104)