mirror of
https://github.com/Relintai/world_generator_addon.git
synced 2024-11-19 20:47:19 +01:00
Added more helper scripts from broken seals, also some initial test project setup.
This commit is contained in:
parent
30bf5b92d6
commit
1db082408f
@ -24,6 +24,11 @@ _global_script_classes=[ {
|
||||
"language": @"GDScript",
|
||||
"path": "res://addons/world_generator/resources/sub_zone_prop.gd"
|
||||
}, {
|
||||
"base": "TerrainLevelGenerator",
|
||||
"class": @"TerrainWorldGenerator",
|
||||
"language": @"GDScript",
|
||||
"path": "res://scripts/world_generators/TerrainWorldGenerator.gd"
|
||||
}, {
|
||||
"base": "Resource",
|
||||
"class": @"WorldGenBaseResource",
|
||||
"language": @"GDScript",
|
||||
@ -57,14 +62,20 @@ _global_script_class_icons={
|
||||
@"WorldGeneratorSettings": "",
|
||||
@"WorldGenBaseResource": "",
|
||||
@"WorldGenWorld": "",
|
||||
@"Zone": ""
|
||||
@"Zone": "",
|
||||
@"TerrainWorldGenerator": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/name="World Generator"
|
||||
run/main_scene="res://terraman/Terraman.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PoolStringArray( "res://addons/world_generator/plugin.cfg" )
|
||||
|
||||
[physics]
|
||||
|
||||
common/enable_pause_aware_picking=true
|
||||
|
158
scripts/world_generator/continents/test_continent.gd
Normal file
158
scripts/world_generator/continents/test_continent.gd
Normal file
@ -0,0 +1,158 @@
|
||||
tool
|
||||
extends Continent
|
||||
|
||||
export(float) var continent_radius : float = 0.5
|
||||
export(float) var continent_bevel : float = 0.3
|
||||
export(float) var continent_base : float = 0
|
||||
|
||||
var voxel_scale : float = 1
|
||||
var current_seed : int = 0
|
||||
|
||||
func _eitor_draw_additional(control : Control) -> void:
|
||||
gui_draw_continent_radius(control, Color(0.6, 0.6, 0.6, 1))
|
||||
gui_draw_continent_bevel(control, Color(1, 1, 1, 1))
|
||||
|
||||
func _eitor_draw_additional_background(control : Control) -> void:
|
||||
gui_draw_continent_radius(control, Color(0.3, 0.3, 0.3, 1))
|
||||
gui_draw_continent_bevel(control, Color(0.6, 0.6, 0.6, 1))
|
||||
|
||||
func gui_draw_continent_radius(control : Control, color : Color) -> void:
|
||||
var s : Vector2 = control.get_size()
|
||||
|
||||
var points : PoolVector2Array
|
||||
var ofsx : float = (1 - (continent_radius * 2)) * s.x / 2.0
|
||||
var ofsy : float = (1 - (continent_radius * 2)) * s.y / 2.0
|
||||
|
||||
for i in range(16):
|
||||
var ifl : float = float(i)
|
||||
var n : float = ifl / 16.0 * 2 * PI
|
||||
var n1 : float = (ifl + 1.0) / 16.0 * 2 * PI
|
||||
|
||||
points.push_back(Vector2((sin(n) + 1.0) * 0.5 * continent_radius * 2 * s.x + ofsx, (cos(n) + 1.0) * 0.5 * continent_radius * 2 * s.y + ofsy))
|
||||
points.push_back(Vector2((sin(n1) + 1.0) * 0.5 * continent_radius * 2 * s.x + ofsx, (cos(n1) + 1.0) * 0.5 * continent_radius * 2 * s.y + ofsy))
|
||||
|
||||
control.draw_polyline(points, color, 1)
|
||||
|
||||
func gui_draw_continent_bevel(control : Control, color : Color) -> void:
|
||||
var s : Vector2 = control.get_size()
|
||||
|
||||
var points : PoolVector2Array
|
||||
var bevel_radius : float = (min(continent_radius, continent_bevel) / continent_radius) / 2.0
|
||||
var ofsx : float = (1 - (bevel_radius * 2)) * s.x / 2.0
|
||||
var ofsy : float = (1 - (bevel_radius * 2)) * s.y / 2.0
|
||||
|
||||
for i in range(16):
|
||||
var ifl : float = float(i)
|
||||
var n : float = ifl / 16.0 * 2 * PI
|
||||
var n1 : float = (ifl + 1.0) / 16.0 * 2 * PI
|
||||
|
||||
points.push_back(Vector2((sin(n) + 1.0) * 0.5 * bevel_radius * 2 * s.x + ofsx, (cos(n) + 1.0) * 0.5 * bevel_radius * 2 * s.y + ofsy))
|
||||
points.push_back(Vector2((sin(n1) + 1.0) * 0.5 * bevel_radius * 2 * s.x + ofsx, (cos(n1) + 1.0) * 0.5 * bevel_radius * 2 * s.y + ofsy))
|
||||
|
||||
control.draw_polyline(points, color, 1)
|
||||
|
||||
func get_continent_radius() -> float:
|
||||
return continent_radius
|
||||
|
||||
func set_continent_radius(ed : float) -> void:
|
||||
continent_radius = ed
|
||||
emit_changed()
|
||||
|
||||
func get_continent_bevel() -> float:
|
||||
return continent_bevel
|
||||
|
||||
func set_continent_bevel(ed : float) -> void:
|
||||
continent_bevel = ed
|
||||
emit_changed()
|
||||
|
||||
func get_continent_base() -> float:
|
||||
return continent_base
|
||||
|
||||
func set_continent_base(ed : float) -> void:
|
||||
continent_base = ed
|
||||
emit_changed()
|
||||
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "TestContinent"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
||||
|
||||
func _setup_terra_library(library : TerrainLibrary, pseed : int) -> void:
|
||||
pass
|
||||
|
||||
static func circle(uv : Vector2, c : Vector2, r : float) -> float:
|
||||
c.x += 0.5
|
||||
c.y += 0.5
|
||||
|
||||
return (uv - c).length() - r;
|
||||
|
||||
func get_value_for(uv : Vector2) -> float:
|
||||
var f : float = circle(uv, Vector2(), continent_radius)
|
||||
|
||||
var cf : float = clamp(continent_base - f / max(continent_bevel, 0.00001), 0.0, 1.0)
|
||||
|
||||
return cf
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
||||
|
||||
var s : FastNoise = FastNoise.new()
|
||||
s.set_noise_type(FastNoise.TYPE_SIMPLEX)
|
||||
s.set_seed(current_seed)
|
||||
|
||||
var sdet : FastNoise = FastNoise.new()
|
||||
sdet.set_noise_type(FastNoise.TYPE_SIMPLEX)
|
||||
sdet.set_seed(current_seed)
|
||||
|
||||
var luv : Vector2 = raycast.get_local_uv()
|
||||
|
||||
var lhit_world_pos : Vector2 = raycast.get_local_position()
|
||||
lhit_world_pos.x *= chunk.size_x
|
||||
lhit_world_pos.y *= chunk.size_z
|
||||
|
||||
var world_rect_size : Vector2 = get_rect().size
|
||||
world_rect_size.x *= chunk.size_x
|
||||
world_rect_size.y *= chunk.size_z
|
||||
|
||||
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
for z in range(-chunk.margin_start, chunk.size_z + chunk.margin_end):
|
||||
var vx : int = x + (chunk.position_x * chunk.size_x)
|
||||
var vz : int = z + (chunk.position_z * chunk.size_z)
|
||||
|
||||
var lwp : Vector2 = lhit_world_pos + Vector2(x, z)
|
||||
var local_uv : Vector2 = lwp / world_rect_size
|
||||
var interp : float = get_value_for(local_uv)
|
||||
|
||||
var val : float = (s.get_noise_2d(vx * 0.2, vz * 0.2))
|
||||
val *= val
|
||||
val += abs(sdet.get_noise_2d(vx * 0.3, vz * 0.3)) * 10
|
||||
val += 110
|
||||
|
||||
var oil : int = chunk.get_voxel(x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
oil += float(val) * interp
|
||||
|
||||
chunk.set_voxel(oil, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_float("get_continent_radius", "set_continent_radius", "Continent Radius", 0.01)
|
||||
inspector.add_slot_float("get_continent_bevel", "set_continent_bevel", "Continent Bevel", 0.01)
|
||||
inspector.add_slot_float("get_continent_base", "set_continent_base", "Continent Base", 0.01)
|
92
scripts/world_generator/subzoneprops/dungeon_spawner.gd
Normal file
92
scripts/world_generator/subzoneprops/dungeon_spawner.gd
Normal file
@ -0,0 +1,92 @@
|
||||
tool
|
||||
extends SubZoneProp
|
||||
|
||||
export(PackedScene) var dungeon_teleporter : PackedScene
|
||||
|
||||
var voxel_scale : float = 1
|
||||
var current_seed : int = 0
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
voxel_scale = chunk.voxel_scale
|
||||
current_seed = pseed
|
||||
|
||||
var cx : int = chunk.get_position_x()
|
||||
var cz : int = chunk.get_position_z()
|
||||
|
||||
var chunk_seed : int = 123 + (cx * 231) + (cz * 123)
|
||||
|
||||
var rng : RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = chunk_seed
|
||||
|
||||
var p : Vector2i = Vector2i(get_rect().size.x / 2, get_rect().size.y / 2)
|
||||
var lp : Vector2i = raycast.get_local_position()
|
||||
|
||||
if p == lp:
|
||||
spawn_dungeon(chunk, chunk_seed, spawn_mobs)
|
||||
|
||||
func spawn_dungeon(chunk: TerrainChunk, dungeon_seed : int, spawn_mobs : bool) -> void:
|
||||
var world_space_data_coordinates_x : int = chunk.position_x * chunk.size_x
|
||||
var world_space_data_coordinates_z : int = chunk.position_z * chunk.size_z
|
||||
|
||||
var vpx : int = 6
|
||||
var vpz : int = 6
|
||||
|
||||
var x : float = (world_space_data_coordinates_x + vpx) * chunk.voxel_scale
|
||||
var z : float = (world_space_data_coordinates_z + vpz) * chunk.voxel_scale
|
||||
|
||||
var vh : int = chunk.get_voxel(vpx, vpz, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
var orx : int = (randi() % 3) + 2
|
||||
var orz : int = (randi() % 3) + 2
|
||||
|
||||
for wx in range(vpx - orx, vpx + orx + 1):
|
||||
for wz in range(vpz - orz, vpz + orz + 1):
|
||||
chunk.set_voxel(vh, wx, wz, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
var vwh : float = chunk.get_voxel_scale() * chunk.get_world_height() * (vh / 255.0)
|
||||
|
||||
var dt : Spatial = dungeon_teleporter.instance()
|
||||
chunk.voxel_world.add_child(dt)
|
||||
dt.owner_chunk = chunk
|
||||
|
||||
var level : int = 2
|
||||
|
||||
if chunk.get_voxel_world().has_method("get_mob_level"):
|
||||
level = chunk.get_voxel_world().get_mob_level()
|
||||
|
||||
dt.min_level = level - 1
|
||||
dt.max_level = level + 1
|
||||
dt.dungeon_seed = dungeon_seed
|
||||
dt.spawn_mobs = spawn_mobs
|
||||
dt.transform = Transform(Basis().scaled(Vector3(chunk.voxel_scale, chunk.voxel_scale, chunk.voxel_scale)), Vector3(x, vwh, z))
|
||||
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "DungeonSpawner"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
||||
|
||||
func get_dungeon_teleporter() -> PackedScene:
|
||||
return dungeon_teleporter
|
||||
|
||||
func set_dungeon_teleporter(ed : PackedScene) -> void:
|
||||
dungeon_teleporter = ed
|
||||
emit_changed()
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_resource("get_dungeon_teleporter", "set_dungeon_teleporter", "Dungeon Teleporter", "PackedScene")
|
67
scripts/world_generator/subzoneprops/mob_spawner.gd
Normal file
67
scripts/world_generator/subzoneprops/mob_spawner.gd
Normal file
@ -0,0 +1,67 @@
|
||||
tool
|
||||
extends SubZoneProp
|
||||
|
||||
export (EntityData) var mob : EntityData
|
||||
export (int) var level : int = 1
|
||||
#density
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
if !mob:
|
||||
return
|
||||
|
||||
var cx : int = chunk.get_position_x()
|
||||
var cz : int = chunk.get_position_z()
|
||||
|
||||
var chunk_seed : int = 123 + (cx * 231) + (cz * 123)
|
||||
|
||||
var rng : RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = chunk_seed
|
||||
|
||||
if not Engine.editor_hint and spawn_mobs and rng.randi() % 4 == 0:
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
||||
var oil : int = chunk.get_voxel(chunk.size_x / 2, chunk.size_z / 2, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
ESS.entity_spawner.spawn_mob(mob.id, level, \
|
||||
Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
|
||||
((oil - 2) / 255.0) * chunk.world_height, \
|
||||
chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2))
|
||||
|
||||
func get_mob() -> EntityData:
|
||||
return mob
|
||||
|
||||
func set_mob(ed : EntityData) -> void:
|
||||
mob = ed
|
||||
emit_changed()
|
||||
|
||||
func get_level() -> int:
|
||||
return level
|
||||
|
||||
func set_level(val : int) -> void:
|
||||
level = val
|
||||
emit_changed()
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "MobSpawner"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_resource("get_mob", "set_mob", "Mob", "EntityData")
|
||||
inspector.add_slot_int("get_level", "set_level", "level")
|
||||
|
66
scripts/world_generator/subzoneprops/spawner.gd
Normal file
66
scripts/world_generator/subzoneprops/spawner.gd
Normal file
@ -0,0 +1,66 @@
|
||||
tool
|
||||
extends SubZoneProp
|
||||
|
||||
export (EntityData) var trainer : EntityData
|
||||
export (EntityData) var vendor : EntityData
|
||||
|
||||
func _is_spawner() -> bool:
|
||||
return true
|
||||
|
||||
func _get_spawn_local_position() -> Vector2:
|
||||
return Vector2(get_rect().size.x / 2, get_rect().size.y / 2)
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
if !spawn_mobs:
|
||||
return
|
||||
|
||||
if trainer == null || vendor == null:
|
||||
return
|
||||
|
||||
var p : Vector2i = Vector2i(get_rect().size.x / 2, get_rect().size.y / 2)
|
||||
var lp : Vector2i = raycast.get_local_position()
|
||||
|
||||
if p == lp:
|
||||
var pos : Vector3 = Vector3(chunk.get_position_x() * chunk.get_size_x() * chunk.voxel_scale + 4, 50 * chunk.voxel_scale, chunk.get_position_z() * chunk.get_size_z() * chunk.voxel_scale + 4)
|
||||
ESS.entity_spawner.spawn_mob(trainer.id, 1, pos)
|
||||
pos = Vector3(chunk.get_position_x() * chunk.get_size_x() * chunk.voxel_scale + 2, 50 * chunk.voxel_scale, chunk.get_position_z() * chunk.get_size_z() * chunk.voxel_scale + 2)
|
||||
ESS.entity_spawner.spawn_mob(vendor.id, 1, pos)
|
||||
|
||||
func get_trainer() -> EntityData:
|
||||
return trainer
|
||||
|
||||
func set_trainer(ed : EntityData) -> void:
|
||||
trainer = ed
|
||||
emit_changed()
|
||||
|
||||
func get_vendor() -> EntityData:
|
||||
return vendor
|
||||
|
||||
func set_vendor(ed : EntityData) -> void:
|
||||
vendor = ed
|
||||
emit_changed()
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "Spawner"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_resource("get_trainer", "set_trainer", "Trainer", "EntityData")
|
||||
inspector.add_slot_resource("get_vendor", "set_vendor", "Vendor", "EntityData")
|
20
scripts/world_generator/subzoneprops/test_subzone_prop.gd
Normal file
20
scripts/world_generator/subzoneprops/test_subzone_prop.gd
Normal file
@ -0,0 +1,20 @@
|
||||
tool
|
||||
extends SubZoneProp
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "TestSubZoneProp"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
73
scripts/world_generator/subzones/forest.gd
Normal file
73
scripts/world_generator/subzones/forest.gd
Normal file
@ -0,0 +1,73 @@
|
||||
tool
|
||||
extends SubZone
|
||||
|
||||
export(PropData) var prop_tree : PropData
|
||||
export(PropData) var prop_tree2 : PropData
|
||||
|
||||
func get_prop_tree() -> PropData:
|
||||
return prop_tree
|
||||
|
||||
func set_prop_tree(ed : PropData) -> void:
|
||||
prop_tree = ed
|
||||
emit_changed()
|
||||
|
||||
func get_prop_tree2() -> PropData:
|
||||
return prop_tree2
|
||||
|
||||
func set_prop_tree2(ed : PropData) -> void:
|
||||
prop_tree2 = ed
|
||||
emit_changed()
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "Forest"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
|
||||
var cx : int = chunk.get_position_x()
|
||||
var cz : int = chunk.get_position_z()
|
||||
|
||||
var chunk_seed : int = 123 + (cx * 231) + (cz * 123)
|
||||
|
||||
var rng : RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = chunk_seed
|
||||
|
||||
#chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
||||
|
||||
# TODO refactor this, it's inefficient
|
||||
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
for z in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
if rng.randf() > 0.992:
|
||||
var oil : int = chunk.get_voxel(x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
var tr : Transform = Transform()
|
||||
|
||||
tr = tr.rotated(Vector3(0, 1, 0), rng.randf() * PI)
|
||||
tr = tr.rotated(Vector3(1, 0, 0), rng.randf() * 0.2 - 0.1)
|
||||
tr = tr.rotated(Vector3(0, 0, 1), rng.randf() * 0.2 - 0.1)
|
||||
tr = tr.scaled(Vector3(0.9 + rng.randf() * 0.2, 0.9 + rng.randf() * 0.2, 0.9 + rng.randf() * 0.2))
|
||||
tr.origin = Vector3((x + chunk.position_x * chunk.size_x), ((oil - 2) / 255.0) * chunk.world_height, (z + chunk.position_z * chunk.size_z))
|
||||
|
||||
chunk.voxel_world.prop_add(tr, prop_tree)
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_resource("get_prop_tree", "set_prop_tree", "Prop Tree", "PropData")
|
||||
inspector.add_slot_resource("get_prop_tree2", "set_prop_tree2", "Prop Tree2", "PropData")
|
20
scripts/world_generator/subzones/test_subzone.gd
Normal file
20
scripts/world_generator/subzones/test_subzone.gd
Normal file
@ -0,0 +1,20 @@
|
||||
tool
|
||||
extends SubZone
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "TestSubZone"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
96
scripts/world_generator/worlds/ocean_base_world.gd
Normal file
96
scripts/world_generator/worlds/ocean_base_world.gd
Normal file
@ -0,0 +1,96 @@
|
||||
tool
|
||||
extends "res://addons/world_generator/resources/world_gen_world.gd"
|
||||
|
||||
export(int) var normal_surface_id : int = 2
|
||||
export(int) var base_iso_level : int = 0
|
||||
export(int) var water_iso_level : int = 100
|
||||
export(int) var water_surface_id : int = 5
|
||||
export(FastnoiseNoiseParams) var base_noise : FastnoiseNoiseParams = null
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_slot_int("get_normal_surface_id", "set_normal_surface_id", "Normal Surface ID")
|
||||
inspector.add_slot_int("get_base_iso_level", "set_base_iso_level", "Base Isolevel")
|
||||
inspector.add_slot_int("get_water_iso_level", "set_water_iso_level", "Water Isolevel")
|
||||
inspector.add_slot_int("get_water_surface_id", "set_water_surface_id", "Water Surface ID")
|
||||
|
||||
inspector.add_slot_resource("get_base_noise_params", "set_base_noise_params", "Base Noise Params", "FastnoiseNoiseParams")
|
||||
|
||||
|
||||
func generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
var p : Vector2 = Vector2(chunk.get_position_x(), chunk.get_position_z())
|
||||
var raycast : WorldGenRaycast = get_hit_stack(p)
|
||||
|
||||
_generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
|
||||
|
||||
while raycast.next():
|
||||
raycast.get_resource()._generate_terra_chunk(chunk, pseed, spawn_mobs, raycast)
|
||||
|
||||
_generate_terra_chunk_ocean(chunk, pseed, spawn_mobs)
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
_generate_terra_chunk_fallback(chunk, pseed, spawn_mobs)
|
||||
|
||||
func _generate_terra_chunk_fallback(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, normal_surface_id)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, base_iso_level)
|
||||
#chunk.set_voxel(1, 0, 0, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
func _generate_terra_chunk_ocean(chunk: TerrainChunk, pseed : int, spawn_mobs: bool) -> void:
|
||||
if !chunk.channel_is_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE):
|
||||
return
|
||||
|
||||
if !chunk.channel_is_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL):
|
||||
return
|
||||
|
||||
var ensured_channels : bool = false
|
||||
|
||||
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
for z in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
var iso_level : int = chunk.get_voxel(x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
if iso_level < water_iso_level:
|
||||
if !ensured_channels:
|
||||
ensured_channels = true
|
||||
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_TYPE, 0)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_ISOLEVEL, water_iso_level)
|
||||
|
||||
chunk.set_voxel(water_surface_id, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_TYPE)
|
||||
chunk.set_voxel(water_iso_level, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_LIQUID_ISOLEVEL)
|
||||
|
||||
func get_normal_surface_id() -> int:
|
||||
return normal_surface_id
|
||||
|
||||
func set_normal_surface_id(ed : int) -> void:
|
||||
normal_surface_id = ed
|
||||
emit_changed()
|
||||
|
||||
func get_base_iso_level() -> int:
|
||||
return base_iso_level
|
||||
|
||||
func set_base_iso_level(ed : int) -> void:
|
||||
base_iso_level = ed
|
||||
emit_changed()
|
||||
|
||||
func get_water_iso_level() -> int:
|
||||
return water_iso_level
|
||||
|
||||
func set_water_iso_level(ed : int) -> void:
|
||||
water_iso_level = ed
|
||||
emit_changed()
|
||||
|
||||
func get_water_surface_id() -> int:
|
||||
return water_surface_id
|
||||
|
||||
func set_water_surface_id(ed : int) -> void:
|
||||
water_surface_id = ed
|
||||
emit_changed()
|
||||
|
||||
func get_base_noise_params() -> FastnoiseNoiseParams:
|
||||
return base_noise
|
||||
|
||||
func set_base_noise_params(ed : FastnoiseNoiseParams) -> void:
|
||||
base_noise = ed
|
||||
emit_changed()
|
129
scripts/world_generator/zones/test_zone.gd
Normal file
129
scripts/world_generator/zones/test_zone.gd
Normal file
@ -0,0 +1,129 @@
|
||||
tool
|
||||
extends Zone
|
||||
|
||||
export(float) var zone_radius : float = 0.5
|
||||
export(float) var zone_bevel : float = 0.3
|
||||
export(float) var zone_base : float = 0
|
||||
|
||||
var voxel_scale : float = 1
|
||||
var current_seed : int = 0
|
||||
|
||||
func get_zone_radius() -> float:
|
||||
return zone_radius
|
||||
|
||||
func set_zone_radius(ed : float) -> void:
|
||||
zone_radius = ed
|
||||
emit_changed()
|
||||
|
||||
func get_zone_bevel() -> float:
|
||||
return zone_bevel
|
||||
|
||||
func set_zone_bevel(ed : float) -> void:
|
||||
zone_bevel = ed
|
||||
emit_changed()
|
||||
|
||||
func get_zone_base() -> float:
|
||||
return zone_base
|
||||
|
||||
func set_zone_base(ed : float) -> void:
|
||||
zone_base = ed
|
||||
emit_changed()
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return "TestZone"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return ""
|
||||
|
||||
static func circle(uv : Vector2, c : Vector2, r : float) -> float:
|
||||
c.x += 0.5
|
||||
c.y += 0.5
|
||||
|
||||
return (uv - c).length() - r;
|
||||
|
||||
func get_value_for(uv : Vector2) -> float:
|
||||
var f : float = circle(uv, Vector2(), zone_radius)
|
||||
|
||||
var cf : float = clamp(zone_base - f / max(zone_bevel, 0.00001), 0.0, 1.0)
|
||||
|
||||
return cf
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
voxel_scale = chunk.voxel_scale
|
||||
current_seed = pseed
|
||||
|
||||
var cx : int = chunk.get_position_x()
|
||||
var cz : int = chunk.get_position_z()
|
||||
|
||||
var chunk_seed : int = 123 + (cx * 231) + (cz * 123)
|
||||
|
||||
var rng : RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = chunk_seed
|
||||
|
||||
gen_terra_chunk(chunk, rng, raycast)
|
||||
|
||||
func gen_terra_chunk(chunk: TerrainChunk, rng : RandomNumberGenerator, raycast : WorldGenRaycast) -> void:
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
||||
|
||||
var s : FastNoise = FastNoise.new()
|
||||
s.set_noise_type(FastNoise.TYPE_SIMPLEX)
|
||||
s.set_seed(current_seed)
|
||||
|
||||
var sdet : FastNoise = FastNoise.new()
|
||||
sdet.set_noise_type(FastNoise.TYPE_SIMPLEX)
|
||||
sdet.set_seed(current_seed)
|
||||
|
||||
var luv : Vector2 = raycast.get_local_uv()
|
||||
|
||||
var lhit_world_pos : Vector2 = raycast.get_local_position()
|
||||
lhit_world_pos.x *= chunk.size_x
|
||||
lhit_world_pos.y *= chunk.size_z
|
||||
|
||||
var world_rect_size : Vector2 = get_rect().size
|
||||
world_rect_size.x *= chunk.size_x
|
||||
world_rect_size.y *= chunk.size_z
|
||||
|
||||
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
for z in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
var vx : int = x + (chunk.position_x * chunk.size_x)
|
||||
var vz : int = z + (chunk.position_z * chunk.size_z)
|
||||
var lwp : Vector2 = lhit_world_pos + Vector2(x, z)
|
||||
var local_uv : Vector2 = lwp / world_rect_size
|
||||
var interp : float = get_value_for(local_uv)
|
||||
|
||||
var val : float = (s.get_noise_2d(vx * 0.05, vz * 0.05) + 2)
|
||||
val *= val
|
||||
#val *= 10.0
|
||||
val += abs(sdet.get_noise_2d(vx * 0.8, vz * 0.8)) * 5
|
||||
|
||||
var oil : int = chunk.get_voxel(x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
oil += float(val) * interp
|
||||
|
||||
chunk.set_voxel(oil, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
if interp < 0.2:
|
||||
continue
|
||||
|
||||
chunk.set_voxel(1, x, z, TerrainChunkDefault.DEFAULT_CHANNEL_TYPE)
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_float("get_zone_radius", "set_zone_radius", "Zone Radius", 0.01)
|
||||
inspector.add_slot_float("get_zone_bevel", "set_zone_bevel", "Zone Bevel", 0.01)
|
||||
inspector.add_slot_float("get_zone_base", "set_zone_base", "Zone Base", 0.01)
|
55
scripts/world_generators/TerrainWorldGenerator.gd
Normal file
55
scripts/world_generators/TerrainWorldGenerator.gd
Normal file
@ -0,0 +1,55 @@
|
||||
tool
|
||||
extends TerrainLevelGenerator
|
||||
class_name TerrainWorldGenerator
|
||||
|
||||
# Copyright (c) 2019-2021 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.
|
||||
|
||||
export(int) var _level_seed : int
|
||||
export(bool) var _spawn_mobs : bool
|
||||
export(Resource) var world_gen_world : Resource = null
|
||||
|
||||
var _world : TerrainWorld
|
||||
var _library : TerrainLibrary
|
||||
|
||||
func setup(world : TerrainWorld, level_seed : int, spawn_mobs : bool, library: TerrainLibrary) -> void:
|
||||
_level_seed = level_seed
|
||||
_spawn_mobs = spawn_mobs
|
||||
_library = library
|
||||
|
||||
if world_gen_world != null:
|
||||
world_gen_world.setup_terra_library(_library, _level_seed)
|
||||
_library.refresh_rects()
|
||||
|
||||
func get_spawn_chunk_position() -> Vector2:
|
||||
if world_gen_world != null:
|
||||
var spawners : Array = world_gen_world.get_spawn_positions()
|
||||
|
||||
if spawners.size() > 0:
|
||||
var v : Vector2 = spawners[0][1]
|
||||
return v
|
||||
|
||||
return Vector2()
|
||||
|
||||
func _generate_chunk(chunk : TerrainChunk) -> void:
|
||||
if world_gen_world == null:
|
||||
return
|
||||
|
||||
world_gen_world.generate_terra_chunk(chunk, _level_seed, _spawn_mobs)
|
3
terraman/Terraman.tscn
Normal file
3
terraman/Terraman.tscn
Normal file
@ -0,0 +1,3 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Main" type="Spatial"]
|
12
test_world/world.tres
Normal file
12
test_world/world.tres
Normal file
@ -0,0 +1,12 @@
|
||||
[gd_resource type="Resource" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/world_generator/resources/world_gen_world.gd" type="Script" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "world"
|
||||
script = ExtResource( 1 )
|
||||
rect = Rect2( 0, 0, 100, 100 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
continents = [ ]
|
13
worlds/test_world/environments/default_env.tres
Normal file
13
worlds/test_world/environments/default_env.tres
Normal file
@ -0,0 +1,13 @@
|
||||
[gd_resource type="Environment3D" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
sky_top_color = Color( 0.0470588, 0.454902, 0.976471, 1 )
|
||||
sky_horizon_color = Color( 0.556863, 0.823529, 0.909804, 1 )
|
||||
sky_curve = 0.25
|
||||
ground_bottom_color = Color( 0.101961, 0.145098, 0.188235, 1 )
|
||||
ground_horizon_color = Color( 0.482353, 0.788235, 0.952941, 1 )
|
||||
ground_curve = 0.01
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
4
worlds/test_world/noises/base_ocean_noise.tres
Normal file
4
worlds/test_world/noises/base_ocean_noise.tres
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_resource type="FastnoiseNoiseParams" format=2]
|
||||
|
||||
[resource]
|
||||
resource_name = "Ocean Floor Noise"
|
177
worlds/test_world/test_world.tres
Normal file
177
worlds/test_world/test_world.tres
Normal file
@ -0,0 +1,177 @@
|
||||
[gd_resource type="Resource" load_steps=19 format=2]
|
||||
|
||||
[ext_resource path="res://scripts/world_generator/worlds/ocean_base_world.gd" type="Script" id=1]
|
||||
[ext_resource path="res://scripts/world_generator/subzones/test_subzone.gd" type="Script" id=2]
|
||||
[ext_resource path="res://scripts/world_generator/continents/test_continent.gd" type="Script" id=3]
|
||||
[ext_resource path="res://scripts/world_generator/zones/test_zone.gd" type="Script" id=7]
|
||||
[ext_resource path="res://worlds/test_world/noises/base_ocean_noise.tres" type="FastnoiseNoiseParams" id=10]
|
||||
[ext_resource path="res://scripts/world_generator/subzones/forest.gd" type="Script" id=13]
|
||||
[ext_resource path="res://scripts/world_generator/subzoneprops/mob_spawner.gd" type="Script" id=17]
|
||||
|
||||
[sub_resource type="Resource" id=4]
|
||||
resource_name = "Village"
|
||||
script = ExtResource( 2 )
|
||||
rect = Rect2( 7.75716, 3.27374, 6.3125, 5.5625 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
subzone_props = [ ]
|
||||
|
||||
[sub_resource type="Resource" id=22]
|
||||
resource_name = "MS"
|
||||
script = ExtResource( 17 )
|
||||
rect = Rect2( 0.0787451, 0.0590621, 8.01231, 9.32505 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
level = 1
|
||||
|
||||
[sub_resource type="Resource" id=7]
|
||||
resource_name = "Forest1"
|
||||
script = ExtResource( 13 )
|
||||
rect = Rect2( 0.714818, 1.1547, 8.23499, 9.43806 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
subzone_props = [ SubResource( 22 ) ]
|
||||
|
||||
[sub_resource type="Resource" id=12]
|
||||
resource_name = "Forest2"
|
||||
|
||||
[sub_resource type="PropDataMeshData" id=1]
|
||||
|
||||
[sub_resource type="PropData" id=17]
|
||||
props = [ SubResource( 1 ) ]
|
||||
|
||||
[sub_resource type="GDScript" id=19]
|
||||
script/source = "tool
|
||||
extends SubZone
|
||||
|
||||
export(PropData) var prop_tree : PropData
|
||||
export(PropData) var prop_tree2 : PropData
|
||||
|
||||
func get_prop_tree() -> PropData:
|
||||
return prop_tree
|
||||
|
||||
func set_prop_tree(ed : PropData) -> void:
|
||||
prop_tree = ed
|
||||
emit_changed()
|
||||
|
||||
func get_prop_tree2() -> PropData:
|
||||
return prop_tree2
|
||||
|
||||
func set_prop_tree2(ed : PropData) -> void:
|
||||
prop_tree2 = ed
|
||||
emit_changed()
|
||||
|
||||
func get_editor_rect_border_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 1)
|
||||
|
||||
func get_editor_rect_color() -> Color:
|
||||
return Color(0.8, 0.8, 0.8, 0.9)
|
||||
|
||||
func get_editor_rect_border_size() -> int:
|
||||
return 2
|
||||
|
||||
func get_editor_font_color() -> Color:
|
||||
return Color(0, 0, 0, 1)
|
||||
|
||||
func get_editor_class() -> String:
|
||||
return \"Forest\"
|
||||
|
||||
func get_editor_additional_text() -> String:
|
||||
return \"\"
|
||||
|
||||
func _generate_terra_chunk(chunk: TerrainChunk, pseed : int, spawn_mobs: bool, raycast : WorldGenRaycast) -> void:
|
||||
|
||||
var cx : int = chunk.get_position_x()
|
||||
var cz : int = chunk.get_position_z()
|
||||
|
||||
var chunk_seed : int = 123 + (cx * 231) + (cz * 123)
|
||||
|
||||
var rng : RandomNumberGenerator = RandomNumberGenerator.new()
|
||||
rng.seed = chunk_seed
|
||||
|
||||
#chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
|
||||
chunk.channel_ensure_allocated(TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)
|
||||
|
||||
# TODO refactor this, it's inefficient
|
||||
for x in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
for z in range(-chunk.margin_start, chunk.size_x + chunk.margin_end):
|
||||
if rng.randf() > 0.992:
|
||||
var oil : int = chunk.get_voxel(x, z, TerrainChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
|
||||
|
||||
var tr : Transform = Transform()
|
||||
|
||||
tr = tr.rotated(Vector3(0, 1, 0), rng.randf() * PI)
|
||||
tr = tr.rotated(Vector3(1, 0, 0), rng.randf() * 0.2 - 0.1)
|
||||
tr = tr.rotated(Vector3(0, 0, 1), rng.randf() * 0.2 - 0.1)
|
||||
tr = tr.scaled(Vector3(0.9 + rng.randf() * 0.2, 0.9 + rng.randf() * 0.2, 0.9 + rng.randf() * 0.2))
|
||||
tr.origin = Vector3((x + chunk.position_x * chunk.size_x), ((oil - 2) / 255.0) * chunk.world_height, (z + chunk.position_z * chunk.size_z))
|
||||
|
||||
chunk.voxel_world.prop_add(tr, prop_tree)
|
||||
|
||||
func setup_property_inspector(inspector) -> void:
|
||||
.setup_property_inspector(inspector)
|
||||
|
||||
inspector.add_h_separator()
|
||||
inspector.add_slot_resource(\"get_prop_tree\", \"set_prop_tree\", \"Prop Tree\", \"PropData\")
|
||||
inspector.add_slot_resource(\"get_prop_tree2\", \"set_prop_tree2\", \"Prop Tree2\", \"PropData\")
|
||||
"
|
||||
|
||||
[sub_resource type="Resource" id=25]
|
||||
resource_name = "MS"
|
||||
script = ExtResource( 17 )
|
||||
rect = Rect2( 0.056856, -0.016504, 2.28407, 3.506 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
level = 1
|
||||
|
||||
[sub_resource type="Resource" id=20]
|
||||
resource_name = "Forest4"
|
||||
script = SubResource( 19 )
|
||||
rect = Rect2( 9.27578, 7.43671, 2.34922, 3.51792 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
subzone_props = [ SubResource( 25 ) ]
|
||||
prop_tree = SubResource( 17 )
|
||||
|
||||
[sub_resource type="Resource" id=3]
|
||||
resource_name = "TestForest"
|
||||
script = ExtResource( 7 )
|
||||
rect = Rect2( 8.85557, 6.975, 21.9944, 11.2839 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
subzones = [ SubResource( 4 ), SubResource( 7 ), SubResource( 12 ), SubResource( 20 ) ]
|
||||
zone_radius = 0.5
|
||||
zone_bevel = 0.3
|
||||
zone_base = 0.0
|
||||
|
||||
[sub_resource type="Resource" id=21]
|
||||
resource_name = "C"
|
||||
script = ExtResource( 3 )
|
||||
rect = Rect2( 241, 247, 40, 25 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
zones = [ SubResource( 3 ) ]
|
||||
continent_radius = 0.5
|
||||
continent_bevel = 0.3
|
||||
continent_base = 0.0
|
||||
|
||||
[resource]
|
||||
resource_name = "TestWorld"
|
||||
script = ExtResource( 1 )
|
||||
rect = Rect2( -250, -250, 500, 500 )
|
||||
min_size = Vector2i( 1, 1 )
|
||||
max_size = Vector2i( 1e+06, 1e+06 )
|
||||
locked = false
|
||||
continents = [ SubResource( 21 ) ]
|
||||
normal_surface_id = 2
|
||||
base_iso_level = 0
|
||||
water_iso_level = 100
|
||||
water_surface_id = 5
|
||||
base_noise = ExtResource( 10 )
|
22
worlds/test_world/voxel_library/merger_library_mat.tres
Normal file
22
worlds/test_world/voxel_library/merger_library_mat.tres
Normal file
File diff suppressed because one or more lines are too long
15
worlds/test_world/voxel_library/merger_prop_mat.tres
Normal file
15
worlds/test_world/voxel_library/merger_prop_mat.tres
Normal file
@ -0,0 +1,15 @@
|
||||
[gd_resource type="SpatialMaterial" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://textures/world/grass/grass_mossy_albedo.png" type="Texture" id=1]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[resource]
|
||||
resource_name = "Material.003"
|
||||
vertex_color_use_as_albedo = true
|
||||
albedo_texture = ExtResource( 1 )
|
||||
metallic = 0.5
|
||||
roughness = 0.0960784
|
Loading…
Reference in New Issue
Block a user