diff --git a/MainMenu0.bin b/MainMenu0.bin new file mode 100644 index 0000000..16a0bc0 Binary files /dev/null and b/MainMenu0.bin differ diff --git a/addons/delaunator/Delaunator.gd b/addons/delaunator/Delaunator.gd index 7860fd2..ee0d43b 100644 --- a/addons/delaunator/Delaunator.gd +++ b/addons/delaunator/Delaunator.gd @@ -68,6 +68,7 @@ func _constructor(): func update(): var n = coords.size() >> 1 + Global.loadings["world_creation"].new_phase("Triangulation des points...", _ids.size()) # Populate an array of point indices; calculate input data bbox. var min_x = INF @@ -284,6 +285,7 @@ func update(): # Save the two new edges in the hash table. _hull_hash[_hash_key(x, y)] = i _hull_hash[_hash_key(coords[2 * e], coords[2 * e + 1])] = e + Global.loadings["world_creation"].increment_step() hull.resize(hull_size) var e = _hull_start diff --git a/menu/LoadingScreen.gd b/menu/LoadingScreen.gd index 7e9544f..3ec7eeb 100644 --- a/menu/LoadingScreen.gd +++ b/menu/LoadingScreen.gd @@ -2,21 +2,23 @@ extends Control var thread var world = {} -var old_step = 0 func _ready(): thread = Thread.new() thread.start(self, "_generate_world") set_process(true) - Global.loading.set_start_time() - + Global.loadings["world_creation"] = LoadingHelper.new() + func _process(_delta): - $ProgressBar.value = Global.loading.get_percentage() - if (Global.loading.get_end_time() > 0): - - Global.print_debug("Elapsed time : %f seconds" % Global.loading.get_elapsed_time("s")) + $VBoxContainer/ProgressBar.value = Global.loadings["world_creation"].get_percentage() + if Global.loadings["world_creation"].get_current_phase(): + $VBoxContainer/HBoxContainer/Phase.text = Global.loadings["world_creation"].get_current_phase().get_label() + if Global.loadings["world_creation"].is_finished: + for phase in Global.loadings["world_creation"].get_phases(): + Global.print_debug("%s : %f seconds" % [phase.get_label(), phase.get_elapsed_time("s")]) + + Global.print_debug("Elapsed time : %f seconds" % Global.loadings["world_creation"].get_elapsed_time("s")) get_tree().change_scene("res://world/game.tscn") - func _exit_tree(): thread.wait_to_finish() diff --git a/menu/LoadingScreen.tscn b/menu/LoadingScreen.tscn index b4df5ca..ab212ae 100644 --- a/menu/LoadingScreen.tscn +++ b/menu/LoadingScreen.tscn @@ -1,18 +1,149 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=37 format=2] [ext_resource path="res://menu/LoadingScreen.gd" type="Script" id=1] +[ext_resource path="res://theme/theme.tres" type="Theme" id=2] +[ext_resource path="res://theme/fonts/monogram.ttf" type="DynamicFontData" id=3] +[ext_resource path="res://menu/loading/frame-29.png" type="Texture" id=4] +[ext_resource path="res://menu/loading/frame-11.png" type="Texture" id=5] +[ext_resource path="res://menu/loading/frame-22.png" type="Texture" id=6] +[ext_resource path="res://menu/loading/frame-1.png" type="Texture" id=7] +[ext_resource path="res://menu/loading/frame-8.png" type="Texture" id=8] +[ext_resource path="res://menu/loading/frame-24.png" type="Texture" id=9] +[ext_resource path="res://menu/loading/frame-18.png" type="Texture" id=10] +[ext_resource path="res://menu/loading/frame-25.png" type="Texture" id=11] +[ext_resource path="res://menu/loading/frame-20.png" type="Texture" id=12] +[ext_resource path="res://menu/loading/frame-27.png" type="Texture" id=13] +[ext_resource path="res://menu/loading/frame-21.png" type="Texture" id=14] +[ext_resource path="res://menu/loading/frame-10.png" type="Texture" id=15] +[ext_resource path="res://menu/loading/frame-2.png" type="Texture" id=16] +[ext_resource path="res://menu/loading/frame-13.png" type="Texture" id=17] +[ext_resource path="res://menu/loading/frame-14.png" type="Texture" id=18] +[ext_resource path="res://menu/loading/frame-16.png" type="Texture" id=19] +[ext_resource path="res://menu/loading/frame-7.png" type="Texture" id=20] +[ext_resource path="res://menu/loading/frame-23.png" type="Texture" id=21] +[ext_resource path="res://menu/loading/frame-26.png" type="Texture" id=22] +[ext_resource path="res://menu/loading/frame-5.png" type="Texture" id=23] +[ext_resource path="res://menu/loading/frame-15.png" type="Texture" id=24] +[ext_resource path="res://menu/loading/frame-9.png" type="Texture" id=25] +[ext_resource path="res://menu/loading/frame-19.png" type="Texture" id=26] +[ext_resource path="res://menu/loading/frame-17.png" type="Texture" id=27] +[ext_resource path="res://menu/loading/frame-4.png" type="Texture" id=28] +[ext_resource path="res://menu/loading/frame-6.png" type="Texture" id=29] +[ext_resource path="res://menu/loading/frame-3.png" type="Texture" id=30] +[ext_resource path="res://menu/loading/frame-28.png" type="Texture" id=31] +[ext_resource path="res://menu/loading/frame-12.png" type="Texture" id=32] + +[sub_resource type="AnimatedTexture" id=4] +flags = 4 +frames = 29 +fps = 30.0 +frame_0/texture = ExtResource( 7 ) +frame_1/texture = ExtResource( 16 ) +frame_1/delay_sec = 0.0 +frame_2/texture = ExtResource( 30 ) +frame_2/delay_sec = 0.0 +frame_3/texture = ExtResource( 28 ) +frame_3/delay_sec = 0.0 +frame_4/texture = ExtResource( 23 ) +frame_4/delay_sec = 0.0 +frame_5/texture = ExtResource( 29 ) +frame_5/delay_sec = 0.0 +frame_6/texture = ExtResource( 20 ) +frame_6/delay_sec = 0.0 +frame_7/texture = ExtResource( 8 ) +frame_7/delay_sec = 0.0 +frame_8/texture = ExtResource( 25 ) +frame_8/delay_sec = 0.0 +frame_9/texture = ExtResource( 15 ) +frame_9/delay_sec = 0.0 +frame_10/texture = ExtResource( 5 ) +frame_10/delay_sec = 0.0 +frame_11/texture = ExtResource( 32 ) +frame_11/delay_sec = 0.0 +frame_12/texture = ExtResource( 17 ) +frame_12/delay_sec = 0.0 +frame_13/texture = ExtResource( 18 ) +frame_13/delay_sec = 0.0 +frame_14/texture = ExtResource( 24 ) +frame_14/delay_sec = 0.0 +frame_15/texture = ExtResource( 19 ) +frame_15/delay_sec = 0.0 +frame_16/texture = ExtResource( 27 ) +frame_16/delay_sec = 0.0 +frame_17/texture = ExtResource( 10 ) +frame_17/delay_sec = 0.0 +frame_18/texture = ExtResource( 26 ) +frame_18/delay_sec = 0.0 +frame_19/texture = ExtResource( 12 ) +frame_19/delay_sec = 0.0 +frame_20/texture = ExtResource( 14 ) +frame_20/delay_sec = 0.0 +frame_21/texture = ExtResource( 6 ) +frame_21/delay_sec = 0.0 +frame_22/texture = ExtResource( 21 ) +frame_22/delay_sec = 0.0 +frame_23/texture = ExtResource( 9 ) +frame_23/delay_sec = 0.0 +frame_24/texture = ExtResource( 11 ) +frame_24/delay_sec = 0.0 +frame_25/texture = ExtResource( 22 ) +frame_25/delay_sec = 0.0 +frame_26/texture = ExtResource( 13 ) +frame_26/delay_sec = 0.0 +frame_27/texture = ExtResource( 31 ) +frame_27/delay_sec = 0.0 +frame_28/texture = ExtResource( 4 ) +frame_28/delay_sec = 0.0 + +[sub_resource type="DynamicFont" id=2] +size = 50 +font_data = ExtResource( 3 ) + +[sub_resource type="DynamicFont" id=3] +size = 36 +font_data = ExtResource( 3 ) + +[sub_resource type="StyleBoxFlat" id=1] [node name="LoadingScreen" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 script = ExtResource( 1 ) -[node name="ProgressBar" type="ProgressBar" parent="."] +[node name="VBoxContainer" type="VBoxContainer" parent="."] anchor_left = 0.5 anchor_top = 0.5 anchor_right = 0.5 anchor_bottom = 0.5 -margin_left = -82.5 -margin_top = -7.0 -margin_right = 82.5 -margin_bottom = 7.0 +margin_left = -335.0 +margin_top = -142.0 +margin_right = 335.0 +margin_bottom = 142.0 +alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"] +margin_top = 99.0 +margin_right = 670.0 +margin_bottom = 151.0 + +[node name="TextureRect" type="TextureRect" parent="VBoxContainer/HBoxContainer"] +margin_right = 57.0 +margin_bottom = 52.0 +texture = SubResource( 4 ) + +[node name="Phase" type="Label" parent="VBoxContainer/HBoxContainer"] +margin_left = 61.0 +margin_top = 5.0 +margin_right = 61.0 +margin_bottom = 46.0 +theme = ExtResource( 2 ) +custom_fonts/font = SubResource( 2 ) + +[node name="ProgressBar" type="ProgressBar" parent="VBoxContainer"] +margin_top = 155.0 +margin_right = 670.0 +margin_bottom = 184.0 +custom_fonts/font = SubResource( 3 ) +custom_styles/fg = SubResource( 1 ) +min_value = 0.1 +value = 0.1 diff --git a/menu/loading/frame-1.png b/menu/loading/frame-1.png new file mode 100644 index 0000000..b8d8abb Binary files /dev/null and b/menu/loading/frame-1.png differ diff --git a/menu/loading/frame-1.png.import b/menu/loading/frame-1.png.import new file mode 100644 index 0000000..9fb71b0 --- /dev/null +++ b/menu/loading/frame-1.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-1.png-3334ac967fb635d82035da8537e2ea67.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-1.png" +dest_files=[ "res://.import/frame-1.png-3334ac967fb635d82035da8537e2ea67.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-10.png b/menu/loading/frame-10.png new file mode 100644 index 0000000..ecbed27 Binary files /dev/null and b/menu/loading/frame-10.png differ diff --git a/menu/loading/frame-10.png.import b/menu/loading/frame-10.png.import new file mode 100644 index 0000000..f82b049 --- /dev/null +++ b/menu/loading/frame-10.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-10.png-3a553502c517cb3e79a0b272af79609c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-10.png" +dest_files=[ "res://.import/frame-10.png-3a553502c517cb3e79a0b272af79609c.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-11.png b/menu/loading/frame-11.png new file mode 100644 index 0000000..d53441b Binary files /dev/null and b/menu/loading/frame-11.png differ diff --git a/menu/loading/frame-11.png.import b/menu/loading/frame-11.png.import new file mode 100644 index 0000000..aa2fcb7 --- /dev/null +++ b/menu/loading/frame-11.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-11.png-38cce6ff10e44573341db67875466f62.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-11.png" +dest_files=[ "res://.import/frame-11.png-38cce6ff10e44573341db67875466f62.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-12.png b/menu/loading/frame-12.png new file mode 100644 index 0000000..2c7675b Binary files /dev/null and b/menu/loading/frame-12.png differ diff --git a/menu/loading/frame-12.png.import b/menu/loading/frame-12.png.import new file mode 100644 index 0000000..a23a56c --- /dev/null +++ b/menu/loading/frame-12.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-12.png-b3dc3514abe05a5ed5d7a0233c71e702.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-12.png" +dest_files=[ "res://.import/frame-12.png-b3dc3514abe05a5ed5d7a0233c71e702.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-13.png b/menu/loading/frame-13.png new file mode 100644 index 0000000..aec453d Binary files /dev/null and b/menu/loading/frame-13.png differ diff --git a/menu/loading/frame-13.png.import b/menu/loading/frame-13.png.import new file mode 100644 index 0000000..4ade625 --- /dev/null +++ b/menu/loading/frame-13.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-13.png-0915e3c8ea8f49a40801b747ac8ce772.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-13.png" +dest_files=[ "res://.import/frame-13.png-0915e3c8ea8f49a40801b747ac8ce772.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-14.png b/menu/loading/frame-14.png new file mode 100644 index 0000000..054d781 Binary files /dev/null and b/menu/loading/frame-14.png differ diff --git a/menu/loading/frame-14.png.import b/menu/loading/frame-14.png.import new file mode 100644 index 0000000..a0c650a --- /dev/null +++ b/menu/loading/frame-14.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-14.png-08719e8cc395231f52e1bf585982a15a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-14.png" +dest_files=[ "res://.import/frame-14.png-08719e8cc395231f52e1bf585982a15a.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-15.png b/menu/loading/frame-15.png new file mode 100644 index 0000000..8ecc8ed Binary files /dev/null and b/menu/loading/frame-15.png differ diff --git a/menu/loading/frame-15.png.import b/menu/loading/frame-15.png.import new file mode 100644 index 0000000..f062311 --- /dev/null +++ b/menu/loading/frame-15.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-15.png-fd46532c64ff86a95f73e66b5f2314e2.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-15.png" +dest_files=[ "res://.import/frame-15.png-fd46532c64ff86a95f73e66b5f2314e2.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-16.png b/menu/loading/frame-16.png new file mode 100644 index 0000000..64cc543 Binary files /dev/null and b/menu/loading/frame-16.png differ diff --git a/menu/loading/frame-16.png.import b/menu/loading/frame-16.png.import new file mode 100644 index 0000000..2400c8e --- /dev/null +++ b/menu/loading/frame-16.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-16.png-fc6d47bd5da9905ff937b3c36f8c5a8b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-16.png" +dest_files=[ "res://.import/frame-16.png-fc6d47bd5da9905ff937b3c36f8c5a8b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-17.png b/menu/loading/frame-17.png new file mode 100644 index 0000000..7a798d7 Binary files /dev/null and b/menu/loading/frame-17.png differ diff --git a/menu/loading/frame-17.png.import b/menu/loading/frame-17.png.import new file mode 100644 index 0000000..cb9f766 --- /dev/null +++ b/menu/loading/frame-17.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-17.png-7893018f592835a7aebb29114104fb24.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-17.png" +dest_files=[ "res://.import/frame-17.png-7893018f592835a7aebb29114104fb24.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-18.png b/menu/loading/frame-18.png new file mode 100644 index 0000000..239556b Binary files /dev/null and b/menu/loading/frame-18.png differ diff --git a/menu/loading/frame-18.png.import b/menu/loading/frame-18.png.import new file mode 100644 index 0000000..5fc08c9 --- /dev/null +++ b/menu/loading/frame-18.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-18.png-f3248f1e9a5bec919f6a760e3850a257.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-18.png" +dest_files=[ "res://.import/frame-18.png-f3248f1e9a5bec919f6a760e3850a257.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-19.png b/menu/loading/frame-19.png new file mode 100644 index 0000000..4a6bd71 Binary files /dev/null and b/menu/loading/frame-19.png differ diff --git a/menu/loading/frame-19.png.import b/menu/loading/frame-19.png.import new file mode 100644 index 0000000..b5f5bdd --- /dev/null +++ b/menu/loading/frame-19.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-19.png-b1cbcfad0cd7cbf7a82c169c1f75ef1e.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-19.png" +dest_files=[ "res://.import/frame-19.png-b1cbcfad0cd7cbf7a82c169c1f75ef1e.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-2.png b/menu/loading/frame-2.png new file mode 100644 index 0000000..da45c54 Binary files /dev/null and b/menu/loading/frame-2.png differ diff --git a/menu/loading/frame-2.png.import b/menu/loading/frame-2.png.import new file mode 100644 index 0000000..8867409 --- /dev/null +++ b/menu/loading/frame-2.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-2.png-670b98edac403f62ca585a91e149c443.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-2.png" +dest_files=[ "res://.import/frame-2.png-670b98edac403f62ca585a91e149c443.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-20.png b/menu/loading/frame-20.png new file mode 100644 index 0000000..9049b91 Binary files /dev/null and b/menu/loading/frame-20.png differ diff --git a/menu/loading/frame-20.png.import b/menu/loading/frame-20.png.import new file mode 100644 index 0000000..32786a2 --- /dev/null +++ b/menu/loading/frame-20.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-20.png-f2216218d7d27fcb0865740c5b5c526d.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-20.png" +dest_files=[ "res://.import/frame-20.png-f2216218d7d27fcb0865740c5b5c526d.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-21.png b/menu/loading/frame-21.png new file mode 100644 index 0000000..ac713cd Binary files /dev/null and b/menu/loading/frame-21.png differ diff --git a/menu/loading/frame-21.png.import b/menu/loading/frame-21.png.import new file mode 100644 index 0000000..774f4c1 --- /dev/null +++ b/menu/loading/frame-21.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-21.png-ea4f0f623ed73fe68a0737887b578e3b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-21.png" +dest_files=[ "res://.import/frame-21.png-ea4f0f623ed73fe68a0737887b578e3b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-22.png b/menu/loading/frame-22.png new file mode 100644 index 0000000..21e405b Binary files /dev/null and b/menu/loading/frame-22.png differ diff --git a/menu/loading/frame-22.png.import b/menu/loading/frame-22.png.import new file mode 100644 index 0000000..23d62e8 --- /dev/null +++ b/menu/loading/frame-22.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-22.png-9a93d459142e84d19ebced361833dc86.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-22.png" +dest_files=[ "res://.import/frame-22.png-9a93d459142e84d19ebced361833dc86.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-23.png b/menu/loading/frame-23.png new file mode 100644 index 0000000..d76bcca Binary files /dev/null and b/menu/loading/frame-23.png differ diff --git a/menu/loading/frame-23.png.import b/menu/loading/frame-23.png.import new file mode 100644 index 0000000..d30b1a1 --- /dev/null +++ b/menu/loading/frame-23.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-23.png-dc9e5c0b964298af4319f8386cae95d9.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-23.png" +dest_files=[ "res://.import/frame-23.png-dc9e5c0b964298af4319f8386cae95d9.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-24.png b/menu/loading/frame-24.png new file mode 100644 index 0000000..21d8dd9 Binary files /dev/null and b/menu/loading/frame-24.png differ diff --git a/menu/loading/frame-24.png.import b/menu/loading/frame-24.png.import new file mode 100644 index 0000000..f745b45 --- /dev/null +++ b/menu/loading/frame-24.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-24.png-a90c66ff7397c44eb30d71407f61a9da.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-24.png" +dest_files=[ "res://.import/frame-24.png-a90c66ff7397c44eb30d71407f61a9da.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-25.png b/menu/loading/frame-25.png new file mode 100644 index 0000000..bac055c Binary files /dev/null and b/menu/loading/frame-25.png differ diff --git a/menu/loading/frame-25.png.import b/menu/loading/frame-25.png.import new file mode 100644 index 0000000..9849ef5 --- /dev/null +++ b/menu/loading/frame-25.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-25.png-6ca5c3c3ce575ddaf9aa1d7291cb4402.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-25.png" +dest_files=[ "res://.import/frame-25.png-6ca5c3c3ce575ddaf9aa1d7291cb4402.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-26.png b/menu/loading/frame-26.png new file mode 100644 index 0000000..f6963d7 Binary files /dev/null and b/menu/loading/frame-26.png differ diff --git a/menu/loading/frame-26.png.import b/menu/loading/frame-26.png.import new file mode 100644 index 0000000..65dcb67 --- /dev/null +++ b/menu/loading/frame-26.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-26.png-5d5bacec35b0575ad2ddffc8c8505b6b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-26.png" +dest_files=[ "res://.import/frame-26.png-5d5bacec35b0575ad2ddffc8c8505b6b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-27.png b/menu/loading/frame-27.png new file mode 100644 index 0000000..ed9068d Binary files /dev/null and b/menu/loading/frame-27.png differ diff --git a/menu/loading/frame-27.png.import b/menu/loading/frame-27.png.import new file mode 100644 index 0000000..b09f5d4 --- /dev/null +++ b/menu/loading/frame-27.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-27.png-1aeaf2194eb51a1eaae8c06e437b9353.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-27.png" +dest_files=[ "res://.import/frame-27.png-1aeaf2194eb51a1eaae8c06e437b9353.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-28.png b/menu/loading/frame-28.png new file mode 100644 index 0000000..5dcc230 Binary files /dev/null and b/menu/loading/frame-28.png differ diff --git a/menu/loading/frame-28.png.import b/menu/loading/frame-28.png.import new file mode 100644 index 0000000..c473155 --- /dev/null +++ b/menu/loading/frame-28.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-28.png-3140f5d63c3ce0ea0caed07dba005208.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-28.png" +dest_files=[ "res://.import/frame-28.png-3140f5d63c3ce0ea0caed07dba005208.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-29.png b/menu/loading/frame-29.png new file mode 100644 index 0000000..b8d8abb Binary files /dev/null and b/menu/loading/frame-29.png differ diff --git a/menu/loading/frame-29.png.import b/menu/loading/frame-29.png.import new file mode 100644 index 0000000..3bda2c8 --- /dev/null +++ b/menu/loading/frame-29.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-29.png-832132f992ba28acce4eb8cfea2906e8.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-29.png" +dest_files=[ "res://.import/frame-29.png-832132f992ba28acce4eb8cfea2906e8.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-3.png b/menu/loading/frame-3.png new file mode 100644 index 0000000..044326d Binary files /dev/null and b/menu/loading/frame-3.png differ diff --git a/menu/loading/frame-3.png.import b/menu/loading/frame-3.png.import new file mode 100644 index 0000000..c53fdfe --- /dev/null +++ b/menu/loading/frame-3.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-3.png-2ab5e40b803c7bf1f02ee0d91afadfe4.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-3.png" +dest_files=[ "res://.import/frame-3.png-2ab5e40b803c7bf1f02ee0d91afadfe4.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-4.png b/menu/loading/frame-4.png new file mode 100644 index 0000000..a14d60d Binary files /dev/null and b/menu/loading/frame-4.png differ diff --git a/menu/loading/frame-4.png.import b/menu/loading/frame-4.png.import new file mode 100644 index 0000000..d7a7b5a --- /dev/null +++ b/menu/loading/frame-4.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-4.png-44d10adbaa900926b3b2f1ff65016153.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-4.png" +dest_files=[ "res://.import/frame-4.png-44d10adbaa900926b3b2f1ff65016153.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-5.png b/menu/loading/frame-5.png new file mode 100644 index 0000000..822e8fb Binary files /dev/null and b/menu/loading/frame-5.png differ diff --git a/menu/loading/frame-5.png.import b/menu/loading/frame-5.png.import new file mode 100644 index 0000000..5c387fb --- /dev/null +++ b/menu/loading/frame-5.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-5.png-605828b97ef9e87f5868335511e6043c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-5.png" +dest_files=[ "res://.import/frame-5.png-605828b97ef9e87f5868335511e6043c.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-6.png b/menu/loading/frame-6.png new file mode 100644 index 0000000..a886410 Binary files /dev/null and b/menu/loading/frame-6.png differ diff --git a/menu/loading/frame-6.png.import b/menu/loading/frame-6.png.import new file mode 100644 index 0000000..d7a88fb --- /dev/null +++ b/menu/loading/frame-6.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-6.png-36b312eee2be191bd902ee7717f786a6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-6.png" +dest_files=[ "res://.import/frame-6.png-36b312eee2be191bd902ee7717f786a6.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-7.png b/menu/loading/frame-7.png new file mode 100644 index 0000000..27540ab Binary files /dev/null and b/menu/loading/frame-7.png differ diff --git a/menu/loading/frame-7.png.import b/menu/loading/frame-7.png.import new file mode 100644 index 0000000..84d5040 --- /dev/null +++ b/menu/loading/frame-7.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-7.png-6f2f3df6b1b4b70f68a44ef907f48982.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-7.png" +dest_files=[ "res://.import/frame-7.png-6f2f3df6b1b4b70f68a44ef907f48982.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-8.png b/menu/loading/frame-8.png new file mode 100644 index 0000000..54fd618 Binary files /dev/null and b/menu/loading/frame-8.png differ diff --git a/menu/loading/frame-8.png.import b/menu/loading/frame-8.png.import new file mode 100644 index 0000000..17d37d7 --- /dev/null +++ b/menu/loading/frame-8.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-8.png-32e5216802e1f252828d128dd2f25762.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-8.png" +dest_files=[ "res://.import/frame-8.png-32e5216802e1f252828d128dd2f25762.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/menu/loading/frame-9.png b/menu/loading/frame-9.png new file mode 100644 index 0000000..10213d4 Binary files /dev/null and b/menu/loading/frame-9.png differ diff --git a/menu/loading/frame-9.png.import b/menu/loading/frame-9.png.import new file mode 100644 index 0000000..ec30158 --- /dev/null +++ b/menu/loading/frame-9.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/frame-9.png-fe8ad182e6b982c03fadda58c8d4014b.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://menu/loading/frame-9.png" +dest_files=[ "res://.import/frame-9.png-fe8ad182e6b982c03fadda58c8d4014b.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot index 3750e34..15d33c5 100644 --- a/project.godot +++ b/project.godot @@ -19,17 +19,17 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://utils/camera/outline.gd" }, { -"base": "Spatial", -"class": "Chunk", -"language": "GDScript", -"path": "res://world/chunk.gd" -}, { "base": "Reference", "class": "Delaunator", "language": "GDScript", "path": "res://addons/delaunator/Delaunator.gd" }, { "base": "Reference", +"class": "LoadingHelper", +"language": "GDScript", +"path": "res://utils/loading/LoadingHelper.gd" +}, { +"base": "Reference", "class": "PoissonDiscSampling", "language": "GDScript", "path": "res://addons/PoissonDiscSampling/PoissonDiscSampling.gd" @@ -39,6 +39,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://utils/terrain/Terrain.gd" }, { +"base": "ArrayMesh", +"class": "TerrainMesh", +"language": "GDScript", +"path": "res://utils/terrain_mesh/TerrainMesh.gd" +}, { "base": "Reference", "class": "WorldGeneration", "language": "GDScript", @@ -47,10 +52,11 @@ _global_script_classes=[ { _global_script_class_icons={ "CameraController": "", "CameraOutline": "", -"Chunk": "", "Delaunator": "", +"LoadingHelper": "", "PoissonDiscSampling": "", "Terrain": "", +"TerrainMesh": "", "WorldGeneration": "" } diff --git a/ui/map/map.gd b/ui/map/map.gd index 68b8ac8..177afc3 100644 --- a/ui/map/map.gd +++ b/ui/map/map.gd @@ -4,7 +4,8 @@ signal map_clicked func heightmap(): draw_rect(Rect2(Vector2(0, 0), Vector2(2048, 2048)), Color("#0e88bd")) - print (Global.terrain) + var coastline = PoolVector2Array() + for center in Global.terrain.get_centers(): if not center.get_data("ocean"): var colors = Gradient.new() @@ -23,13 +24,12 @@ func heightmap(): if center.polygon().size() > 2: draw_polygon(center.polygon(), PoolColorArray([color])) - var coastline = PoolVector2Array() - for center in Global.terrain.get_centers(): - if center.get_data("coast"): - for border in center.borders(): - if (border.end_center().get_data("ocean")): - coastline.append(border.line()[0]) - coastline.append(border.line()[1]) + if center.get_data("coast"): + for border in center.borders(): + if (border.end_center().get_data("ocean")): + coastline.append(border.line()[0]) + coastline.append(border.line()[1]) + # for edge in Global.terrain.get_edges(): # if edge.get_data("coast"): @@ -95,7 +95,6 @@ func draw_voronoi_cells_convex_hull(): draw_polygon(voronoi_cell, PoolColorArray([color])) func _draw(): - print("before drawing") heightmap() # draw_voronoi_cells() # draw_triangles_edges() diff --git a/utils/Global.gd b/utils/Global.gd index 03cd234..f1ffb16 100644 --- a/utils/Global.gd +++ b/utils/Global.gd @@ -4,63 +4,20 @@ var debug = true var terrain_name = "" var terrain_mesh: Mesh var terrain = Terrain.new() -var loading = loading_helper.new() +# var loading = LoadingHelper.new() +var loadings = {} +var materials +var count = 0 + +func _ready(): + var file = File.new() + file.open("res://world/materials/materials.json", File.READ) + materials = JSON.parse(file.get_as_text()).result + file.close() # Debuging messages func print_debug(message): if debug: print(message) -class loading_helper: - var _step = 0 - var _max_step = 0 - var _start_time = 0 - var _end_time = 0 - - func _init(): - pass - - func reset(): - _step = 0 - _max_step = 0 - _start_time = 0 - _end_time = 0 - - func set_step(number: int): - _step = number - - func get_step(): - return _step - - func increment_step(): - _step += 1 - - func set_max_step(number: int): - _max_step = number - - func get_max_step(): - return _max_step - - func set_start_time(): - _start_time = OS.get_ticks_msec() - - func get_start_time(): - return _start_time - - func set_end_time(): - _end_time = OS.get_ticks_msec() - - func get_end_time(): - return _end_time - - func get_elapsed_time(unit): - var elapsed_time = _end_time - _start_time - if unit == "s": - elapsed_time = float(elapsed_time) / 1000.0 - - return elapsed_time - func get_percentage(): - if get_max_step() > 0: - return float(get_step()) / float(get_max_step()) * 100 - return 0 diff --git a/utils/loading/LoadingHelper.gd b/utils/loading/LoadingHelper.gd new file mode 100644 index 0000000..b36982d --- /dev/null +++ b/utils/loading/LoadingHelper.gd @@ -0,0 +1,115 @@ +extends Reference +class_name LoadingHelper + +class Phase: + var _label: String + var _start_time = 0 + var _end_time = 0 + var is_loading = false + var is_finished = false + var _step = 0 + var _max_step = 0 + + func _init(label, max_step): + self._label = label + self._max_step = max_step + _start_time = OS.get_ticks_msec() + + func stop(): + _end_time = OS.get_ticks_msec() + set_step(_max_step) + is_loading = false + is_finished = true + + func get_label(): + return _label + + func set_max_step(number: int): + _max_step = number + + func get_max_step(): + return _max_step + + func set_step(number: int): + _step = number + + func get_step(): + return _step + + func increment_step(): + _step += 1 + + func get_start_time(): + return _start_time + + func get_end_time(): + return _end_time + + func get_elapsed_time(unit): + var elapsed_time = _end_time - _start_time + if unit == "s": + elapsed_time = float(elapsed_time) / 1000.0 + + return elapsed_time + +var is_loading = false +var is_finished = false +var _max_phases = 0 +var _phases = [] +var _coeffs +var _phases_progression = [] +var _total_coeffs = 0 + +func start(coeffs, first_phase_label, first_phase_max_step): + is_loading = true + self._max_phases = coeffs.size() + self._coeffs = coeffs + for coeff in coeffs: + self._total_coeffs += coeff + self._phases_progression.append(self._total_coeffs) + new_phase(first_phase_label, first_phase_max_step) + +func stop(): + is_loading = false + is_finished = true + if get_current_phase(): + get_current_phase().stop() + +func get_current_phase(): + if _phases.size() > 0: + return _phases[_phases.size() - 1] + return null + +func new_phase(label: String, max_step: int): + if get_current_phase(): + get_current_phase().stop() + _phases.append(Phase.new(label, max_step)) + +func increment_step(): + _phases[_phases.size() - 1].increment_step() + +func get_phases(): + return _phases + +func get_start_time(): + return _phases[0].get_start_time() + +func get_end_time(): + return get_current_phase().get_end_time() + +func get_elapsed_time(unit): + var elapsed_time = get_end_time() - get_start_time() + if unit == "s": + elapsed_time = float(elapsed_time) / 1000.0 + + return elapsed_time + +func get_percentage(): + var percentage = 0 + if _max_phases > 0: + var min_progress = float(_phases_progression[_phases.size() - 2]) / float(_total_coeffs) * 100 + var max_progress = float(_phases_progression[_phases.size() - 1]) / float(_total_coeffs) * 100 + var phase_progress = float(get_current_phase().get_step()) / float(get_current_phase().get_max_step()) + + percentage = range_lerp(phase_progress, 0, 1, min_progress, max_progress) + return percentage diff --git a/utils/terrain/Terrain.gd b/utils/terrain/Terrain.gd index 1bb71ea..62419ce 100644 --- a/utils/terrain/Terrain.gd +++ b/utils/terrain/Terrain.gd @@ -58,7 +58,19 @@ class VoronoiCenter: var data = _terrain._points_data[_idx] if data.has(key): return data[key] - + + func has_temp_key(key): + return _terrain._points_temp_data[_idx].has(key) + + func set_temp_data(key,value): + var data = _terrain._points_temp_data[_idx] + data[key] = value + + func get_temp_data(key): + var data = _terrain._points_temp_data[_idx] + if data.has(key): + return data[key] + func point3d(): return _terrain._points[_idx] @@ -99,6 +111,13 @@ class VoronoiCenter: list_corners.append(corner) return list_corners + func corner(idx): + var triangle = to_point().triangles_around()[idx] + return VoronoiCorner.new(triangle) + + func corner_count(): + return to_point().triangles_around().size() + func polygon(): var polygon = [] for corner in corners(): @@ -223,7 +242,19 @@ class Triangle: var data = _terrain._triangles_data[_idx] if data.has(key): return data[key] - + + func has_temp_key(key): + return _terrain._triangles_temp_data[_idx].has(key) + + func set_temp_data(key,value): + var data = _terrain._triangles_temp_data[_idx] + data[key] = value + + func get_temp_data(key): + var data = _terrain._triangles_temp_data[_idx] + if data.has(key): + return data[key] + func edges(): return [Edge.new(3 * _idx, _terrain), Edge.new(3 * _idx + 1, _terrain), Edge.new(3 * _idx + 2, _terrain)] @@ -243,37 +274,48 @@ class Triangle: return list_triangles func center2d(): - var points = points() - var a = points[0].point2d() - var b = points[1].point2d() - var c = points[2].point2d() - var ad = a[0] * a[0] + a[1] * a[1] - var bd = b[0] * b[0] + b[1] * b[1] - var cd = c[0] * c[0] + c[1] * c[1] - var D = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1])) - - return Vector2( - 1 / D * (ad * (b[1] - c[1]) + bd * (c[1] - a[1]) + cd * (a[1] - b[1])), - 1 / D * (ad * (c[0] - b[0]) + bd * (a[0] - c[0]) + cd * (b[0] - a[0])) - ) + var circumcenter = get_data("center2d") + if not circumcenter: + var points = points() + var a = points[0].point2d() + var b = points[1].point2d() + var c = points[2].point2d() + var ad = a[0] * a[0] + a[1] * a[1] + var bd = b[0] * b[0] + b[1] * b[1] + var cd = c[0] * c[0] + c[1] * c[1] + var D = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1])) + + circumcenter = Vector2( + 1 / D * (ad * (b[1] - c[1]) + bd * (c[1] - a[1]) + cd * (a[1] - b[1])), + 1 / D * (ad * (c[0] - b[0]) + bd * (a[0] - c[0]) + cd * (b[0] - a[0])) + ) + + set_data("center2d", circumcenter) + return circumcenter + return circumcenter # return (points[0].point2d() + points[1].point2d() + points[2].point2d()) / 3.0 func center3d(): - var points = points() - var a = points[0].point2d() - var b = points[1].point2d() - var c = points[2].point2d() - var ad = a[0] * a[0] + a[1] * a[1] - var bd = b[0] * b[0] + b[1] * b[1] - var cd = c[0] * c[0] + c[1] * c[1] - var D = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1])) - - return Vector3( - 1 / D * (ad * (b[1] - c[1]) + bd * (c[1] - a[1]) + cd * (a[1] - b[1])), - points[0].get_elevation(), - 1 / D * (ad * (c[0] - b[0]) + bd * (a[0] - c[0]) + cd * (b[0] - a[0])) - ) - + var circumcenter = get_data("center3d") + if not circumcenter: + var points = points() + var a = points[0].point2d() + var b = points[1].point2d() + var c = points[2].point2d() + var ad = a[0] * a[0] + a[1] * a[1] + var bd = b[0] * b[0] + b[1] * b[1] + var cd = c[0] * c[0] + c[1] * c[1] + var D = 2 * (a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1])) + + circumcenter = Vector3( + 1 / D * (ad * (b[1] - c[1]) + bd * (c[1] - a[1]) + cd * (a[1] - b[1])), + points[0].get_elevation(), + 1 / D * (ad * (c[0] - b[0]) + bd * (a[0] - c[0]) + cd * (b[0] - a[0])) + ) + + set_data("center3d", circumcenter) + return circumcenter + return circumcenter # var center2d = center2d() # return Vector3(center2d.x, ) # var points = points() @@ -359,6 +401,18 @@ class Point: var data = _terrain._points_data[_idx] if data.has(key): return data[key] + + func has_temp_key(key): + return _terrain._points_temp_data[_idx].has(key) + + func set_temp_data(key,value): + var data = _terrain._points_temp_data[_idx] + data[key] = value + + func get_temp_data(key): + var data = _terrain._points_temp_data[_idx] + if data.has(key): + return data[key] func point3d(): return _terrain._points[_idx] @@ -401,10 +455,13 @@ class Point: return list_points func triangles_around(): - var list_triangles = [] - for edge in edges_around(): - list_triangles.append(edge.triangle()) -# list_triangles.append(edge.opposite().triangle()) + var list_triangles = get_temp_data("triangles_around") + if not list_triangles: + list_triangles = [] + for edge in edges_around(): + list_triangles.append(edge.triangle()) + # list_triangles.append(edge.opposite().triangle()) + set_temp_data("triangles_around", list_triangles) return list_triangles # Edges iterator @@ -458,6 +515,17 @@ class Edge: var data = _terrain._edges_data[_idx] if data.has(key): return data[key] + + func has_temp_key(key): + return _terrain._edges_temp_data[_idx].has(key) + + func set_temp_data(key,value): + _terrain._edges_temp_data[_idx][key] = value + + func get_temp_data(key): + var data = _terrain._edges_temp_data[_idx] + if data.has(key): + return data[key] func next_half(): return Edge.new(_idx - 2 if _idx % 3 == 2 else _idx + 1, _terrain) @@ -500,6 +568,10 @@ var _data = {} var _points_data = [] var _edges_data = [] var _triangles_data = [] +var _temp_data = {} +var _points_temp_data = [] +var _edges_temp_data = [] +var _triangles_temp_data = [] var _created = false var _loaded = false @@ -563,12 +635,15 @@ func create(width:int, height:int, spacing:int, name:String): _height = height _spacing = spacing _name = name + Global.loadings["world_creation"].new_phase("Generation des points...", 1) _create_points() delaunay = Delaunator.new(_points) _halfedges = PoolIntArray(delaunay.halfedges) _triangles = PoolIntArray(delaunay.triangles) + Global.loadings["world_creation"].new_phase("Initialisation du terrain...", get_points().size() + get_edges().size()) + # Initialize find_point _data["find_point"]=[] _data["find_point"].resize(1024) @@ -576,24 +651,29 @@ func create(width:int, height:int, spacing:int, name:String): _data["find_point"][idx]=[] for point in get_points(): _data["find_point"][point.find_index()].append(point.get_index()) + Global.loadings["world_creation"].increment_step() # Initialize _points_to_halfedges for edge in get_edges(): var endpoint = _triangles[edge.next_half().get_index()] if (! _points_to_halfedges.has(endpoint) or _halfedges[edge.get_index()] == -1): _points_to_halfedges[endpoint] = edge.get_index() + Global.loadings["world_creation"].increment_step() # Initialise _points_data for point_idx in self.get_points().size(): _points_data.append({}) + _points_temp_data.append({}) # Initialise _edges_data for edge_idx in self.get_edges().size(): _edges_data.append({}) + _edges_temp_data.append({}) # Initialise _triangle_data for triangle_idx in self.get_triangles().size(): _triangles_data.append({}) + _triangles_temp_data.append({}) _created = true save() @@ -611,11 +691,37 @@ func _create_points(): # Terrain methodes func set_data(key,value): _data[key] = value + +func set_temp_data(key, value): + _temp_data[key] = value func get_data(key): if _data.has(key): return _data[key] +func get_temp_data(key): + if _temp_data.has(key): + return _temp_data[key] + +func reset_temp_data(): + _temp_data = {} + + # Reset _points_data + _points_temp_data = [] + for point_idx in self.get_points().size(): + _points_temp_data.append({}) + + # Reset _edges_data + _edges_temp_data = [] + for edge_idx in self.get_edges().size(): + _edges_temp_data.append({}) + + # Reset _triangle_data + _triangles_temp_data = [] + for triangle_idx in self.get_triangles().size(): + _triangles_temp_data.append({}) + + func get_triangles(): var triangles = Triangles.new(self) return triangles @@ -693,14 +799,14 @@ func delete(name): var filename = directory.get_next() while filename != "": if( directory.file_exists(filename)): - print("Found file: " + filename) + Global.print_debug("Found file: " + filename) directory.remove(filename) filename = directory.get_next() directory.list_dir_end() directory.change_dir("..") var result = directory.remove(name) if(result != OK): - print(result) + Global.print_debug(result) func save_parameter(): @@ -758,6 +864,19 @@ func load(name): # Load data if directory.file_exists("data.save"): load_data(name) + + # Initialise _points_temp_data + for point_idx in self.get_points().size(): + _points_temp_data.append({}) + + # Initialise _edges_temp_data + for edge_idx in self.get_edges().size(): + _edges_temp_data.append({}) + + # Initialise _triangle_temp_data + for triangle_idx in self.get_triangles().size(): + _triangles_temp_data.append({}) + _loaded = true diff --git a/utils/terrain_mesh/TerrainMesh.gd b/utils/terrain_mesh/TerrainMesh.gd new file mode 100644 index 0000000..e4bb3e7 --- /dev/null +++ b/utils/terrain_mesh/TerrainMesh.gd @@ -0,0 +1,114 @@ +extends ArrayMesh +class_name TerrainMesh + +var loader + +func create_mesh(): + var vertices = [] + var normals = [] + var uvs = [] + + var factor = Vector3(1, 120, 1) + Global.loadings["world_creation"].new_phase("Construction du modele 3d...", Global.terrain.get_centers().size()) + + for center in Global.terrain.get_centers(): + # Global.loadings["world_creation"].increment_step() + + + if not center.get_data("water"): + var material_id = Global.materials[center.get_data("material")] + var top_uv = Vector2(0, float(material_id) / (Global.materials.size()-1)) + var border_uv = Vector2(1, float(material_id) / (Global.materials.size()-1)) + var corner_number = center.corner_count() + for corner_count in corner_number: + var current_corner = center.corner(corner_count) + var next_corner + if corner_count < corner_number - 1: + next_corner = center.corner(corner_count + 1) + else: + next_corner = center.corner(0) + + for i in 3: + normals.append(Vector3.UP) + uvs.append(top_uv) + + vertices.append(Vector3(current_corner.point2d().x, center.get_elevation(), current_corner.point2d().y) * factor) + vertices.append(Vector3(next_corner.point2d().x, center.get_elevation(), next_corner.point2d().y) * factor) + vertices.append(Vector3(center.point2d().x, center.get_elevation(), center.point2d().y) * factor) + for edge in center.borders(): + if edge.end_center().get_elevation() < edge.start_center().get_elevation(): + var top = edge.start_center().get_elevation() + var bottom = edge.end_center().get_elevation() + if edge.end_center().get_data("ocean"): + bottom = 0.0 + + var a = Vector3(edge.start_corner().point3d().x, bottom, edge.start_corner().point3d().z) * factor + var b = Vector3(edge.end_corner().point3d().x, top, edge.end_corner().point3d().z) * factor + var c = Vector3(edge.start_corner().point3d().x, top, edge.start_corner().point3d().z) * factor + var d = Vector3(edge.end_corner().point3d().x, bottom, edge.end_corner().point3d().z) * factor + var normal = get_triangle_normal(a, b, c) + for i in 6: + normals.append(normal) + uvs.append(border_uv) + vertices.append(a) + vertices.append(b) + vertices.append(c) + + vertices.append(a) + vertices.append(d) + vertices.append(b) + Global.loadings["world_creation"].increment_step() + + + var array_mesh = [] + array_mesh.resize(Mesh.ARRAY_MAX) + array_mesh[Mesh.ARRAY_VERTEX] = PoolVector3Array(vertices) + array_mesh[Mesh.ARRAY_NORMAL] = PoolVector3Array(normals) + array_mesh[Mesh.ARRAY_TEX_UV] = PoolVector2Array(uvs) + + # var terrain_mesh = TerrainMesh.new() + var mesh = ArrayMesh.new() + + mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, array_mesh) + mesh.surface_set_material(0, load("res://world/materials/world.material")) + + save_mesh(array_mesh) + return array_mesh + +func get_triangle_normal(a, b, c): + # find the surface normal given 3 vertices + var side1 = b - a + var side2 = c - a + var normal = side1.cross(side2) + return normal + +func save_mesh(array_mesh): + var directory = Directory.new() + Global.print_debug("Save mesh : %s" %(Global.terrain_name)) + + # Goto terrain directory + directory.open("user://") + if not directory.dir_exists("terrain"): + directory.make_dir("terrain") + directory.change_dir("terrain") + if not directory.dir_exists(Global.terrain_name): + directory.make_dir(Global.terrain_name) + directory.change_dir(Global.terrain_name) + + var file = File.new() + var file_name = "user://terrain/%s/mesh.save" % (Global.terrain_name) + file.open(file_name, File.WRITE) + file.store_var(array_mesh) + file.close() + +func load_mesh(): + var file = File.new() + var file_name = "user://terrain/%s/mesh.save" % (Global.terrain_name) + Global.print_debug("Load mesh file : %s" % (file_name)) + if file.file_exists(file_name): + file.open(file_name, File.READ) + var array_mesh = file.get_var() + file.close() + return array_mesh + else: + Global.print_debug("The mesh file : %s does not exist" % (file_name)) diff --git a/utils/world_generation/WorldGeneration.gd b/utils/world_generation/WorldGeneration.gd index c80cba6..2b69554 100644 --- a/utils/world_generation/WorldGeneration.gd +++ b/utils/world_generation/WorldGeneration.gd @@ -10,64 +10,55 @@ export(int, 1, 30) var wavelength = 8 export(int) var border_width = 200 export(int) var terraces = 100 export(int) var terrace_height = 5 -export(float) var mountain_height = 10.0 / 24.0 +export(float) var mountain_height = 0.3 export(int) var river_proba = 200 var rng = RandomNumberGenerator.new() var noise = OpenSimplexNoise.new() func _init(): - Global.loading.reset() rng.randomize() noise.seed = rng.randi() noise.octaves = octaves if Global.terrain.exists(Global.terrain_name): + var coeffs = [1] + Global.loadings["world_creation"].start(coeffs, "Chargement...", 100) Global.terrain.load(Global.terrain_name) else: + var coeffs = [0, 1, 2, 2, 2, 2, 2, 8] + Global.loadings["world_creation"].start(coeffs, "Start", 100) Global.terrain.create(width,height,spacing,Global.terrain_name) - - var max_step = ( - # Global.terrain.get_triangles().size() - Global.terrain.get_points().size() - ) - - if Global.terrain.is_created(): - max_step += Global.terrain.get_points().size() - max_step += Global.terrain.get_centers().size() - Global.loading.set_step(Global.terrain.get_points().size()) - - Global.loading.set_max_step(max_step) if Global.terrain.is_created(): init_data() + Global.terrain.reset_temp_data() Global.terrain.save() - - if Global.terrain.is_created() or Global.terrain.is_loaded(): - pass - # create_map() - # Global.terrain.set_data("mesh", create_mesh()) - # add_trees() - # get_tree().change_scene("res://world/game.tscn") - else: - Global.print_debug("Pas de Global.terrain, pas de construction ...") - Global.print_debug("Pas de construction ..., pas de palais ...") - Global.print_debug("Pas de palais ..., pas de palais.") + var terrain_mesh = TerrainMesh.new() + Global.terrain.set_temp_data("mesh", terrain_mesh.create_mesh()) - Global.loading.set_end_time() + if Global.terrain.is_loaded(): + var terrain_mesh = TerrainMesh.new() + Global.terrain.set_temp_data("mesh", terrain_mesh.load_mesh()) + + Global.loadings["world_creation"].stop() func init_data(): + Global.loadings["world_creation"].new_phase("Generation des continents...", Global.terrain.get_centers().size()) for center in Global.terrain.get_centers(): center.set_elevation(find_elevation(center.point2d())) if center.get_elevation() <= 0.0: center.set_data("water", true) if center.get_elevation() >= mountain_height: center.set_data("mountain", true) - Global.loading.increment_step() + Global.loadings["world_creation"].increment_step() + + Global.loadings["world_creation"].new_phase("Remplissage des oceans...", 1) fill_oceans() # remove_holes() + Global.loadings["world_creation"].new_phase("Generation des biomes...", Global.terrain.get_centers().size()) for center in Global.terrain.get_centers(): center.set_data("coast", is_coast(center.to_point())) # if center.get_data("ocean"): @@ -78,6 +69,7 @@ func init_data(): center.set_data("material", "stone") if center.get_data("coast"): center.set_data("material", "sand") + Global.loadings["world_creation"].increment_step() @@ -279,69 +271,6 @@ func is_coast(point): - -func create_mesh(): - var file = File.new() - file.open("res://world/materials/materials.json", File.READ) - var materials = JSON.parse(file.get_as_text()).result - - var st = SurfaceTool.new() - - st.begin(Mesh.PRIMITIVE_TRIANGLES) - var factor = Vector3(1, 120, 1) - # for center in Global.terrain.get_centers(): - for i in range(1, 2048): - for j in range(1, 2048): - for center in Global.terrain.get_chunk(Vector2(i, j)): - # print(center.get_data("water")) - if not center.get_data("water"): - # print(center.get_data("material")) - var material_id = materials[center.get_data("material")] - var top_uv = Vector2(0, float(material_id) / (materials.size()-1)) - var border_uv = Vector2(1, float(material_id) / (materials.size()-1)) - - for edge in center.borders(): - if edge.end_center().get_elevation() < edge.start_center().get_elevation(): - var top = edge.start_center().get_elevation() - # if edge.start_center().get_data("ocean"): - # top = -1.0 - var bottom = edge.end_center().get_elevation() - if edge.end_center().get_data("ocean"): - bottom = 0.0 - st.add_uv(border_uv) - st.add_vertex(Vector3(edge.start_corner().point3d().x, bottom, edge.start_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.end_corner().point3d().x, top, edge.end_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.start_corner().point3d().x, top, edge.start_corner().point3d().z) * factor) - - st.add_vertex(Vector3(edge.start_corner().point3d().x, bottom, edge.start_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.end_corner().point3d().x, bottom, edge.end_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.end_corner().point3d().x, top, edge.end_corner().point3d().z) * factor) - - for corner_count in center.corners().size(): - var current_corner = center.corners()[corner_count] - var next_corner - if corner_count < center.corners().size() - 1: - next_corner = center.corners()[corner_count+1] - else: - next_corner = center.corners()[0] - - st.add_uv(Vector2(top_uv)) - st.add_vertex(Vector3(current_corner.point2d().x, center.get_elevation(), current_corner.point2d().y) * factor) - st.add_vertex(Vector3(next_corner.point2d().x, center.get_elevation(), next_corner.point2d().y) * factor) - st.add_vertex(Vector3(center.point2d().x, center.get_elevation(), center.point2d().y) * factor) - Global.loading.increment_step() - - st.generate_normals() - st.index() - - var mi = MeshInstance.new() - mi.mesh = st.commit() - var material = load("res://world/materials/world.material") - mi.set_surface_material(0, material) - mi.create_trimesh_collision() - mi.cast_shadow = GeometryInstance.SHADOW_CASTING_SETTING_ON - return mi - # Enregistrement de la map + intégration dans la génération du monde #32 # func create_map(): diff --git a/world.mesh b/world.mesh deleted file mode 100644 index 4cfcc1f..0000000 Binary files a/world.mesh and /dev/null differ diff --git a/world/World3d.gd b/world/World3d.gd index 5bfc11c..e7c5792 100644 --- a/world/World3d.gd +++ b/world/World3d.gd @@ -2,16 +2,26 @@ extends Spatial var rng = RandomNumberGenerator.new() var chunk_size = 32 -var chunk_amount = 4 +var chunk_amount = 16 var chunks = {} var unready_chunks = {} var thread func _ready(): - # var mi = Global.terrain.get_data("mesh") - # add_child(mi) - # add_trees() - thread = Thread.new() + add_world() + add_trees() + +func add_world(): + var terrain_mesh = TerrainMesh.new() + terrain_mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, Global.terrain.get_temp_data("mesh")) + terrain_mesh.surface_set_material(0, load("res://world/materials/world.material")) + + var mi := MeshInstance.new() + mi.mesh = terrain_mesh + mi.create_trimesh_collision() + + add_child(mi) + Global.terrain.reset_temp_data() func add_trees(): rng.randomize() @@ -24,77 +34,9 @@ func add_trees(): if num == 1: var points2d = poisson_disc_sampling.generate_points(3, center.polygon(), 2) for point in points2d: - # print(point) var tree = treescene.instance() var scaling = rng.randi_range(0.8, 1.2) tree.scale = Vector3(scaling, scaling, scaling) tree.rotate_y(rng.randi_range(0, 2*PI)) tree.translation = Vector3(point.x, center.get_elevation() * 120, point.y) add_child(tree) - - -func add_chunk(x, z): - var key = str(x) + "," + str(z) - if chunks.has(key) or unready_chunks.has(key): - return - - if not thread.is_active(): - thread.start(self, "load_chunk", [thread, x, z]) - unready_chunks[key] = 1 - -func load_chunk(array): - var thread = array[0] - var x = array[1] - var z = array[2] - - # print(x) - # print(z) - - var chunk = Chunk.new(x * chunk_size, z * chunk_size) - - # chunk.translation = Vector3(x * chunk_size, 0, z * chunk_size) - - call_deferred("load_done", chunk, thread) - -func load_done(chunk, thread): - add_child(chunk) - var key = str(chunk.x / chunk_size) + "," + str(chunk.z / chunk_size) - chunks[key] = chunk - unready_chunks.erase(key) - thread.wait_to_finish() - -func get_chunk(x, z): - var key = str(x) + "," + str(z) - if chunks.has(key): - return chunks.get(key) - - return null - -func _process(delta): - update_chunks() - clean_up_chunks() - reset_chunks() - -func update_chunks(): - var camera_translation = $CamBase/Camera.translation - # print(camera_translation) - var c_x = int(camera_translation.x) / chunk_size - var c_z = int(camera_translation.y) / chunk_size * -1 - - for x in range(c_x - chunk_amount * 0.5, c_x + chunk_amount * 0.53): - for z in range(c_z - chunk_amount * 0.5, c_z + chunk_amount * 0.53): - add_chunk(x, z) - var chunk = get_chunk(x, z) - if chunk != null: - chunk.should_remove = false - -func clean_up_chunks(): - for key in chunks: - var chunk = chunks[key] - if chunk.should_remove: - chunk.queue_free() - chunks.erase(key) - -func reset_chunks(): - for key in chunks: - chunks[key].should_remove = true diff --git a/world/chunk.gd b/world/chunk.gd deleted file mode 100644 index 955b0be..0000000 --- a/world/chunk.gd +++ /dev/null @@ -1,78 +0,0 @@ -extends Spatial -class_name Chunk - -var noise -var should_remove = true -var x -var z -var empty = true - -func _init(x, z): - self.x = x - self.z = z - -func _ready(): - generate_chunk() - pass -func generate_chunk(): - var file = File.new() - file.open("res://world/materials/materials.json", File.READ) - var materials = JSON.parse(file.get_as_text()).result - - var st = SurfaceTool.new() - - st.begin(Mesh.PRIMITIVE_TRIANGLES) - var factor = Vector3(1, 120, 1) - # print(x) - # print(z) - for center in Global.terrain.get_chunk(Vector2(x, z)): - # print(center.get_data("water")) - if not center.get_data("water"): - empty = false - # print(center.get_data("material")) - var material_id = materials[center.get_data("material")] - var top_uv = Vector2(0, float(material_id) / (materials.size()-1)) - var border_uv = Vector2(1, float(material_id) / (materials.size()-1)) - - for edge in center.borders(): - if edge.end_center().get_elevation() < edge.start_center().get_elevation(): - var top = edge.start_center().get_elevation() - # if edge.start_center().get_data("ocean"): - # top = -1.0 - var bottom = edge.end_center().get_elevation() - if edge.end_center().get_data("ocean"): - bottom = 0.0 - st.add_uv(border_uv) - st.add_vertex(Vector3(edge.start_corner().point3d().x, bottom, edge.start_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.end_corner().point3d().x, top, edge.end_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.start_corner().point3d().x, top, edge.start_corner().point3d().z) * factor) - - st.add_vertex(Vector3(edge.start_corner().point3d().x, bottom, edge.start_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.end_corner().point3d().x, bottom, edge.end_corner().point3d().z) * factor) - st.add_vertex(Vector3(edge.end_corner().point3d().x, top, edge.end_corner().point3d().z) * factor) - - for corner_count in center.corners().size(): - var current_corner = center.corners()[corner_count] - var next_corner - if corner_count < center.corners().size() - 1: - next_corner = center.corners()[corner_count+1] - else: - next_corner = center.corners()[0] - - st.add_uv(Vector2(top_uv)) - st.add_vertex(Vector3(current_corner.point2d().x, center.get_elevation(), current_corner.point2d().y) * factor) - st.add_vertex(Vector3(next_corner.point2d().x, center.get_elevation(), next_corner.point2d().y) * factor) - st.add_vertex(Vector3(center.point2d().x, center.get_elevation(), center.point2d().y) * factor) - Global.loading.increment_step() - - if not empty: - st.generate_normals() - st.index() - - var mi = MeshInstance.new() - mi.mesh = st.commit() - var material = load("res://world/materials/world.material") - mi.set_surface_material(0, material) - mi.create_trimesh_collision() - mi.cast_shadow = GeometryInstance.SHADOW_CASTING_SETTING_ON - add_child(mi) diff --git a/world/game.tscn b/world/game.tscn index b9f9c18..ead788d 100644 --- a/world/game.tscn +++ b/world/game.tscn @@ -173,8 +173,6 @@ material/0 = SubResource( 3 ) physics_interpolation_mode = 1 transform = Transform( 1, 0, 0, 0, 0.659983, -0.75128, 0, 0.75128, 0.659983, 0, -5.72205e-06, 6.618 ) fov = 55.0 -depth_threshold = 0.001 -depth_multiplier = 999.0 zoom_sensibility = 1.436 height = 5.0