proper handling of nesting in coordinates

This commit is contained in:
veclav talica 2024-08-02 04:38:05 +03:00
parent 59384ce345
commit 8908b51103
5 changed files with 41 additions and 20 deletions

View File

@ -3,19 +3,20 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://eempmja460l5" uid="uid://eempmja460l5"
path="res://.godot/imported/Stone_11-128x128.png-74289798a2555c4732a5c0fbe1b7230c.ctex" path.s3tc="res://.godot/imported/Stone_11-128x128.png-74289798a2555c4732a5c0fbe1b7230c.s3tc.ctex"
metadata={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://Art/Stone_11-128x128.png" source_file="res://Art/Stone_11-128x128.png"
dest_files=["res://.godot/imported/Stone_11-128x128.png-74289798a2555c4732a5c0fbe1b7230c.ctex"] dest_files=["res://.godot/imported/Stone_11-128x128.png-74289798a2555c4732a5c0fbe1b7230c.s3tc.ctex"]
[params] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1

View File

@ -22,8 +22,13 @@ func generate_geometry() -> Node3D:
func get_spawn_point() -> Vector3: func get_spawn_point() -> Vector3:
for child in get_children(): var stack := [self]
while stack:
var node = stack.pop_front()
for child in node.get_children():
if child is SpaceSpawn: if child is SpaceSpawn:
return child.space_position(self) return child.space_position(self)
stack.push_back(child)
return Vector3.ZERO return Vector3.ZERO

View File

@ -1,7 +1,10 @@
@tool
extends SpaceEntity extends SpaceEntity
class_name SpaceRegion ## Classic 2.5D sector beauty.
##
class_name SpaceRegion
@export var elevation: float = 0.0 @export var elevation: float = 0.0
@export var height: float = 100.0 @export var height: float = 100.0
@ -13,9 +16,19 @@ func generate_geometry(space: Space) -> Node3D:
return _generate_geometry(space, true) return _generate_geometry(space, true)
func _process(delta):
if Engine.is_editor_hint():
self.texture = floor_texture
func _generate_geometry(space: Space, looked_from_inside: bool) -> Node3D: func _generate_geometry(space: Space, looked_from_inside: bool) -> Node3D:
var geometry := MeshInstance3D.new() var geometry := MeshInstance3D.new()
geometry.name = name geometry.name = name
geometry.position = Vector3(
position.x * space.unit_scale,
0,
position.y * space.unit_scale,
)
var mesh := ArrayMesh.new() var mesh := ArrayMesh.new()
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_wall_arrays(space, looked_from_inside)) mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_wall_arrays(space, looked_from_inside))

View File

@ -7,4 +7,4 @@ class_name SpaceSpawn
func space_position(space: Space) -> Vector3: func space_position(space: Space) -> Vector3:
# todo: Get current region elevation # todo: Get current region elevation
return Vector3(position.x * space.unit_scale, 0, position.y * space.unit_scale) return Vector3(global_position.x * space.unit_scale, 0, global_position.y * space.unit_scale)

View File

@ -1,33 +1,35 @@
[gd_scene load_steps=8 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/Space.gd" id="1_ckp7u"]
[ext_resource type="Script" path="res://Scripts/Space/SpaceRegion.gd" id="2_s3h7s"] [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://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://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="Texture2D" uid="uid://eempmja460l5" path="res://Art/Stone_11-128x128.png" id="4_mnswr"] [ext_resource type="Texture2D" uid="uid://eempmja460l5" path="res://Art/Stone_11-128x128.png" id="4_mnswr"]
[ext_resource type="Script" path="res://Scripts/Space/SpaceSpawn.gd" id="4_rhl23"] [ext_resource type="Script" path="res://Scripts/Space/SpaceSpawn.gd" id="4_rhl23"]
[node name="Dungeon" type="Node2D"] [node name="Dungeon" type="Node2D"]
script = ExtResource("1_ckp7u") script = ExtResource("1_ckp7u")
unit_scale = 0.02
[node name="Room" type="Polygon2D" parent="."] [node name="Room" type="Polygon2D" parent="."]
position = Vector2(-30, -8) texture_repeat = 2
polygon = PackedVector2Array(30, 72, 262, 32, 497, 192, 286, 328, 94, 264) position = Vector2(440, 136)
texture = ExtResource("4_mnswr")
polygon = PackedVector2Array(-104, -80, 40, -112, 128, -16, 328, -56, 360, 16, 176, 56, 32, 96, -80, 64)
uv = PackedVector2Array(1.88, 5.28, 0.6, 1.44, 5.24, 0.64, 5.24, 0.64, 9.94, 3.84, 5.72, 6.56, 5.72, 6.56, 1.88, 5.28, 5.24, 0.64)
script = ExtResource("2_s3h7s") script = ExtResource("2_s3h7s")
wall_texture = ExtResource("3_ondo6") wall_texture = ExtResource("3_ondo6")
floor_texture = ExtResource("4_mnswr") floor_texture = ExtResource("4_mnswr")
[node name="Column" type="Polygon2D" parent="Room"] [node name="Column" type="Polygon2D" parent="Room"]
position = Vector2(78, -8) texture_repeat = 2
color = Color(0.665891, 0.820479, 1, 1) polygon = PackedVector2Array(8, -40, 48, -64, 88, -24, 64, 0, 24, -8)
polygon = PackedVector2Array(222, 168, 272, 136, 318, 184, 294, 232, 230, 216) uv = PackedVector2Array(1.88, 5.28, 0.6, 1.44, 5.24, 0.64, 5.24, 0.64, 9.94, 3.84, 5.72, 6.56, 5.72, 6.56, 1.88, 5.28, 5.24, 0.64)
script = ExtResource("2_s3h7s") script = ExtResource("2_s3h7s")
wall_texture = ExtResource("3_r08k8") wall_texture = ExtResource("3_ondo6")
floor_texture = ExtResource("3_r08k8")
[node name="Spawn" type="Sprite2D" parent="."] [node name="Spawn" type="Sprite2D" parent="Room"]
position = Vector2(72, 104) position = Vector2(-48, 32)
rotation = 0.159622 rotation = 0.159622
scale = Vector2(0.25, 0.25) scale = Vector2(0.25, 0.25)
texture = ExtResource("3_7vff1") texture = ExtResource("3_7vff1")