diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index b3e9312..0000000 --- a/LICENSE.md +++ /dev/null @@ -1,22 +0,0 @@ - -The MIT License (MIT) - -Copyright (c) 2021 João Marinheiro - -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. diff --git a/utils/world_generation/WorldGeneration.gd b/utils/world_generation/WorldGeneration.gd index 1c410e1..f00364b 100644 --- a/utils/world_generation/WorldGeneration.gd +++ b/utils/world_generation/WorldGeneration.gd @@ -4,7 +4,7 @@ class_name WorldGeneration export(int) var width = 2048 export(int) var height = 2048 -export(int) var spacing = 5 +export(int) var spacing = 40 export(int, 1, 9) var octaves = 5 export(int, 1, 30) var wavelength = 8 export(int) var border_width = 200 @@ -71,6 +71,12 @@ func init_data(): center.set_data("coast", is_coast(center.to_point())) # if center.get_data("ocean"): # center.set_elevation(-1.0) + + center.set_data("material", "grass") + if center.get_data("mountain"): + center.set_data("material", "stone") + if center.get_data("coast"): + center.set_data("material", "sand") @@ -236,7 +242,7 @@ func find_elevation(point): elevation = min(elevation, 1) - elevation = round(elevation * terraces) / terraces + elevation = (elevation * terraces) / terraces return elevation @@ -274,20 +280,19 @@ 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(): if not center.get_data("water"): - var top_uv = Vector2(0, 0) - var border_uv = Vector2(1, 0) - if center.get_data("mountain"): - top_uv = Vector2(1, 0.5) - border_uv = Vector2(1, 0.5) - if center.get_data("coast"): - top_uv = Vector2(1, 1) - border_uv = Vector2(1, 1) + 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(): @@ -325,7 +330,7 @@ func create_mesh(): var mi = MeshInstance.new() mi.mesh = st.commit() - var material = load("res://world/world.material") + 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 diff --git a/world/materials/materials.json b/world/materials/materials.json new file mode 100644 index 0000000..fb6a7f9 --- /dev/null +++ b/world/materials/materials.json @@ -0,0 +1,5 @@ +{ + "grass": 0, + "stone": 1, + "sand": 2 +} diff --git a/world/world.material b/world/materials/world.material similarity index 100% rename from world/world.material rename to world/materials/world.material diff --git a/world/world.tres b/world/world.tres deleted file mode 100644 index e91e776..0000000 --- a/world/world.tres +++ /dev/null @@ -1,5 +0,0 @@ -[gd_resource type="SpatialMaterial" format=2] - -[resource] -params_diffuse_mode = 1 -albedo_color = Color( 0.125, 0.5, 0.275, 1 )