diff --git a/game/dev/shader_character_dev.tscn b/game/dev/shader_character_dev.tscn index 39d9b805..fa1f34fa 100644 --- a/game/dev/shader_character_dev.tscn +++ b/game/dev/shader_character_dev.tscn @@ -3,10 +3,11 @@ [ext_resource path="res://data/models/armature_model_orig_v2.tscn" type="PackedScene" id=1] [ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=2] [ext_resource path="res://prop_tool/dada.tres" type="PropData" id=3] -[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.gd" type="Script" id=4] +[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=4] [ext_resource path="res://dungeon_generator/MainDungeonGenerator.gd" type="Script" id=5] [ext_resource path="res://dev/character_dev_mat.tres" type="Material" id=6] + [sub_resource type="VoxelmanLevelGenerator" id=1] script = ExtResource( 5 ) prop = ExtResource( 3 ) diff --git a/game/project.godot b/game/project.godot index d60f5b30..c555d6b5 100644 --- a/game/project.godot +++ b/game/project.godot @@ -19,11 +19,6 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://player/CharacterSkeletonAttachPoint.gd" }, { -"base": "VoxelChunk", -"class": "CubicVoxelChunk", -"language": "GDScript", -"path": "res://voxelman/cubic_mesher/CubicVoxelChunk.gd" -}, { "base": "Entity", "class": "DisplayPlayerGD", "language": "GDScript", @@ -42,7 +37,7 @@ _global_script_classes=[ { "base": "VoxelMesherCubic", "class": "GDCubicVoxelMesher", "language": "GDScript", -"path": "res://voxelman/cubic_mesher/CubicVoxelMesher.gd" +"path": "res://voxelman/world/CubicVoxelMesher.gd" }, { "base": "ItemTemplate", "class": "ItemTemplateGD", @@ -132,17 +127,17 @@ _global_script_classes=[ { "base": "VoxelChunk", "class": "TVVoxelChunk", "language": "GDScript", -"path": "res://voxelman/transvoxel_mesher/TVVoxelChunk.gd" +"path": "res://voxelman/world/TVVoxelChunk.gd" }, { "base": "VoxelMesherTransvoxel", "class": "TVVoxelMesher", "language": "GDScript", -"path": "res://voxelman/transvoxel_mesher/TVVoxelMesher.gd" +"path": "res://voxelman/world/TVVoxelMesher.gd" }, { "base": "VoxelMesherTransvoxel", "class": "TestVoxelMesher", "language": "GDScript", -"path": "res://voxelman/transvoxel_mesher/TestVoxelMesher.gd" +"path": "res://voxelman/world/TestVoxelMesher.gd" }, { "base": "WorldSpell", "class": "WorldSpellGD", @@ -152,7 +147,6 @@ _global_script_classes=[ { _global_script_class_icons={ "AuraGD": "", "CharacterSkeketonAttachPoint": "", -"CubicVoxelChunk": "", "DisplayPlayerGD": "", "EntityAIGD": "", "EntityDataGD": "", diff --git a/game/scenes/Menu.tscn b/game/scenes/Menu.tscn index 694d9b38..fa456255 100644 --- a/game/scenes/Menu.tscn +++ b/game/scenes/Menu.tscn @@ -15,11 +15,12 @@ [ext_resource path="res://scenes/DisconnectButton.gd" type="Script" id=13] [ext_resource path="res://scenes/ConnectServerButton.gd" type="Script" id=14] [ext_resource path="res://scenes/HostGameButton.gd" type="Script" id=15] -[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.gd" type="Script" id=16] +[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=16] [ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=17] [ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=18] [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=19] + [sub_resource type="VoxelmanLevelGenerator" id=1] script = ExtResource( 18 ) _force_planet = -1 diff --git a/game/scenes/World.tscn b/game/scenes/World.tscn index 3219f6ff..54315c7a 100644 --- a/game/scenes/World.tscn +++ b/game/scenes/World.tscn @@ -3,7 +3,7 @@ [ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=1] [ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=2] [ext_resource path="res://scripts/settings/DirectionalLightSettings.gd" type="Script" id=3] -[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.gd" type="Script" id=8] +[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=8] [sub_resource type="VoxelmanLevelGenerator" id=1] script = ExtResource( 1 ) diff --git a/game/voxelman/cubic_mesher/CubicVoxelChunk.gd b/game/voxelman/cubic_mesher/CubicVoxelChunk.gd deleted file mode 100644 index f7c14ae3..00000000 --- a/game/voxelman/cubic_mesher/CubicVoxelChunk.gd +++ /dev/null @@ -1,63 +0,0 @@ -extends VoxelChunk -class_name CubicVoxelChunk - -# Copyright Péter Magyar relintai@gmail.com -# MIT License, might be merged into the Voxelman engine module - -# Copyright (c) 2019-2020 Péter Magyar - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -var lod_data : Array = [ - 1, #CHUNK_INDEX_UP - 1, #CHUNK_INDEX_DOWN - 1, #CHUNK_INDEX_LEFT - 1, #CHUNK_INDEX_RIGHT - 1, #CHUNK_INDEX_FRONT - 1 #CHUNK_INDEX_BACK -] - -func _create_meshers(): -# mesher = VoxelMesherCubic.new() - add_mesher(GDCubicVoxelMesher.new()) -# mesher.base_light_value = 0.45 -# mesher.ao_strength = 0.05 -# mesher.ao_strength = 0.2 - -func a_build_phase(phase): - if phase == VoxelChunk.BUILD_PHASE_LIGHTS: -# clear_baked_lights() -# generate_random_ao() -# -## var vl : VoxelLight = VoxelLight.new() -# -# bake_lights() -# -# set_physics_process_internal(true) -# ._build_phase(phase) - pass - elif phase == VoxelChunk.BUILD_PHASE_PROP_MESH: -# set_physics_process_internal(true) - ._build_phase(phase) - elif phase == VoxelChunk.BUILD_PHASE_FINALIZE: - ._build_phase(phase) - - notification(NOTIFICATION_TRANSFORM_CHANGED) - else: - ._build_phase(phase) diff --git a/game/voxelman/cubic_mesher/CubicVoxelWorld.gd b/game/voxelman/cubic_mesher/CubicVoxelWorld.gd deleted file mode 100644 index f33ffa46..00000000 --- a/game/voxelman/cubic_mesher/CubicVoxelWorld.gd +++ /dev/null @@ -1,172 +0,0 @@ -extends VoxelWorld - -# Copyright Péter Magyar relintai@gmail.com -# MIT License, might be merged into the Voxelman engine module - -# Copyright (c) 2019-2020 Péter Magyar - -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -enum GenType { - TEST, NORMAL -} - -export(int) var gen_type : int = GenType.NORMAL - -export(Array, MeshDataResource) var meshes : Array - -var chunks : Dictionary = Dictionary() -var spawned : bool = false - -var generation_queue : Array - -func _ready() -> void: - if level_generator != null: - level_generator.setup(self, 80, false, library) - - spawn() - set_process(true) - -#func _process(delta : float) -> void: -# if not generation_queue.empty(): -# var chunk : VoxelChunk = generation_queue.front() -# -# if gen_type == GenType.NORMAL: -## generate(chunk) -# pass -# else: -# generate_terrarin(chunk) -# -# generation_queue.remove(0) -# -# if generation_queue.empty(): -# emit_signal("generation_finished") - -func generate_terrarin(chunk : VoxelChunk) -> void: - var buffer : VoxelChunk = chunk.get_buffer() - buffer.create(int(chunk_size_x) + 3, int(chunk_size_y) + 3, int(chunk_size_z) + 3) - - var noise : OpenSimplexNoise = OpenSimplexNoise.new() - noise.seed = 10 - noise.octaves = 4 - noise.period = 200.0 - noise.persistence = 0.8 - - var terr_noise : OpenSimplexNoise = OpenSimplexNoise.new() - terr_noise.seed = 10 * 321 + 112 - terr_noise.octaves = 4 - terr_noise.period = 20.0 - terr_noise.persistence = 0.9 - - for x in range(-1, chunk_size_x + 2): - for z in range(-1, chunk_size_z + 2): - var val : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z)) - val *= val - val *= 100 - val += 2 - - var tv : float = terr_noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z)) - val += tv * 2 - - var v : int = (int(val)) - - for y in range(-1, v): - seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y) - buffer.set_voxel(1, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE) - buffer.set_voxel(randi() % 200 + 55, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL) - - seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y + 1) - buffer.set_voxel(1, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_TYPE) - buffer.set_voxel(randi() % 200 + 55, x + 1, y + 2, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL) - - for i in range(5): - var light : VoxelLight = VoxelLight.new() - randomize() - light.color = Color(randf(), randf(), randf()) - light.size = randi() % 5 + 5 - light.set_world_position((chunk.position_x * chunk.size_x) + (randi() % chunk.size_x), (chunk.position_y * chunk.size_y) + (randi() % 6), (chunk.position_z * chunk.size_z) + (randi() % chunk.size_z)) - chunk.add_voxel_light(light) - - -# var light : VoxelLight = VoxelLight.new() -# light.color = Color(1.0, 0, 0) -# light.size = 10 -# light.set_world_position((chunk.position_x * chunk.size_x) + (2), (chunk.position_y * chunk.size_y) + (7), (chunk.position_z * chunk.size_z) + (1)) -# chunk.add_voxel_light(light) - -# for x in range(16): -# for z in range(16): - -# chunk.add_prop(Transform(Basis().scaled(Vector3(0.2, 0.2, 0.2)), Vector3(2, 5, 0) * voxel_scale), meshes[0]) - -# chunk.add_prop(Transform(Basis(), Vector3(4, 3, 5) * voxel_scale), meshes[0]) - - chunk.bake_lights() - - chunk.build() -# chunk.draw_debug_voxels(2000) - chunk.draw_debug_voxel_lights() - - -#func spawn_chunk(x : int, y : int, z : int, lod_size : int = 1) -> void: -# var name : String = "Chunk," + str(x) + "," + str(y) + "," + str(z) -# var chunk : VoxelChunk = VoxelChunk.new() -## var chunk : VoxelChunk = MarchingCubesVoxelChunk.new() -# -# chunk.voxel_world = self -# chunk.set_chunk_position(x, y, z) -# chunk.library = library -# chunk.voxel_scale = voxel_scale -# chunk.lod_size = lod_size -# chunk.set_chunk_size(int(chunk_size_x), int(chunk_size_y), int(chunk_size_z)) -# -# chunk.create_mesher() -# chunk.mesher.base_light_value = 0.6 -# -# chunks[name] = chunk -# -# generation_queue.append(chunk) - -func _create_chunk(x : int, y : int, z : int, pchunk : Node) -> VoxelChunk: - var chunk : VoxelChunk = CubicVoxelChunk.new() - - #chunk.lod_size = 1 - - return ._create_chunk(x, y, z, chunk) - -func spawn() -> void: - var hsize : int = 5 - -# if gen_type == GenType.NORMAL: - for x in range(-hsize, hsize): - for z in range(-hsize, hsize): - for y in range(-4, 2): -# spawn_chunk(x, y, z, abs(int(ceil(x / 2))) + 1) -# spawn_chunk(x, y, z, 1) - create_chunk(x, y, z) - -#func set_player(p_player : Spatial) -> void: -# player = p_player - -# if _spawned: -# clear() -# -# spawn() -# pass - diff --git a/game/voxelman/cubic_mesher/CubicVoxelWorld.tscn b/game/voxelman/cubic_mesher/CubicVoxelWorld.tscn deleted file mode 100644 index f5e11551..00000000 --- a/game/voxelman/cubic_mesher/CubicVoxelWorld.tscn +++ /dev/null @@ -1,25 +0,0 @@ -[gd_scene load_steps=5 format=2] - -[ext_resource path="res://voxelman/cubic_mesher/CubicVoxelWorld.gd" type="Script" id=1] -[ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=2] -[ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=3] - -[sub_resource type="VoxelmanLevelGenerator" id=1] -script = ExtResource( 3 ) -_force_planet = -1 -_level_seed = 0 -_spawn_mobs = false - -[node name="VoxelWorld" type="VoxelWorld"] -use_threads = false -max_concurrent_generations = 1 -library = ExtResource( 2 ) -level_generator = SubResource( 1 ) -voxel_scale = 4.0 -script = ExtResource( 1 ) - -[node name="Camera" type="Camera" parent="."] -current = true - -[node name="DirectionalLight" type="DirectionalLight" parent="."] -transform = Transform( 0.751552, -0.185778, 0.632974, 0.622874, -0.116152, -0.773651, 0.217249, 0.975702, 0.028422, 0, 27.1286, 0 ) diff --git a/game/voxelman/cubic_mesher/CubicVoxelMesher.gd b/game/voxelman/world/CubicVoxelMesher.gd similarity index 100% rename from game/voxelman/cubic_mesher/CubicVoxelMesher.gd rename to game/voxelman/world/CubicVoxelMesher.gd diff --git a/game/voxelman/transvoxel_mesher/TVTestScene.tscn b/game/voxelman/world/TVTestScene.tscn similarity index 98% rename from game/voxelman/transvoxel_mesher/TVTestScene.tscn rename to game/voxelman/world/TVTestScene.tscn index 0db5ca57..8c154a32 100644 --- a/game/voxelman/transvoxel_mesher/TVTestScene.tscn +++ b/game/voxelman/world/TVTestScene.tscn @@ -1,12 +1,13 @@ [gd_scene load_steps=18 format=2] -[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.tscn" type="PackedScene" id=1] +[ext_resource path="res://voxelman/world/TVVoxelWorld.tscn" type="PackedScene" id=1] [ext_resource path="res://data/materials/voxelman.tres" type="Material" id=2] [ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3] [ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=4] [ext_resource path="res://data/voxel_textures/grass_albedo.png" type="Texture" id=5] [ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=6] + [sub_resource type="Environment" id=1] ambient_light_color = Color( 1, 1, 1, 1 ) diff --git a/game/voxelman/transvoxel_mesher/TVVoxelChunk.gd b/game/voxelman/world/TVVoxelChunk.gd similarity index 100% rename from game/voxelman/transvoxel_mesher/TVVoxelChunk.gd rename to game/voxelman/world/TVVoxelChunk.gd diff --git a/game/voxelman/transvoxel_mesher/TVVoxelMesher.gd b/game/voxelman/world/TVVoxelMesher.gd similarity index 100% rename from game/voxelman/transvoxel_mesher/TVVoxelMesher.gd rename to game/voxelman/world/TVVoxelMesher.gd diff --git a/game/voxelman/transvoxel_mesher/TVVoxelWorld.gd b/game/voxelman/world/TVVoxelWorld.gd similarity index 100% rename from game/voxelman/transvoxel_mesher/TVVoxelWorld.gd rename to game/voxelman/world/TVVoxelWorld.gd diff --git a/game/voxelman/transvoxel_mesher/TVVoxelWorld.tscn b/game/voxelman/world/TVVoxelWorld.tscn similarity index 76% rename from game/voxelman/transvoxel_mesher/TVVoxelWorld.tscn rename to game/voxelman/world/TVVoxelWorld.tscn index 47e583ef..a997f863 100644 --- a/game/voxelman/transvoxel_mesher/TVVoxelWorld.tscn +++ b/game/voxelman/world/TVVoxelWorld.tscn @@ -1,7 +1,8 @@ [gd_scene load_steps=3 format=2] [ext_resource path="res://data/voxel_libraries/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=1] -[ext_resource path="res://voxelman/transvoxel_mesher/TVVoxelWorld.gd" type="Script" id=2] +[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=2] + [node name="World" type="VoxelWorld"] library = ExtResource( 1 ) diff --git a/game/voxelman/transvoxel_mesher/TestVoxelMesher.gd b/game/voxelman/world/TestVoxelMesher.gd similarity index 100% rename from game/voxelman/transvoxel_mesher/TestVoxelMesher.gd rename to game/voxelman/world/TestVoxelMesher.gd