Removed the voxelman specific code/resources from the project.

This commit is contained in:
Relintai 2021-04-19 10:41:41 +02:00
parent 00abc55491
commit e582f4d6e5
28 changed files with 82 additions and 2501 deletions

View File

@ -214,6 +214,6 @@ master func sreceive_upload_character(data: String) -> void:
func set_terrarin_player():
Logger.verbose("NetworkManager cspawn_player")
var terrarin : VoxelWorld = get_node("/root/GameScene/VoxelWorld")
var terrarin : TerraWorld = get_node("/root/GameScene/VoxelWorld")
terrarin.set_player(local_player_master.player.get_body() as Spatial)

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://voxelman/debug/FreeLookCamera.gd" type="Script" id=1]
[ext_resource path="res://debug/FreeLookCamera.gd" type="Script" id=1]
[node name="Camera" type="Camera"]

File diff suppressed because one or more lines are too long

View File

@ -32,38 +32,6 @@ func _setup():
var d : Dungeon = get_dungeon(i)
d.setup()
func _generate_voxel_chunk(chunk: VoxelChunk, spawn_mobs: bool) -> void:
if voxel_scale < 0:
voxel_scale = chunk.voxel_scale
#todo generate this properly
var entrance_position : Vector3 = Vector3(7, 5, 7)
for i in range(get_dungeon_count()):
var d : Dungeon = get_dungeon(i)
if d.has_method("has_entrance_position"):
d.entrance_position.origin = entrance_position
entrance_position = d.next_level_teleporter_position_data_space
entrance_position *= voxel_scale
terrarin_gen.generate_simple_terrarin(chunk, spawn_mobs)
for i in range(get_dungeon_count()):
get_dungeon(i).generate_chunk(chunk, spawn_mobs)
if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs and randi() % 4 == 0:
var level : int = 1
if chunk.get_voxel_world().has_method("get_mob_level"):
level = chunk.get_voxel_world().get_mob_level()
ESS.entity_spawner.spawn_mob(0, level, \
Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
(chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \
chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2))
func _generate_terra_chunk(chunk, spawn_mobs):
if voxel_scale < 0:
voxel_scale = chunk.voxel_scale
@ -97,157 +65,6 @@ func _generate_terra_chunk(chunk, spawn_mobs):
100, \
chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2))
func generate_terrarin(chunk : VoxelChunk, spawn_mobs: bool) -> void:
var noise : OpenSimplexNoise = OpenSimplexNoise.new()
noise.seed = 10 * current_seed
noise.octaves = 4
noise.period = 280.0
noise.persistence = 0.8
var terr_noise : OpenSimplexNoise = OpenSimplexNoise.new()
terr_noise.seed = 10 * 321 + 112 * current_seed
terr_noise.octaves = 4
terr_noise.period = 90.0
terr_noise.persistence = 0.9
var det_noise : OpenSimplexNoise = OpenSimplexNoise.new()
det_noise.seed = 10 * 3231 + 112 * current_seed
det_noise.octaves = 6
det_noise.period = 80.0
det_noise.persistence = 0.3
for x in range(-chunk.get_margin_start(), chunk.size_x + chunk.get_margin_end()):
for z in range(-chunk.get_margin_start(), chunk.size_z + chunk.get_margin_end()):
var val : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
val *= val
val *= 200
val += 2
var tv : float = terr_noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
tv *= tv * tv * tv
val += tv * 2
var dval : float = noise.get_noise_2d(x + (chunk.position_x * chunk.size_x), z + (chunk.position_z * chunk.size_z))
val += dval * 6
var v : int = (int(val))
v -= chunk.position_y * (chunk.size_y)
if v > chunk.size_y + chunk.get_margin_end():
v = chunk.size_y + chunk.get_margin_end()
for y in range(-chunk.get_margin_start(), v):
seed(x + (chunk.position_x * chunk.size_x) + z + (chunk.position_z * chunk.size_z) + y + (chunk.position_y * chunk.size_y))
if v < 2:
chunk.set_voxel(1, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
elif v == 2:
chunk.set_voxel(3, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
else:
chunk.set_voxel(2, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# if y == v - 1:
# chunk.set_voxel(int(255.0 * (val - int(val))), x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
# else:
# chunk.set_voxel(255, x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
#
var val2 : float = (val - int(val)) * 4.0
val2 = int(val2)
val2 /= 4.0
chunk.set_voxel(int(255.0 * val2), x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
# chunk.set_voxel(int(255.0 * (val - int(val)) / 180.0) * 180, x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
# chunk.set_voxel(int(255.0 * (val - int(val))), x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
# box_blur(chunk)
# chunk.build()
if not Engine.editor_hint and chunk.position_y == 0 and spawn_mobs:
var level : int = 1
if chunk.get_voxel_world().has_method("get_mob_level"):
level = chunk.get_voxel_world().mob_level
ESS.entity_spawner.spawn_mob(0, level, \
Vector3(chunk.position_x * chunk.size_x * chunk.voxel_scale + chunk.size_x / 2,\
(chunk.position_y + 1) * chunk.size_y * chunk.voxel_scale, \
chunk.position_z * chunk.size_z * chunk.voxel_scale + chunk.size_z / 2))
func box_blur(chunk : VoxelChunk):
for x in range(0, chunk.size_x):
for z in range(0, chunk.size_z):
for y in range(0, chunk.size_z):
var avg : float = 0
var avgc : int = 0
var curr : int = chunk.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
curr = chunk.get_voxel(x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
if curr > 0:
avg += curr
avgc += 1
avg /= float(avgc)
var aavg: int = int(avg)
chunk.set_voxel(aavg, x, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x + 1, y, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x + 1, y, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x + 1, y + 1, z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
chunk.set_voxel(aavg, x + 1, y + 1, z + 1, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
func gen_terra_chunk(chunk: TerraChunk) -> void:
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_TYPE, 1)
chunk.channel_ensure_allocated(TerraChunkDefault.DEFAULT_CHANNEL_ISOLEVEL, 0)

View File

@ -25,76 +25,76 @@ func _setup():
sizex = 4
sizey = 4
sizez = 4
func a_generate_voxel_chunk(chunk : VoxelChunk, spawn_mobs: bool) -> void:
if chunk.position_x != 0 or chunk.position_z != 0:
return
var hs : int = chunk.get_size_y() / 2 - sizex / 2
if chunk.position_y == 0:
for y in range(0, 4):
for x in range(-4, 5):
for z in range(-4, 5):
if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) != 0:
chunk.set_voxel(4, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
for x in range(-5, 5):
for z in [-5, 4]:
for y in range(0, randi() % 5):
if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) == 0:
chunk.set_voxel(4, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(10, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
for x in [-5, 5]:
for z in range(-5, 4):
for y in range(0, randi() % 5):
if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) == 0:
chunk.set_voxel(4, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(10, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
# var num : int = randi() % 10 + 7
# for i in range(num):
# var x : int = randi() % 12 - 6
# var z : int = randi() % 12 - 6
#
# for y in range(4, 1, -1):
# if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) != 0:
# chunk.set_voxel(1, hs + x, y + 1, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(100, hs + x, y + 1, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
# break
for y in range(-chunk.get_margin_start(), chunk.size_y + chunk.get_margin_end()):
for x in range(0, 2):
for z in range(0, 2):
chunk.set_voxel(0, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
for y in range(3, chunk.get_size_y() / 2):
chunk.set_voxel(4, hs, y, hs, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel((16 - y) * 8, hs, y, hs, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
if chunk.position_y == -1:
for y in range(chunk.get_size_y() - sizey - 1, chunk.get_size_y()):
for x in range(hs - 1, hs + sizex + 1):
for z in range(hs - 1, hs + sizez + 1):
chunk.set_voxel(4, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(255, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
for y in range(chunk.get_size_y() - sizey + 1, chunk.size_y + chunk.get_margin_end()):
for x in range(0, 2):
for z in range(0, 2):
chunk.set_voxel(0, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
for y in range(chunk.get_size_y() - sizey, chunk.get_size_y() - 1):
for x in range(hs, hs + sizex):
for z in range(hs, hs + sizez):
chunk.set_voxel(0, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
for x in range(0, 2):
for z in range(0, 2):
chunk.set_voxel(3, hs + x, chunk.get_size_y() - sizey, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
chunk.set_voxel(30, x, chunk.get_size_y() - sizey, z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
#func a_generate_voxel_chunk(chunk : VoxelChunk, spawn_mobs: bool) -> void:
# if chunk.position_x != 0 or chunk.position_z != 0:
# return
#
# var hs : int = chunk.get_size_y() / 2 - sizex / 2
#
# if chunk.position_y == 0:
# for y in range(0, 4):
# for x in range(-4, 5):
# for z in range(-4, 5):
# if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) != 0:
# chunk.set_voxel(4, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
#
#
# for x in range(-5, 5):
# for z in [-5, 4]:
# for y in range(0, randi() % 5):
# if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) == 0:
# chunk.set_voxel(4, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(10, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
#
# for x in [-5, 5]:
# for z in range(-5, 4):
# for y in range(0, randi() % 5):
# if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) == 0:
# chunk.set_voxel(4, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(10, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
#
## var num : int = randi() % 10 + 7
## for i in range(num):
## var x : int = randi() % 12 - 6
## var z : int = randi() % 12 - 6
##
## for y in range(4, 1, -1):
## if chunk.get_voxel(hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE) != 0:
## chunk.set_voxel(1, hs + x, y + 1, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
## chunk.set_voxel(100, hs + x, y + 1, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
## break
#
# for y in range(-chunk.get_margin_start(), chunk.size_y + chunk.get_margin_end()):
# for x in range(0, 2):
# for z in range(0, 2):
# chunk.set_voxel(0, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
#
# for y in range(3, chunk.get_size_y() / 2):
# chunk.set_voxel(4, hs, y, hs, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel((16 - y) * 8, hs, y, hs, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
#
# if chunk.position_y == -1:
# for y in range(chunk.get_size_y() - sizey - 1, chunk.get_size_y()):
# for x in range(hs - 1, hs + sizex + 1):
# for z in range(hs - 1, hs + sizez + 1):
# chunk.set_voxel(4, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(255, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
#
# for y in range(chunk.get_size_y() - sizey + 1, chunk.size_y + chunk.get_margin_end()):
# for x in range(0, 2):
# for z in range(0, 2):
# chunk.set_voxel(0, hs + x, y, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
#
#
# for y in range(chunk.get_size_y() - sizey, chunk.get_size_y() - 1):
# for x in range(hs, hs + sizex):
# for z in range(hs, hs + sizez):
# chunk.set_voxel(0, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
#
# for x in range(0, 2):
# for z in range(0, 2):
# chunk.set_voxel(3, hs + x, chunk.get_size_y() - sizey, hs + z, VoxelChunkDefault.DEFAULT_CHANNEL_TYPE)
# chunk.set_voxel(30, x, chunk.get_size_y() - sizey, z, VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL)
#
#

View File

@ -111,14 +111,6 @@ func _setup():
build()
func _setup_voxel_library(library):
._setup_voxel_library(library)
if library is VoxelmanLibraryMerger:
library.get_prop_packer().add_texture(wall_texture)
library.get_prop_packer().add_texture(floor_texture)
library.get_prop_packer().add_texture(ceiling_texture)
func _setup_terra_library(library):
._setup_terra_library(library)
@ -220,11 +212,11 @@ func _generate_voxel_chunk(chunk, spawn_mobs):
# for i in range(get_dungeon_start_room_count()):
# get_dungeon_start_room(i).generate_chunk(chunk, spawn_mobs)
func add_wall(chunk : VoxelChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource, tex : Texture):
func add_wall(chunk : TerraChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource, tex : Texture):
for y in range(floor_pos, ceiling_pos):
chunk.add_mesh_data_resourcev(Vector3(x, y, z), wall, tex)
func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk : VoxelChunk, teleports_to : Vector3):
func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk : TerraChunk, teleports_to : Vector3):
var s = scene.instance()
chunk.get_voxel_world().add_child(s)
s.transform = transform

View File

@ -106,7 +106,7 @@ func _generate_voxel_chunk(chunk, spawn_mobs):
if !aabb.intersects(chunk_aabb):
return
chunk.ensure_channel_allocated(VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE, 1)
chunk.ensure_channel_allocated(TerraChunkDefault.DEFAULT_CHANNEL_ALT_TYPE, 1)
var px : int = chunk.position_x * chunk.size_x - posx
var pz : int = chunk.position_z * chunk.size_z - posz
@ -171,12 +171,12 @@ func _generate_voxel_chunk(chunk, spawn_mobs):
# for i in range(get_dungeon_start_room_count()):
# get_dungeon_start_room(i).generate_chunk(chunk, spawn_mobs)
func add_wall(chunk : VoxelChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource, tex : Texture):
func add_wall(chunk : TerraChunk, x : int, z : int, floor_pos : int, ceiling_pos : int, wall : MeshDataResource, tex : Texture):
for y in range(floor_pos, ceiling_pos):
chunk.set_voxel(0, x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE)
chunk.set_voxel(0, x, z, TerraChunkDefault.DEFAULT_CHANNEL_ALT_TYPE)
# chunk.add_mesh_data_resourcev(Vector3(x, y, z), wall, tex)
func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk : VoxelChunk, teleports_to : Vector3):
func spawn_teleporter_scene(scene : PackedScene, transform : Transform, chunk : TerraChunk, teleports_to : Vector3):
var s = scene.instance()
chunk.get_voxel_world().add_child(s)
s.transform = transform

View File

@ -12,19 +12,6 @@ func _instance(p_seed, p_instance):
return p_instance
func _generate_voxel_chunk(chunk : VoxelChunk, spawn_mobs : bool):
if trainer == null || vendor == null:
return
if chunk.position_x == 0 && chunk.position_y == 0 && chunk.position_z == 0:
var pos : Vector3 = Vector3(4 * chunk.voxel_scale, 8 * chunk.voxel_scale, 4 * chunk.voxel_scale)
ESS.entity_spawner.spawn_mob(trainer.id, 1, pos)
pos = Vector3(2 * chunk.voxel_scale, 8 * chunk.voxel_scale, 2 * chunk.voxel_scale)
ESS.entity_spawner.spawn_mob(vendor.id, 1, pos)
func _generate_terra_chunk(chunk : TerraChunk, spawn_mobs : bool):
if trainer == null || vendor == null:
return

View File

@ -1,16 +0,0 @@
[gd_resource type="VoxelmanLibraryMerger" load_steps=9 format=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/surfaces/2_test.tres" type="VoxelSurfaceMerger" id=1]
[ext_resource path="res://modules/planets/test_planet/voxel_library/surfaces/4_dungeon_stone.tres" type="VoxelSurfaceMerger" id=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/surfaces/1_stone.tres" type="VoxelSurfaceMerger" id=3]
[ext_resource path="res://modules/core/materials/1_standard_material.tres" type="Material" id=4]
[ext_resource path="res://modules/planets/test_planet/voxel_library/surfaces/3_test2.tres" type="VoxelSurfaceMerger" id=5]
[ext_resource path="res://modules/core/materials/5_standard_material_nouv2.tres" type="Material" id=6]
[ext_resource path="res://modules/core/materials/7_standard_material_notex.tres" type="Material" id=7]
[ext_resource path="res://modules/core/materials/10_standard_vman_mdr_material.tres" type="Material" id=8]
[resource]
materials = [ ExtResource( 4 ), ExtResource( 6 ), ExtResource( 6 ), ExtResource( 7 ), ExtResource( 7 ), ExtResource( 7 ), ExtResource( 7 ), ExtResource( 7 ) ]
prop_materials = [ ExtResource( 8 ), ExtResource( 8 ), ExtResource( 8 ), ExtResource( 8 ) ]
texture_flags = 1
voxel_surfaces = [ ExtResource( 3 ), ExtResource( 1 ), ExtResource( 5 ), ExtResource( 2 ) ]

View File

@ -1,11 +0,0 @@
[gd_resource type="VoxelSurfaceMerger" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/dirt_albedo.png" type="Texture" id=1]
[resource]
resource_name = "Stone"
id = 1
voxel_name = "Stone"
texture_top = ExtResource( 1 )
texture_bottom = ExtResource( 1 )
texture_side = ExtResource( 1 )

View File

@ -1,11 +0,0 @@
[gd_resource type="VoxelSurfaceMerger" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_1_albedo.png" type="Texture" id=1]
[resource]
resource_name = "Test"
id = 2
voxel_name = "Test"
texture_top = ExtResource( 1 )
texture_bottom = ExtResource( 1 )
texture_side = ExtResource( 1 )

View File

@ -1,11 +0,0 @@
[gd_resource type="VoxelSurfaceMerger" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/grass_mossy_albedo.png" type="Texture" id=1]
[resource]
resource_name = "Test2"
id = 3
voxel_name = "Test2"
texture_top = ExtResource( 1 )
texture_bottom = ExtResource( 1 )
texture_side = ExtResource( 1 )

View File

@ -1,11 +0,0 @@
[gd_resource type="VoxelSurfaceMerger" load_steps=2 format=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/stone_dungeon_1_albedo.png" type="Texture" id=1]
[resource]
resource_name = "Dungeon Stone"
id = 4
voxel_name = "Dungeon Stone"
texture_top = ExtResource( 1 )
texture_bottom = ExtResource( 1 )
texture_side = ExtResource( 1 )

View File

@ -1,205 +0,0 @@
{
"connections": [
{
"from": "voronoi",
"from_port": 1,
"to": "colorize",
"to_port": 0
},
{
"from": "colorize",
"from_port": 0,
"to": "blend",
"to_port": 0
},
{
"from": "perlin",
"from_port": 0,
"to": "blend",
"to_port": 1
},
{
"from": "blend",
"from_port": 0,
"to": "colorize_2",
"to_port": 0
},
{
"from": "colorize_2",
"from_port": 0,
"to": "Material",
"to_port": 0
},
{
"from": "colorize_2",
"from_port": 0,
"to": "export",
"to_port": 0
}
],
"label": "Graph",
"name": "@@1045",
"node_position": {
"x": 0,
"y": 0
},
"nodes": [
{
"name": "Material",
"node_position": {
"x": 508,
"y": -238
},
"parameters": {
"albedo_color": {
"a": 1,
"b": 1,
"g": 1,
"r": 1,
"type": "Color"
},
"ao_light_affect": 1,
"depth_scale": 1,
"emission_energy": 1,
"metallic": 1,
"normal_scale": 1,
"roughness": 1,
"size": 7,
"subsurf_scatter_strength": 0
},
"type": "material"
},
{
"name": "voronoi",
"node_position": {
"x": -627.5,
"y": -296.5
},
"parameters": {
"intensity": 1,
"randomness": 0.95,
"scale_x": 8,
"scale_y": 8,
"stretch_x": 1,
"stretch_y": 1
},
"type": "voronoi"
},
{
"name": "colorize",
"node_position": {
"x": -362.5,
"y": -334.5
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0,
"r": 0
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 1,
"r": 1
}
],
"type": "Gradient"
}
},
"type": "colorize"
},
{
"name": "export",
"node_position": {
"x": 545.5,
"y": 62.5
},
"parameters": {
"size": 7,
"suffix": "albedo"
},
"type": "export"
},
{
"name": "perlin",
"node_position": {
"x": -373.5,
"y": -38.5
},
"parameters": {
"iterations": 9,
"persistence": 0.9,
"scale_x": 20,
"scale_y": 20
},
"type": "perlin"
},
{
"name": "blend",
"node_position": {
"x": -102.5,
"y": -118.5
},
"parameters": {
"amount": 0.68005,
"blend_type": 0
},
"type": "blend"
},
{
"name": "colorize_2",
"node_position": {
"x": 223.5,
"y": -182.5
},
"parameters": {
"gradient": {
"interpolation": 1,
"points": [
{
"a": 1,
"b": 0,
"g": 0,
"pos": 0,
"r": 0
},
{
"a": 1,
"b": 0.670407,
"g": 0.671875,
"pos": 0.6,
"r": 0.624903
},
{
"a": 1,
"b": 0.742626,
"g": 0.84375,
"pos": 0.836364,
"r": 0.83743
},
{
"a": 1,
"b": 1,
"g": 1,
"pos": 1,
"r": 1
}
],
"type": "Gradient"
}
},
"type": "colorize"
}
],
"parameters": {
},
"type": "graph"
}

View File

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/stone_2_albedo.png-c18c0574c81fbcf23632af2f67956979.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://data/voxel_surfaces/stone_2_albedo.png"
dest_files=[ "res://.import/stone_2_albedo.png-c18c0574c81fbcf23632af2f67956979.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -44,11 +44,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://scripts/entities/EntityDataGD.gd"
}, {
"base": "VoxelMesherCubic",
"class": "GDCubicVoxelMesher",
"language": "GDScript",
"path": "res://voxelman/debug/CubicVoxelMesher.gd"
}, {
"base": "Node",
"class": "GEAction",
"language": "GDScript",
@ -149,11 +144,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://scenes/MainScene.gd"
}, {
"base": "VoxelmanLevelGenerator",
"class": "MainPlanetGenerator",
"language": "GDScript",
"path": "res://scripts/world_generators/MainPlanetGenerator.gd"
}, {
"base": "TerramanLevelGenerator",
"class": "MainTPlanetGenerator",
"language": "GDScript",
@ -204,21 +194,6 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://scripts/spells/gd_spell_script.gd"
}, {
"base": "VoxelChunkMarchingCubes",
"class": "TVVoxelChunk",
"language": "GDScript",
"path": "res://voxelman/world/TVVoxelChunk.gd"
}, {
"base": "VoxelMesherMarchingCubes",
"class": "TVVoxelMesher",
"language": "GDScript",
"path": "res://voxelman/world/TVVoxelMesher.gd"
}, {
"base": "VoxelMesherMarchingCubes",
"class": "TestVoxelMesher",
"language": "GDScript",
"path": "res://voxelman/debug/TestVoxelMesher.gd"
}, {
"base": "GameModule",
"class": "UIGuiChildModule",
"language": "GDScript",
@ -237,7 +212,6 @@ _global_script_class_icons={
"DisplayPlayerGD": "",
"EntityAIGD": "",
"EntityDataGD": "",
"GDCubicVoxelMesher": "",
"GEAction": "",
"GEBrighten": "",
"GEBrush": "",
@ -258,7 +232,6 @@ _global_script_class_icons={
"ItemTemplateGD": "",
"LayeredTextureMaker": "",
"Main": "",
"MainPlanetGenerator": "",
"MainTPlanetGenerator": "",
"ManaResource": "",
"Menu": "",
@ -269,9 +242,6 @@ _global_script_class_icons={
"SpeedResource": "",
"SpellEffectVisualBasic": "",
"SpellGD": "",
"TVVoxelChunk": "",
"TVVoxelMesher": "",
"TestVoxelMesher": "",
"UIGuiChildModule": "",
"UIWindowModule": ""
}

View File

@ -5,7 +5,7 @@
[ext_resource path="res://menu/Menu.tscn" type="PackedScene" id=3]
[ext_resource path="res://ui/theme/ui_theme.tres" type="Theme" id=4]
[ext_resource path="res://ui/debug/DebugInfo.tscn" type="PackedScene" id=5]
[ext_resource path="res://voxelman/debug/FreeLookCam.tscn" type="PackedScene" id=6]
[ext_resource path="res://debug/FreeLookCam.tscn" type="PackedScene" id=6]
[node name="Main" type="Node"]
script = ExtResource( 1 )

View File

@ -1,88 +0,0 @@
[gd_scene load_steps=10 format=2]
[ext_resource path="res://scripts/world_generators/MainPlanetGenerator.gd" type="Script" id=1]
[ext_resource path="res://modules/planets/test_planet/voxel_library/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://test_props/MeshDataInstance.tres" type="PropData" id=4]
[ext_resource path="res://modules/planets/test_planet/DungeonPlanetData.tres" type="Planet" id=5]
[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=8]
[sub_resource type="VoxelmanLevelGenerator" id=1]
script = ExtResource( 1 )
_force_planet = -1
_level_seed = 0
_spawn_mobs = false
planet = ExtResource( 5 )
[sub_resource type="ProceduralSky" id=2]
sky_top_color = Color( 0.34902, 0.643137, 0.705882, 1 )
sky_horizon_color = Color( 0.27451, 0.278431, 0.207843, 1 )
sky_curve = 0.263535
sky_energy = 0.3
ground_bottom_color = Color( 0.196078, 0.152941, 0.152941, 1 )
ground_horizon_color = Color( 0.223529, 0.192157, 0.164706, 1 )
ground_curve = 0.101965
ground_energy = 0.4
sun_color = Color( 0.45098, 0.352941, 0.113725, 1 )
sun_latitude = 39.71
sun_longitude = -8.09
sun_angle_min = 0.0
sun_angle_max = 23.15
sun_energy = 9.29
texture_size = 0
[sub_resource type="Environment" id=3]
background_mode = 2
background_sky = SubResource( 2 )
ambient_light_color = Color( 0.870588, 0.870588, 0.870588, 1 )
ambient_light_energy = 1.67
ambient_light_sky_contribution = 0.09
fog_enabled = true
fog_color = Color( 0.184314, 0.207843, 0.156863, 1 )
fog_sun_color = Color( 0.196078, 0.266667, 0.309804, 1 )
fog_sun_amount = 0.53
fog_depth_begin = 155.9
fog_depth_end = 379.9
fog_depth_curve = 1.18921
tonemap_mode = 2
tonemap_exposure = 0.83
auto_exposure_max_luma = 7.33
ss_reflections_enabled = true
ssao_enabled = true
glow_levels/3 = false
glow_intensity = 1.6
glow_strength = 1.1
glow_bloom = 0.1
glow_hdr_luminance_cap = 1.0
[node name="World" type="VoxelWorldDefault" groups=[
"save",
]]
data_margin_end = 2
max_concurrent_generations = 8
max_frame_chunk_build_steps = 4
library = ExtResource( 2 )
level_generator = SubResource( 1 )
voxel_scale = 2.0
chunk_spawn_range = 6
build_flags = 511
lod_update_interval = 2.0
num_lods = 8
script = ExtResource( 8 )
spawn_height = 3
test_prop = ExtResource( 4 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 3 )
__meta__ = {
"_editor_description_": ""
}
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( -0.797163, 0.45442, 0.397535, 0.124932, -0.520028, 0.844963, 0.590697, 0.723238, 0.357776, 0, 18.834, 0 )
layers = 3
light_color = Color( 1, 0.878431, 0.878431, 1 )
light_energy = 0.87
light_specular = 0.65
shadow_bias = 0.07
script = ExtResource( 3 )

View File

@ -1,105 +0,0 @@
tool
extends VoxelmanLevelGenerator
class_name MainPlanetGenerator
# 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.
const planet_folder : String = "res://modules/planets"
export(int) var _force_planet : int = -1
export(int) var _level_seed : int
export(bool) var _spawn_mobs : bool
export(Planet) var planet : Planet = null
var _world : VoxelWorld
var _planet : Planet
var _library : VoxelmanLibrary
func setup(world : VoxelWorld, level_seed : int, spawn_mobs : bool, library: VoxelmanLibrary) -> void:
_level_seed = level_seed
_world = world
_spawn_mobs = spawn_mobs
_library = library
if planet != null:
_planet = planet.instance(_level_seed)
_planet.current_seed = _level_seed
_planet.setup()
_planet.setup_library(_library)
_library.refresh_rects()
# create_planet()
func _generate_chunk(chunk : VoxelChunk) -> void:
if _planet == null:
return
_planet.generate_voxel_chunk(chunk, _spawn_mobs)
func create_planet():
var planet_files : Array = get_planets(planet_folder)
if planet_files.size() == 0:
return
var ind : int
if _force_planet == -1:
seed(_level_seed)
ind = randi() % planet_files.size()
else:
ind = _force_planet
var planet_data : Planet = ResourceLoader.load(planet_files[ind], "Planet")
if planet_data == null:
print("planet_data is null!")
return
print("planet loaded: " + planet_data.resource_path)
_planet = planet_data.instance(_level_seed)
_planet.current_seed = _level_seed
_planet.data = planet_data
_planet.setup()
_planet.setup_library(_library)
func get_planets(path : String, root : bool = true) -> Array:
var planet_files : Array = Array()
var dir = Directory.new()
if dir.open(path) == OK:
dir.list_dir_begin(true)
var file_name = dir.get_next()
while (file_name != ""):
if not dir.current_is_dir():
planet_files.append(path + "/" + file_name)
else:
if root:
var l : Array = get_planets(path + "/" + file_name, false)
for i in l:
planet_files.append(i)
file_name = dir.get_next()
return planet_files

View File

@ -1,27 +0,0 @@
extends Label
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# 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.
func _process(delta):
text = str(Engine.get_frames_per_second()) + "FPS"

View File

@ -1,101 +0,0 @@
extends VoxelMesherCubic
class_name GDCubicVoxelMesher
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# 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.
var count : int = 0
func _add_chunk(chunk : VoxelChunk) -> void:
chunk.generate_ao();
var x_size : int = chunk.get_size_x() - 1
var y_size : int = chunk.get_size_y() - 1
var z_size : int = chunk.get_size_z() - 1
var lod_size : float = 1
var voxel_size : float = 1
var cube_points : VoxelCubePoints = VoxelCubePoints.new()
var tile_uv_size : float = 1/4.0
var base_light : Color = Color(0.4, 0.4, 0.4)
for y in range(chunk.get_margin_start() + lod_size, y_size, lod_size):
for z in range(chunk.get_margin_start() + lod_size, z_size, lod_size):
for x in range(chunk.get_margin_start() + lod_size, x_size, lod_size):
cube_points.setup(chunk, x, y, z, lod_size)
if not cube_points.has_points():
continue
for face in range(VoxelCubePoints.VOXEL_FACE_COUNT):
if not cube_points.is_face_visible(face):
continue
add_indices(get_vertex_count() + 2)
add_indices(get_vertex_count() + 1)
add_indices(get_vertex_count() + 0)
add_indices(get_vertex_count() + 3)
add_indices(get_vertex_count() + 2)
add_indices(get_vertex_count() + 0)
var vertices : Array = [
cube_points.get_point_for_face(face, 0),
cube_points.get_point_for_face(face, 1),
cube_points.get_point_for_face(face, 2),
cube_points.get_point_for_face(face, 3)
]
var normals : Array = [
(vertices[3] - vertices[0]).cross(vertices[1] - vertices[0]),
(vertices[0] - vertices[1]).cross(vertices[2] - vertices[1]),
(vertices[1] - vertices[2]).cross(vertices[3] - vertices[2]),
(vertices[2] - vertices[3]).cross(vertices[0] - vertices[3])
]
var face_light_direction : Vector3 = cube_points.get_face_light_direction(face)
for i in range(4):
add_normal(normals[i])
var light : Color = cube_points.get_face_point_light_color(face, i)
light += base_light
var NdotL : float = clamp(normals[i].dot(face_light_direction), 0, 1.0)
light *= NdotL
light -= cube_points.get_face_point_ao_color(face, i) * ao_strength
add_color(light)
light.r = clamp(light.r, 0, 1.0)
light.g = clamp(light.g, 0, 1.0)
light.b = clamp(light.b, 0, 1.0)
add_uv((cube_points.get_point_uv_direction(face, i) + Vector2(0.5, 0.5)) * Vector2(tile_uv_size, tile_uv_size))
add_vertex((vertices[i] * voxel_size + Vector3(x, y, z)) * voxel_scale)

View File

@ -1,158 +0,0 @@
[gd_scene load_steps=18 format=2]
[ext_resource path="res://voxelman/debug/TVVoxelWorld.tscn" type="PackedScene" id=1]
[ext_resource path="res://modules/core/materials/voxelman.tres" type="Material" id=2]
[ext_resource path="res://voxelman/FPSCounter.gd" type="Script" id=3]
[ext_resource path="res://voxelman/debug/FreeLookCam.tscn" type="PackedScene" id=4]
[ext_resource path="res://modules/planets/test_planet/voxel_library/textures/grass_mossy_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 )
[sub_resource type="VoxelmanLevelGenerator" id=2]
script = ExtResource( 6 )
_force_planet = -1
_level_seed = 0
_spawn_mobs = false
[sub_resource type="SpatialMaterial" id=3]
albedo_color = Color( 0.00392157, 0.105882, 0.0196078, 1 )
[sub_resource type="PlaneMesh" id=4]
[sub_resource type="SphereMesh" id=5]
[sub_resource type="SpatialMaterial" id=6]
albedo_color = Color( 1, 0.00392157, 0.00392157, 1 )
[sub_resource type="PrismMesh" id=7]
[sub_resource type="PrismMesh" id=8]
[sub_resource type="SpatialMaterial" id=9]
albedo_color = Color( 0.129412, 1, 0.0156863, 1 )
albedo_texture = ExtResource( 5 )
[sub_resource type="PrismMesh" id=10]
[sub_resource type="SpatialMaterial" id=11]
albedo_color = Color( 0.00784314, 0.0627451, 1, 1 )
albedo_texture = ExtResource( 5 )
[node name="MC_Test" type="Spatial"]
[node name="Camera" parent="." instance=ExtResource( 4 )]
transform = Transform( -0.999922, -0.00920995, -0.00840917, -0.0115497, 0.938254, 0.345753, 0.00470557, 0.345823, -0.938288, 6.00985, 6.90149, -5.3643 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 1 )
[node name="DebugGeom" type="ImmediateGeometry" parent="."]
[node name="VoxelWorld" parent="." instance=ExtResource( 1 )]
level_generator = SubResource( 2 )
voxel_scale = 1.0
chunk_spawn_range = 2
show_loading_screen = false
generate_on_ready = true
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 1, 0, 0, 0, -0.236854, 0.971545, 0, -0.971545, -0.236854, 0, 41.8924, 0 )
[node name="DirectionalLight2" type="DirectionalLight" parent="."]
transform = Transform( -0.781917, -0.147651, 0.605645, -0.623383, 0.1852, -0.759667, 0, -0.971545, -0.236854, 0, 12.0807, 0 )
[node name="FPSCounter" type="Label" parent="."]
margin_right = 123.0
margin_bottom = 41.0
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -5, 0 )
material_override = SubResource( 3 )
mesh = SubResource( 4 )
material/0 = ExtResource( 2 )
[node name="gizmo" type="Spatial" parent="."]
[node name="MeshInstance2" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
mesh = SubResource( 5 )
material/0 = ExtResource( 2 )
[node name="MeshInstance6" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 1 )
mesh = SubResource( 5 )
material/0 = ExtResource( 2 )
[node name="MeshInstance7" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 1 )
mesh = SubResource( 5 )
material/0 = ExtResource( 2 )
[node name="MeshInstance8" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 1, 0 )
mesh = SubResource( 5 )
material/0 = ExtResource( 2 )
[node name="MeshInstance9" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 1, 0, 1 )
mesh = SubResource( 5 )
material/0 = ExtResource( 2 )
[node name="MeshInstance3" type="MeshInstance" parent="gizmo"]
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
material_override = SubResource( 6 )
mesh = SubResource( 7 )
material/0 = ExtResource( 2 )
[node name="MeshInstance4" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
mesh = SubResource( 8 )
material/0 = SubResource( 9 )
[node name="MeshInstance5" type="MeshInstance" parent="gizmo"]
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
mesh = SubResource( 10 )
material/0 = SubResource( 11 )
[node name="gizmo2" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 53.2071, 8.56598, 59.3495 )
[node name="MeshInstance2" type="MeshInstance" parent="gizmo2"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0 )
mesh = SubResource( 5 )
material/0 = ExtResource( 2 )
[node name="MeshInstance3" type="MeshInstance" parent="gizmo2"]
transform = Transform( 5.96244e-10, 0.05, 0, -0.05, 5.96244e-10, 0, 0, 0, 0.05, 1, 0, 0 )
material_override = SubResource( 6 )
mesh = SubResource( 7 )
material/0 = ExtResource( 2 )
[node name="MeshInstance4" type="MeshInstance" parent="gizmo2"]
transform = Transform( 0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 1, 0 )
mesh = SubResource( 8 )
material/0 = SubResource( 9 )
[node name="MeshInstance5" type="MeshInstance" parent="gizmo2"]
transform = Transform( 0.05, 0, 0, 0, -2.18557e-09, -0.05, 0, 0.05, -2.18557e-09, 0, 0, 1 )
mesh = SubResource( 10 )
material/0 = SubResource( 11 )

View File

@ -1,10 +0,0 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://modules/planets/test_planet/voxel_library/1_main_lib_merger_empty.tres" type="VoxelmanLibraryMerger" id=1]
[ext_resource path="res://voxelman/world/TVVoxelWorld.gd" type="Script" id=2]
[node name="World" type="VoxelWorldDefault"]
library = ExtResource( 1 )
voxel_scale = 2.0
player_path = NodePath("Camera")
script = ExtResource( 2 )

View File

@ -1,454 +0,0 @@
extends VoxelMesherMarchingCubes
class_name TestVoxelMesher
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# 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.
var count : int = 0
var regular_uv_entries : Array = [
[ 0, 0 ], #0
[ 1, 0 ], #1
[ 0, 1 ], #2
[ 1, 1 ], #3
]
var regular_uv_data : Array = [
[],
#[ 0x6201, 0x5102, 0x3304 ],
[ 2, 1, 3 ], #h top s, n, s
#[ 0x6201, 0x2315, 0x4113 ],
[ 2, 1, 0 ], #h top s, s, n
#[ 0x5102, 0x3304, 0x2315, 0x4113 ],
[ 0, 1, 2, 3 ], #h top n, s, s, n
#[ 0x5102, 0x4223, 0x1326 ],
[ 2, 3, 5 ], #h top
#[ 0x3304, 0x6201, 0x4223, 0x1326 ],
[ 2, 3, 1, 0 ], #h top
#[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326 ],
[ 2, 3, 1, 2, 1, 0 ], #h top
#[ 0x4223, 0x1326, 0x3304, 0x2315, 0x4113 ],
[ 3, 1, 0, 2, 3 ], #h top
#[ 0x4113, 0x8337, 0x4223 ],
[ 3, 1, 0 ], #h top
#[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337 ],
[ 3, 0, 2, 0, 3, 1 ], #h top
#[ 0x6201, 0x2315, 0x8337, 0x4223 ],
[ 2, 3, 1, 0 ], #h top
#[ 0x5102, 0x3304, 0x2315, 0x8337, 0x4223 ],
[ 0, 2, 3, 1, 0 ], #h top
#[ 0x5102, 0x4113, 0x8337, 0x1326 ],
[ 2, 3, 1, 0 ], #h top s, s, n, n
#[ 0x4113, 0x8337, 0x1326, 0x3304, 0x6201 ],
[ 3, 1, 0, 2, 2 ], #h top s, n, n, n, s
#[ 0x6201, 0x2315, 0x8337, 0x1326, 0x5102 ],
[ 2, 3, 1, 0, 2 ], #h top s, n, n, n, s
#[ 0x3304, 0x2315, 0x8337, 0x1326 ],
[ 2, 3, 1, 0 ], #h top n, n, n, n
#[ 0x3304, 0x1146, 0x2245 ],
[ 2, 0, 3 ], # h bottom n, s, s
#[ 0x6201, 0x5102, 0x1146, 0x2245 ],
[ 0, 1, 2, 3 ],
[ 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245 ],
[ 0x2315, 0x4113, 0x5102, 0x1146, 0x2245 ],
[ 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245 ],
[ 0x1146, 0x2245, 0x6201, 0x4223, 0x1326 ],
[ 0x3304, 0x1146, 0x2245, 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326 ],
[ 0x4223, 0x1326, 0x1146, 0x2245, 0x2315, 0x4113 ],
[ 0x4223, 0x4113, 0x8337, 0x3304, 0x1146, 0x2245 ],
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x4223, 0x4113, 0x8337 ],
[ 0x4223, 0x6201, 0x2315, 0x8337, 0x3304, 0x1146, 0x2245 ],
[ 0x4223, 0x8337, 0x2315, 0x2245, 0x1146, 0x5102 ],
[ 0x5102, 0x4113, 0x8337, 0x1326, 0x3304, 0x1146, 0x2245 ],
[ 0x4113, 0x8337, 0x1326, 0x1146, 0x2245, 0x6201 ],
[ 0x6201, 0x2315, 0x8337, 0x1326, 0x5102, 0x3304, 0x1146, 0x2245 ],
[ 0x2245, 0x2315, 0x8337, 0x1326, 0x1146 ],
#[ 0x2315, 0x2245, 0x8157 ],
[ 0, 1, 4 ],
[ 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157 ],
#[ 0x4113, 0x6201, 0x2245, 0x8157 ],
[ 0, 1, 2, 3 ],
[ 0x2245, 0x8157, 0x4113, 0x5102, 0x3304 ],
[ 0x5102, 0x4223, 0x1326, 0x2315, 0x2245, 0x8157 ],
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x2315, 0x2245, 0x8157 ],
[ 0x6201, 0x2245, 0x8157, 0x4113, 0x5102, 0x4223, 0x1326 ],
[ 0x4223, 0x1326, 0x3304, 0x2245, 0x8157, 0x4113 ],
[ 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
[ 0x8337, 0x4223, 0x6201, 0x2245, 0x8157 ],
[ 0x5102, 0x3304, 0x2245, 0x8157, 0x8337, 0x4223 ],
[ 0x5102, 0x4113, 0x8337, 0x1326, 0x2315, 0x2245, 0x8157 ],
[ 0x4113, 0x8337, 0x1326, 0x3304, 0x6201, 0x2315, 0x2245, 0x8157 ],
[ 0x5102, 0x1326, 0x8337, 0x8157, 0x2245, 0x6201 ],
[ 0x8157, 0x8337, 0x1326, 0x3304, 0x2245 ],
#[ 0x2315, 0x3304, 0x1146, 0x8157 ],
[ 0, 1, 2, 3 ],
[ 0x6201, 0x5102, 0x1146, 0x8157, 0x2315 ],
[ 0x3304, 0x1146, 0x8157, 0x4113, 0x6201 ],
#[ 0x4113, 0x5102, 0x1146, 0x8157 ],
[ 0, 1, 2, 3 ],
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x5102, 0x4223, 0x1326 ],
[ 0x1326, 0x4223, 0x6201, 0x2315, 0x8157, 0x1146 ],
[ 0x3304, 0x1146, 0x8157, 0x4113, 0x6201, 0x5102, 0x4223, 0x1326 ],
[ 0x1326, 0x1146, 0x8157, 0x4113, 0x4223 ],
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x4223, 0x4113, 0x8337 ],
[ 0x6201, 0x5102, 0x1146, 0x8157, 0x2315, 0x4223, 0x4113, 0x8337 ],
[ 0x3304, 0x1146, 0x8157, 0x8337, 0x4223, 0x6201 ],
[ 0x4223, 0x5102, 0x1146, 0x8157, 0x8337 ],
[ 0x2315, 0x3304, 0x1146, 0x8157, 0x5102, 0x4113, 0x8337, 0x1326 ],
[ 0x6201, 0x4113, 0x8337, 0x1326, 0x1146, 0x8157, 0x2315 ],
[ 0x6201, 0x3304, 0x1146, 0x8157, 0x8337, 0x1326, 0x5102 ],
#[ 0x1326, 0x1146, 0x8157, 0x8337 ],
[ 0, 1, 2, 3 ],
#[ 0x1326, 0x8267, 0x1146 ],
[ 0, 1, 4 ],
[ 0x6201, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 ],
[ 0x6201, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 ],
[ 0x5102, 0x3304, 0x2315, 0x4113, 0x1326, 0x8267, 0x1146 ],
#[ 0x5102, 0x4223, 0x8267, 0x1146 ],
[ 0, 1, 2, 3 ],
[ 0x3304, 0x6201, 0x4223, 0x8267, 0x1146 ],
[ 0x5102, 0x4223, 0x8267, 0x1146, 0x6201, 0x2315, 0x4113 ],
[ 0x1146, 0x8267, 0x4223, 0x4113, 0x2315, 0x3304 ],
[ 0x4113, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x1326, 0x8267, 0x1146 ],
[ 0x6201, 0x2315, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
[ 0x5102, 0x3304, 0x2315, 0x8337, 0x4223, 0x1326, 0x8267, 0x1146 ],
[ 0x8267, 0x1146, 0x5102, 0x4113, 0x8337 ],
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304 ],
[ 0x6201, 0x2315, 0x8337, 0x8267, 0x1146, 0x5102 ],
[ 0x1146, 0x3304, 0x2315, 0x8337, 0x8267 ],
#[ 0x3304, 0x1326, 0x8267, 0x2245 ],
[ 0, 1, 2, 3 ],
[ 0x1326, 0x8267, 0x2245, 0x6201, 0x5102 ],
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x6201, 0x2315, 0x4113 ],
[ 0x1326, 0x8267, 0x2245, 0x2315, 0x4113, 0x5102 ],
[ 0x5102, 0x4223, 0x8267, 0x2245, 0x3304 ],
#[ 0x6201, 0x4223, 0x8267, 0x2245 ],
[ 0, 1, 2, 3 ],
[ 0x5102, 0x4223, 0x8267, 0x2245, 0x3304, 0x6201, 0x2315, 0x4113 ],
[ 0x4113, 0x4223, 0x8267, 0x2245, 0x2315 ],
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x4223, 0x4113, 0x8337 ],
[ 0x1326, 0x8267, 0x2245, 0x6201, 0x5102, 0x4223, 0x4113, 0x8337 ],
[ 0x3304, 0x1326, 0x8267, 0x2245, 0x4223, 0x6201, 0x2315, 0x8337 ],
[ 0x5102, 0x1326, 0x8267, 0x2245, 0x2315, 0x8337, 0x4223 ],
[ 0x3304, 0x2245, 0x8267, 0x8337, 0x4113, 0x5102 ],
[ 0x8337, 0x8267, 0x2245, 0x6201, 0x4113 ],
[ 0x5102, 0x6201, 0x2315, 0x8337, 0x8267, 0x2245, 0x3304 ],
#[ 0x2315, 0x8337, 0x8267, 0x2245 ],
[ 0, 1, 2, 3 ],
[ 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
[ 0x6201, 0x5102, 0x3304, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
[ 0x6201, 0x2245, 0x8157, 0x4113, 0x1326, 0x8267, 0x1146 ],
[ 0x2245, 0x8157, 0x4113, 0x5102, 0x3304, 0x1326, 0x8267, 0x1146 ],
[ 0x4223, 0x8267, 0x1146, 0x5102, 0x2315, 0x2245, 0x8157 ],
[ 0x3304, 0x6201, 0x4223, 0x8267, 0x1146, 0x2315, 0x2245, 0x8157 ],
[ 0x4223, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157, 0x4113 ],
[ 0x3304, 0x2245, 0x8157, 0x4113, 0x4223, 0x8267, 0x1146 ],
[ 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
[ 0x6201, 0x5102, 0x3304, 0x4223, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
[ 0x8337, 0x4223, 0x6201, 0x2245, 0x8157, 0x1326, 0x8267, 0x1146 ],
[ 0x4223, 0x5102, 0x3304, 0x2245, 0x8157, 0x8337, 0x1326, 0x8267, 0x1146 ],
[ 0x8267, 0x1146, 0x5102, 0x4113, 0x8337, 0x2315, 0x2245, 0x8157 ],
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x1146, 0x3304, 0x2315, 0x2245, 0x8157 ],
[ 0x8337, 0x8267, 0x1146, 0x5102, 0x6201, 0x2245, 0x8157 ],
[ 0x3304, 0x2245, 0x8157, 0x8337, 0x8267, 0x1146 ],
[ 0x8157, 0x2315, 0x3304, 0x1326, 0x8267 ],
[ 0x8267, 0x8157, 0x2315, 0x6201, 0x5102, 0x1326 ],
[ 0x8267, 0x1326, 0x3304, 0x6201, 0x4113, 0x8157 ],
[ 0x8267, 0x8157, 0x4113, 0x5102, 0x1326 ],
[ 0x5102, 0x4223, 0x8267, 0x8157, 0x2315, 0x3304 ],
[ 0x2315, 0x6201, 0x4223, 0x8267, 0x8157 ],
[ 0x3304, 0x5102, 0x4223, 0x8267, 0x8157, 0x4113, 0x6201 ],
#[ 0x4113, 0x4223, 0x8267, 0x8157 ],
[ 0, 1, 2, 3 ],
[ 0x8157, 0x2315, 0x3304, 0x1326, 0x8267, 0x4223, 0x4113, 0x8337 ],
[ 0x8157, 0x2315, 0x6201, 0x5102, 0x1326, 0x8267, 0x4223, 0x4113, 0x8337 ],
[ 0x8157, 0x8337, 0x4223, 0x6201, 0x3304, 0x1326, 0x8267 ],
[ 0x5102, 0x1326, 0x8267, 0x8157, 0x8337, 0x4223 ],
[ 0x8267, 0x8157, 0x2315, 0x3304, 0x5102, 0x4113, 0x8337 ],
[ 0x6201, 0x4113, 0x8337, 0x8267, 0x8157, 0x2315 ],
[ 0x6201, 0x3304, 0x5102, 0x8337, 0x8267, 0x8157 ],
#[ 0x8337, 0x8267, 0x8157 ],
#[ 0x8337, 0x8157, 0x8267 ],
[ 0, 1, 4 ],
[ 0, 1, 4 ],
[ 0x6201, 0x5102, 0x3304, 0x8337, 0x8157, 0x8267 ],
[ 0x6201, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
[ 0x5102, 0x3304, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
[ 0x5102, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x8337, 0x8157, 0x8267 ],
[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
[ 0x4223, 0x1326, 0x3304, 0x2315, 0x4113, 0x8337, 0x8157, 0x8267 ],
#[ 0x4113, 0x8157, 0x8267, 0x4223 ],
[ 0, 1, 2, 3 ],
[ 0x4223, 0x4113, 0x8157, 0x8267, 0x6201, 0x5102, 0x3304 ],
[ 0x8157, 0x8267, 0x4223, 0x6201, 0x2315 ],
[ 0x3304, 0x2315, 0x8157, 0x8267, 0x4223, 0x5102 ],
[ 0x1326, 0x5102, 0x4113, 0x8157, 0x8267 ],
[ 0x8157, 0x4113, 0x6201, 0x3304, 0x1326, 0x8267 ],
[ 0x1326, 0x5102, 0x6201, 0x2315, 0x8157, 0x8267 ],
[ 0x8267, 0x1326, 0x3304, 0x2315, 0x8157 ],
[ 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
[ 0x6201, 0x2315, 0x4113, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
[ 0x2315, 0x4113, 0x5102, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
[ 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
[ 0x1146, 0x2245, 0x6201, 0x4223, 0x1326, 0x8337, 0x8157, 0x8267 ],
[ 0x6201, 0x2315, 0x4113, 0x5102, 0x4223, 0x1326, 0x3304, 0x1146, 0x2245, 0x8337, 0x8157, 0x8267 ],
[ 0x4113, 0x4223, 0x1326, 0x1146, 0x2245, 0x2315, 0x8337, 0x8157, 0x8267 ],
[ 0x4223, 0x4113, 0x8157, 0x8267, 0x3304, 0x1146, 0x2245 ],
[ 0x6201, 0x5102, 0x1146, 0x2245, 0x4223, 0x4113, 0x8157, 0x8267 ],
[ 0x8157, 0x8267, 0x4223, 0x6201, 0x2315, 0x3304, 0x1146, 0x2245 ],
[ 0x2315, 0x8157, 0x8267, 0x4223, 0x5102, 0x1146, 0x2245 ],
[ 0x1326, 0x5102, 0x4113, 0x8157, 0x8267, 0x3304, 0x1146, 0x2245 ],
[ 0x1326, 0x1146, 0x2245, 0x6201, 0x4113, 0x8157, 0x8267 ],
[ 0x5102, 0x6201, 0x2315, 0x8157, 0x8267, 0x1326, 0x3304, 0x1146, 0x2245 ],
[ 0x1326, 0x1146, 0x2245, 0x2315, 0x8157, 0x8267 ],
#[ 0x2315, 0x2245, 0x8267, 0x8337 ],
[ 0, 1, 2, 3 ],
[ 0x2315, 0x2245, 0x8267, 0x8337, 0x6201, 0x5102, 0x3304 ],
[ 0x4113, 0x6201, 0x2245, 0x8267, 0x8337 ],
[ 0x5102, 0x4113, 0x8337, 0x8267, 0x2245, 0x3304 ],
[ 0x2315, 0x2245, 0x8267, 0x8337, 0x5102, 0x4223, 0x1326 ],
[ 0x6201, 0x4223, 0x1326, 0x3304, 0x8337, 0x2315, 0x2245, 0x8267 ],
[ 0x4113, 0x6201, 0x2245, 0x8267, 0x8337, 0x5102, 0x4223, 0x1326 ],
[ 0x4113, 0x4223, 0x1326, 0x3304, 0x2245, 0x8267, 0x8337 ],
[ 0x2315, 0x2245, 0x8267, 0x4223, 0x4113 ],
[ 0x2315, 0x2245, 0x8267, 0x4223, 0x4113, 0x6201, 0x5102, 0x3304 ],
#[ 0x6201, 0x2245, 0x8267, 0x4223 ],
[ 0, 1, 2, 3 ],
[ 0x3304, 0x2245, 0x8267, 0x4223, 0x5102 ],
[ 0x5102, 0x4113, 0x2315, 0x2245, 0x8267, 0x1326 ],
[ 0x4113, 0x2315, 0x2245, 0x8267, 0x1326, 0x3304, 0x6201 ],
[ 0x5102, 0x6201, 0x2245, 0x8267, 0x1326 ],
#[ 0x3304, 0x2245, 0x8267, 0x1326 ],
[ 0, 1, 2, 3 ],
[ 0x8267, 0x8337, 0x2315, 0x3304, 0x1146 ],
[ 0x5102, 0x1146, 0x8267, 0x8337, 0x2315, 0x6201 ],
[ 0x3304, 0x1146, 0x8267, 0x8337, 0x4113, 0x6201 ],
[ 0x8337, 0x4113, 0x5102, 0x1146, 0x8267 ],
[ 0x8267, 0x8337, 0x2315, 0x3304, 0x1146, 0x5102, 0x4223, 0x1326 ],
[ 0x1146, 0x8267, 0x8337, 0x2315, 0x6201, 0x4223, 0x1326 ],
[ 0x8267, 0x8337, 0x4113, 0x6201, 0x3304, 0x1146, 0x5102, 0x4223, 0x1326 ],
[ 0x4113, 0x4223, 0x1326, 0x1146, 0x8267, 0x8337 ],
[ 0x3304, 0x2315, 0x4113, 0x4223, 0x8267, 0x1146 ],
[ 0x2315, 0x6201, 0x5102, 0x1146, 0x8267, 0x4223, 0x4113 ],
[ 0x1146, 0x8267, 0x4223, 0x6201, 0x3304 ],
#[ 0x5102, 0x1146, 0x8267, 0x4223 ],
[ 0, 1, 2, 3 ],
[ 0x8267, 0x1326, 0x5102, 0x4113, 0x2315, 0x3304, 0x1146 ],
[ 0x6201, 0x4113, 0x2315, 0x1326, 0x1146, 0x8267 ],
[ 0x6201, 0x3304, 0x1146, 0x8267, 0x1326, 0x5102 ],
#[ 0x1326, 0x1146, 0x8267 ],
[ 0, 1, 4 ],
#[ 0x1326, 0x8337, 0x8157, 0x1146 ],
[ 0, 1, 2, 3 ],
[ 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 ],
[ 0x8337, 0x8157, 0x1146, 0x1326, 0x6201, 0x2315, 0x4113 ],
[ 0x4113, 0x5102, 0x3304, 0x2315, 0x1326, 0x8337, 0x8157, 0x1146 ],
[ 0x8337, 0x8157, 0x1146, 0x5102, 0x4223 ],
[ 0x6201, 0x4223, 0x8337, 0x8157, 0x1146, 0x3304 ],
[ 0x8337, 0x8157, 0x1146, 0x5102, 0x4223, 0x6201, 0x2315, 0x4113 ],
[ 0x4223, 0x8337, 0x8157, 0x1146, 0x3304, 0x2315, 0x4113 ],
[ 0x4223, 0x4113, 0x8157, 0x1146, 0x1326 ],
[ 0x4223, 0x4113, 0x8157, 0x1146, 0x1326, 0x6201, 0x5102, 0x3304 ],
[ 0x1146, 0x8157, 0x2315, 0x6201, 0x4223, 0x1326 ],
[ 0x4223, 0x5102, 0x3304, 0x2315, 0x8157, 0x1146, 0x1326 ],
#[ 0x4113, 0x8157, 0x1146, 0x5102 ],
[ 0, 1, 2, 3 ],
[ 0x6201, 0x4113, 0x8157, 0x1146, 0x3304 ],
[ 0x2315, 0x8157, 0x1146, 0x5102, 0x6201 ],
#[ 0x2315, 0x8157, 0x1146, 0x3304 ],
[ 0, 1, 2, 3 ],
[ 0x2245, 0x3304, 0x1326, 0x8337, 0x8157 ],
[ 0x6201, 0x2245, 0x8157, 0x8337, 0x1326, 0x5102 ],
[ 0x2245, 0x3304, 0x1326, 0x8337, 0x8157, 0x6201, 0x2315, 0x4113 ],
[ 0x2245, 0x2315, 0x4113, 0x5102, 0x1326, 0x8337, 0x8157 ],
[ 0x4223, 0x8337, 0x8157, 0x2245, 0x3304, 0x5102 ],
[ 0x8157, 0x2245, 0x6201, 0x4223, 0x8337 ],
[ 0x2245, 0x3304, 0x5102, 0x4223, 0x8337, 0x8157, 0x4113, 0x6201, 0x2315 ],
[ 0x4223, 0x8337, 0x8157, 0x2245, 0x2315, 0x4113 ],
[ 0x4113, 0x8157, 0x2245, 0x3304, 0x1326, 0x4223 ],
[ 0x1326, 0x4223, 0x4113, 0x8157, 0x2245, 0x6201, 0x5102 ],
[ 0x8157, 0x2245, 0x3304, 0x1326, 0x4223, 0x6201, 0x2315 ],
[ 0x5102, 0x1326, 0x4223, 0x2315, 0x8157, 0x2245 ],
[ 0x3304, 0x5102, 0x4113, 0x8157, 0x2245 ],
#[ 0x4113, 0x8157, 0x2245, 0x6201 ],
[ 0, 1, 2, 3 ],
[ 0x5102, 0x6201, 0x2315, 0x8157, 0x2245, 0x3304 ],
#[ 0x2315, 0x8157, 0x2245 ],
[ 0, 1, 4 ],
[ 0x1146, 0x1326, 0x8337, 0x2315, 0x2245 ],
[ 0x1146, 0x1326, 0x8337, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304 ],
[ 0x6201, 0x2245, 0x1146, 0x1326, 0x8337, 0x4113 ],
[ 0x2245, 0x1146, 0x1326, 0x8337, 0x4113, 0x5102, 0x3304 ],
[ 0x5102, 0x1146, 0x2245, 0x2315, 0x8337, 0x4223 ],
[ 0x1146, 0x3304, 0x6201, 0x4223, 0x8337, 0x2315, 0x2245 ],
[ 0x8337, 0x4113, 0x6201, 0x2245, 0x1146, 0x5102, 0x4223 ],
[ 0x4223, 0x8337, 0x4113, 0x3304, 0x2245, 0x1146 ],
[ 0x4113, 0x2315, 0x2245, 0x1146, 0x1326, 0x4223 ],
[ 0x1146, 0x1326, 0x4223, 0x4113, 0x2315, 0x2245, 0x6201, 0x5102, 0x3304 ],
[ 0x1326, 0x4223, 0x6201, 0x2245, 0x1146 ],
[ 0x4223, 0x5102, 0x3304, 0x2245, 0x1146, 0x1326 ],
[ 0x2245, 0x1146, 0x5102, 0x4113, 0x2315 ],
[ 0x4113, 0x2315, 0x2245, 0x1146, 0x3304, 0x6201 ],
#[ 0x6201, 0x2245, 0x1146, 0x5102 ],
[ 0, 1, 2, 3 ],
#[ 0x3304, 0x2245, 0x1146 ],
[ 0, 1, 4 ],
#[ 0x3304, 0x1326, 0x8337, 0x2315 ],
[ 0, 1, 2, 3 ],
[ 0x5102, 0x1326, 0x8337, 0x2315, 0x6201 ],
[ 0x6201, 0x3304, 0x1326, 0x8337, 0x4113 ],
#[ 0x5102, 0x1326, 0x8337, 0x4113 ],
[ 0, 1, 2, 3 ],
[ 0x4223, 0x8337, 0x2315, 0x3304, 0x5102 ],
#[ 0x6201, 0x4223, 0x8337, 0x2315 ],
[ 0, 1, 2, 3 ],
[ 0x3304, 0x5102, 0x4223, 0x8337, 0x4113, 0x6201 ],
#[ 0x4113, 0x4223, 0x8337 ],
[ 0, 1, 4 ],
[ 0x4113, 0x2315, 0x3304, 0x1326, 0x4223 ],
[ 0x1326, 0x4223, 0x4113, 0x2315, 0x6201, 0x5102 ],
#[ 0x3304, 0x1326, 0x4223, 0x6201 ],
[ 0, 1, 2, 3 ],
#[ 0x5102, 0x1326, 0x4223 ],
[ 0, 1, 4 ],
#[ 0x5102, 0x4113, 0x2315, 0x3304 ],
[ 0, 1, 2, 3 ],
#[ 0x6201, 0x4113, 0x2315 ],
[ 0, 1, 4 ],
#[ 0x6201, 0x3304, 0x5102 ],
[ 0, 1, 4 ],
[]
]
func get_case_code(buffer : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
var case_code : int = 0
if (buffer.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_000
if (buffer.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_010
if (buffer.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_001
if (buffer.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_011
if (buffer.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_100
if (buffer.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_110
if (buffer.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_101
if (buffer.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_111
return case_code
func _add_chunk(buffer : VoxelChunk) -> void:
var x_size : int = buffer.get_size_x() - 1
var y_size : int = buffer.get_size_y() - 1
var z_size : int = buffer.get_size_z() - 1
var lod_size : int = 1
for y in range(0, y_size, lod_size):
for z in range(0, z_size, lod_size):
for x in range(0, x_size, lod_size):
var case_code : int = get_case_code(buffer, x, y, z, lod_size)
if case_code == 0 or case_code == 255:
continue
var regular_cell_class : int = get_regular_cell_class(case_code)
var cell_data : MarchingCubesCellData = get_regular_cell_data(regular_cell_class)
var index_count : int = cell_data.get_triangle_count() * 3
var vertex_count : int = cell_data.get_vertex_count()
var uvs : Array = regular_uv_data[case_code]
for i in range(index_count):
var ind : int = get_vertex_count() + cell_data.get_vertex_index(i)
add_indices(ind)
for i in range(vertex_count):
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
var sv : int = get_regular_vertex_data_second_vertex(case_code, i)
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
var type0 : int = buffer.get_voxel(x + offs0.x, y + offs0.y, z + offs0.z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
var type1 : int = buffer.get_voxel(x + offs1.x, y + offs1.y, z + offs1.z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
var fill : int = 0
var vert_pos : Vector3
var vert_dir : Vector3
if type0 == 0:
fill = buffer.get_voxel(x + offs1.x, y + offs1.y, z + offs1.z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
vert_pos = get_regular_vertex_second_position(case_code, i)
vert_dir = get_regular_vertex_first_position(case_code, i)
else:
fill = buffer.get_voxel(x + offs0.x, y + offs0.y, z + offs0.z, VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
vert_pos = get_regular_vertex_first_position(case_code, i)
vert_dir = get_regular_vertex_second_position(case_code, i)
vert_dir = vert_dir - vert_pos
vert_pos += vert_dir * (fill / 256.0)
vert_pos *= float(lod_size)
vert_pos += Vector3(x, y, z)
vert_pos *= float(voxel_scale)
if regular_uv_entries.size() > uvs[i]:
add_uv(Vector2(regular_uv_entries[uvs[i]][0], regular_uv_entries[uvs[i]][1]));
add_uv(Vector2(0, 0))
add_vertex(vert_pos)
func create_Debug_triangle(position : Vector3):
add_indices(get_indices_count())
add_vertex(position)
add_indices(get_indices_count())
add_vertex(position + Vector3(2, 0, 0))
add_indices(get_indices_count())
add_vertex(position + Vector3(0, 0, 2))
print(get_vertex_count())

View File

@ -1,233 +0,0 @@
tool
extends VoxelChunkMarchingCubes
class_name TVVoxelChunk
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# 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.
var _prop_texture_packer : TexturePacker
var _textures : Array
var _prop_material : SpatialMaterial
var _entities_spawned : bool
var _prop_mesh_instance_rid : RID
var _prop_mesh_rid : RID
#func _init():
# add_mesh_data_resource(get_transform().scaled(Vector3(10, 10, 10)), ResourceLoader.load("res://modules/species/Human/Female/character_models/huf_calf_left.gltf"))
# add_mesh_data_resource(get_transform().translated(Vector3(0, 4, 0)), ResourceLoader.load("res://modules/species/Human/Female/character_models/huf_calf_left.gltf"))
#func _init():
# _prop_texture_packer = TexturePacker.new()
# _prop_texture_packer.max_atlas_size = 1024
# _prop_texture_packer.margin = 1
# _prop_texture_packer.background_color = Color(0, 0, 0, 1)
# _prop_texture_packer.texture_flags = Texture.FLAG_MIPMAPS
func _create_meshers():
var tj : VoxelTerrarinJob = VoxelTerrarinJob.new()
var lj : VoxelLightJob = VoxelLightJob.new()
var pj : VoxelPropJob = VoxelPropJob.new()
var prop_mesher = TVVoxelMesher.new()
prop_mesher.base_light_value = 0.45
prop_mesher.ao_strength = 0.2
prop_mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
prop_mesher.voxel_scale = voxel_scale
prop_mesher.build_flags = build_flags
prop_mesher.texture_scale = 3
pj.set_prop_mesher(prop_mesher);
var mesher : TVVoxelMesher = TVVoxelMesher.new()
mesher.base_light_value = 0.45
mesher.ao_strength = 0.2
mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
mesher.voxel_scale = voxel_scale
mesher.build_flags = build_flags
mesher.texture_scale = 3
mesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_TYPE
mesher.channel_index_isolevel = VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL
tj.add_mesher(mesher)
var cmesher : VoxelMesherBlocky = VoxelMesherBlocky.new()
cmesher.texture_scale = 3
cmesher.base_light_value = 0.45
cmesher.ao_strength = 0.2
cmesher.voxel_scale = voxel_scale
cmesher.build_flags = build_flags
if cmesher.build_flags & VoxelChunkDefault.BUILD_FLAG_USE_LIGHTING != 0:
cmesher.build_flags = cmesher.build_flags ^ VoxelChunkDefault.BUILD_FLAG_USE_LIGHTING
cmesher.always_add_colors = true
# cmesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_TYPE
cmesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE
tj.add_mesher(cmesher)
_prop_texture_packer = TexturePacker.new()
_prop_texture_packer.max_atlas_size = 1024
_prop_texture_packer.margin = 1
_prop_texture_packer.background_color = Color(0, 0, 0, 1)
_prop_texture_packer.texture_flags = Texture.FLAG_MIPMAPS
job_add(lj)
job_add(tj)
job_add(pj)
#func _build_phase(phase):
# if phase == VoxelChunkDefault.BUILD_PHASE_SETUP:
# ._build_phase(phase)
#
# elif phase == VoxelChunkDefault.BUILD_PHASE_LIGHTS:
# clear_baked_lights()
# generate_random_ao(123)
# bake_lights()
#
# next_phase()
#set_physics_process_internal(true)
# active_build_phase_type = VoxelChunkDefault.BUILD_PHASE_TYPE_PHYSICS_PROCESS
# return
# elif phase == VoxelChunkDefault.BUILD_PHASE_TERRARIN_MESH:
# for i in range(get_mesher_count()):
# var mesher : VoxelMesher = get_mesher(i)
# mesher.bake_colors(self)
#
# for i in range(get_mesher_count()):
# var mesher : VoxelMesher = get_mesher(i)
# mesher.set_library(library)
#
# var mesh_rid : RID = get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 0)
#
# if mesh_rid == RID():
# create_meshes(MESH_INDEX_TERRARIN, lod_num + 1)
# mesh_rid = get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 0)
#
# var mesher : VoxelMesher = null
# for i in range(get_mesher_count()):
# var m : VoxelMesher = get_mesher(i)
#
# if mesher == null:
# mesher = m
# continue
#
# mesher.set_material(library.material)
# mesher.add_mesher(m)
#
# if (mesh_rid != RID()):
# VisualServer.mesh_clear(mesh_rid)
#
# if mesher.get_vertex_count() == 0:
# next_phase()
# return true
#
# if (mesh_rid == RID()):
# create_meshes(MESH_INDEX_TERRARIN, lod_num + 1)
# mesh_rid = get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 0)
#
# var arr : Array = mesher.build_mesh()
#
# VisualServer.mesh_add_surface_from_arrays(mesh_rid, VisualServer.PRIMITIVE_TRIANGLES, arr)
#
# if library.get_material(0) != null:
# VisualServer.mesh_surface_set_material(mesh_rid, 0, library.get_material(0).get_rid())
#
## VisualServer.instance_set_visible(get_mesh_instance_rid(), false)
#
# if generate_lod and lod_num >= 1:
# #for lod 1 just remove uv2
#
# arr[VisualServer.ARRAY_TEX_UV2] = null
#
# VisualServer.mesh_add_surface_from_arrays(get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 1), VisualServer.PRIMITIVE_TRIANGLES, arr)
#
# if library.get_material(1) != null:
# VisualServer.mesh_surface_set_material(get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 1), 0, library.get_material(1).get_rid())
#
# if lod_num >= 2:
# arr = merge_mesh_array(arr)
#
# VisualServer.mesh_add_surface_from_arrays(get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 2), VisualServer.PRIMITIVE_TRIANGLES, arr)
#
# if library.get_material(2) != null:
# VisualServer.mesh_surface_set_material(get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 2), 0, library.get_material(2).get_rid())
#
# if lod_num >= 3:
# var mat : ShaderMaterial = library.get_material(0) as ShaderMaterial
# var tex : Texture = mat.get_shader_param("texture_albedo")
#
# arr = bake_mesh_array_uv(arr, tex)
# arr[VisualServer.ARRAY_TEX_UV] = null
#
# VisualServer.mesh_add_surface_from_arrays(get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 3), VisualServer.PRIMITIVE_TRIANGLES, arr)
#
# if library.get_material(3) != null:
# VisualServer.mesh_surface_set_material(get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 3), 0, library.get_material(3).get_rid())
## if lod_num > 4:
## var fqms : FastQuadraticMeshSimplifier = FastQuadraticMeshSimplifier.new()
## fqms.initialize(merged)
##
## var arr_merged_simplified : Array = merged
#
## for i in range(2, _lod_meshes.size()):
## fqms.simplify_mesh(arr_merged_simplified[0].size() * 0.8, 7)
## arr_merged_simplified = fqms.get_arrays()
#
## if arr_merged_simplified[0].size() == 0:
## break
#
## VisualServer.mesh_add_surface_from_arrays(_lod_meshes[i], VisualServer.PRIMITIVE_TRIANGLES, arr_merged_simplified)
#
## if library.get_material(i) != null:
## VisualServer.mesh_surface_set_material(_lod_meshes[i], 0, library.get_material(i).get_rid())
#
# next_phase();
#
# return
# else:
# ._build_phase(phase)
#func _build_phase(phase):
# if phase == VoxelChunkDefault.BUILD_PHASE_COLLIDER:
# active_build_phase_type = VoxelChunkDefault.BUILD_PHASE_TYPE_PHYSICS_PROCESS
# return
# elif phase == VoxelChunkDefault.BUILD_PHASE_PROP_MESH:
# next_phase()
# return
#
# ._build_phase(phase)
#func _build_phase_physics_process(phase):
# if phase == VoxelChunkDefault.BUILD_PHASE_PROP_SETUP:
## add_prop(ResourceLoader.load("res://prop_tool/ToolTes2at.tres"))
# build_phase_prop_mesh()
# active_build_phase_type = VoxelChunkDefault.BUILD_PHASE_TYPE_NORMAL
# next_phase()
# return
#
# ._build_phase_physics_process(phase)
#

View File

@ -1,360 +0,0 @@
extends VoxelMesherMarchingCubes
class_name TVVoxelMesher
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# 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.
const TEXTURE_SCALE = 4
func get_voxel_type_array(chunk : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> Array:
var arr : Array = [
chunk.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE),
chunk.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
]
return arr
func get_case_code_from_arr(data : Array) -> int:
var case_code : int = 0
if (data[0] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_000
if (data[1] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_010
if (data[2] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_001
if (data[3] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_011
if (data[4] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_100
if (data[5] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_110
if (data[6] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_101
if (data[7] != 0):
case_code = case_code | VOXEL_ENTRY_MASK_111
return case_code
func get_case_code(chunk : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
var case_code : int = 0
if (chunk.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_000
if (chunk.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_010
if (chunk.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_001
if (chunk.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_011
if (chunk.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_100
if (chunk.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_110
if (chunk.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_101
if (chunk.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE) != 0):
case_code = case_code | VOXEL_ENTRY_MASK_111
return case_code
func get_voxel_type(chunk : VoxelChunk, x : int, y : int, z : int, size : int = 1) -> int:
var type : int = 0
type = chunk.get_voxel(x, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x + size, y + size, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x + size, y + size, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x + size, y, z, VoxelChunk.DEFAULT_CHANNEL_TYPE)
if type != 0:
return type
type = chunk.get_voxel(x + size, y, z + size, VoxelChunk.DEFAULT_CHANNEL_TYPE)
return type
func n_add_chunk(chunk : VoxelChunk) -> void:
chunk.generate_ao()
var lod_size : int = 1
var x_size : int = chunk.get_size_x()
var y_size : int = chunk.get_size_y()
var z_size : int = chunk.get_size_z()
for y in range(0, y_size, lod_size):
for z in range(0, z_size, lod_size):
for x in range(0, x_size, lod_size):
var type_arr : Array = get_voxel_type_array(chunk, x, y, z, lod_size)
var case_code : int = get_case_code_from_arr(type_arr)
if case_code == 0 or case_code == 255:
continue
var regular_cell_class : int = get_regular_cell_class(case_code)
var cell_data : MarchingCubesCellData = get_regular_cell_data(regular_cell_class)
var index_count : int = cell_data.get_triangle_count() * 3
var vertex_count : int = cell_data.get_vertex_count()
for i in range(index_count):
var ind : int = get_vertex_count() + cell_data.get_vertex_index(i)
add_indices(ind)
var temp_verts : Array = Array()
var carr : Dictionary = Dictionary()
for t in type_arr:
if carr.has(t):
carr[t] += 1
else:
carr[t] = 1
var type_id1 : int = -1
var type_id1c : int = -1
var type_id2 : int = -1
var type_id2c : int = -1
for k in carr.keys():
if k == 0:
continue
var c : int = carr[k]
if type_id1c == -1:
type_id1 = k
type_id1c = c
continue
if c > type_id1c:
type_id1 = k
type_id1c = c
for k in carr.keys():
if k == 0:
continue
var c : int = carr[k]
if type_id2c == -1:
type_id2 = k
type_id2c = c
continue
if c > type_id2c and k != type_id1:
type_id2 = k
type_id2c = c
var surface_ratio : float = 1
if type_id1 != type_id2:
surface_ratio = float(type_id1c) / float(type_id2c) / 8.0
var surface1 : VoxelSurface = library.get_voxel_surface(type_id1)
var surface2 : VoxelSurface = library.get_voxel_surface(type_id2)
# if type_id1 == 0:
# print(type_id1)
#
# if type_id2 == 0:
# print("asd" + str(type_id2))
for i in range(vertex_count):
var fv : int = get_regular_vertex_data_first_vertex(case_code, i)
var sv : int = get_regular_vertex_data_second_vertex(case_code, i)
var offs0 : Vector3 = corner_id_to_vertex(fv) * lod_size
var offs1 : Vector3 = corner_id_to_vertex(sv) * lod_size
var type : int = chunk.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_TYPE)
var fill : int = 0
var vert_pos : Vector3
var vert_dir : Vector3
if type == 0:
fill = chunk.get_voxel(int(x + offs1.x), int(y + offs1.y), int(z + offs1.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
vert_pos = get_regular_vertex_second_position(case_code, i)
vert_dir = get_regular_vertex_first_position(case_code, i)
else:
fill = chunk.get_voxel(int(x + offs0.x), int(y + offs0.y), int(z + offs0.z), VoxelChunk.DEFAULT_CHANNEL_ISOLEVEL)
vert_pos = get_regular_vertex_first_position(case_code, i)
vert_dir = get_regular_vertex_second_position(case_code, i)
vert_dir = vert_dir - vert_pos
vert_pos += vert_dir * (fill / 256.0)
temp_verts.append(vert_pos)
var temp_normals : Array = Array()
#warning-ignore:unused_variable
for i in range(len(temp_verts)):
temp_normals.append(Vector3())
#generate normals
for i in range(0, index_count, 3):
var indices : Array = [
cell_data.get_vertex_index(i),
cell_data.get_vertex_index(i + 1),
cell_data.get_vertex_index(i + 2)
]
var vertices : Array = [
temp_verts[indices[0]],
temp_verts[indices[1]],
temp_verts[indices[2]],
]
temp_normals[indices[0]] += (vertices[1] - vertices[0]).cross(vertices[0] - vertices[2])
temp_normals[indices[1]] += (vertices[2] - vertices[1]).cross(vertices[1] - vertices[0])
temp_normals[indices[2]] += (vertices[2] - vertices[1]).cross(vertices[2] - vertices[0])
for i in range(len(temp_verts)):
temp_normals[i] = (temp_normals[i] as Vector3).normalized()
for cvi in range(len(temp_verts)):
var vertex : Vector3 = temp_verts[cvi]
var normal : Vector3 = temp_normals[cvi]
var s : Vector3 = Vector3()
var t : Vector3 = Vector3()
t.x = vertex.z
t.y = vertex.z
t.z = vertex.y
s.x = vertex.y
s.y = vertex.x
s.z = vertex.x
var bx : float = abs(normal.x)
var by : float = abs(normal.y)
var bz : float = abs(normal.z)
if (bx + 0.0001 > by and bx + 0.0001 > bz):
var uv : Vector2 = Vector2(s.x, t.x)
var umargin : Rect2 = uv_margin
uv.x *= umargin.size.x
uv.y *= umargin.size.y
uv.x += umargin.position.x
uv.y += umargin.position.y
add_uv(surface1.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
add_uv2(surface2.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
elif (bz + 0.0001 > bx and bz + 0.0001 > by):
var uv : Vector2 = Vector2(s.z, t.z)
var umargin : Rect2 = uv_margin
uv.x *= umargin.size.x
uv.y *= umargin.size.y
uv.x += umargin.position.x
uv.y += umargin.position.y
add_uv(surface1.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
add_uv2(surface2.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_SIDE, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
else:
var uv : Vector2 = Vector2(s.y, t.y)
var umargin : Rect2 = uv_margin
uv.x *= umargin.size.x
uv.y *= umargin.size.y
uv.x += umargin.position.x
uv.y += umargin.position.y
add_uv(surface1.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_TOP, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
add_uv2(surface2.transform_uv_scaled(VoxelSurface.VOXEL_SIDE_TOP, uv, x % TEXTURE_SCALE, z % TEXTURE_SCALE, TEXTURE_SCALE))
for i in range(len(temp_verts)):
var vert_pos : Vector3 = temp_verts[i] as Vector3
vert_pos *= float(lod_size)
vert_pos += Vector3(x, y, z)
var normal : Vector3 = temp_normals[i] as Vector3
#var vpx : int = int(vert_pos.x)
#var vpy : int = int(vert_pos.y)
#var vpz : int = int(vert_pos.z)
add_color(Color(1, 1, 1, surface_ratio))
vert_pos *= float(voxel_scale)
add_normal(normal)
add_vertex(vert_pos)

View File

@ -1,350 +0,0 @@
tool
extends VoxelWorldDefault
# Copyright Péter Magyar relintai@gmail.com
# MIT License, might be merged into the Voxelman engine module
# 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(Array, MeshDataResource) var meshes : Array
export(bool) var editor_generate : bool = false setget set_editor_generate, get_editor_generate
export(bool) var show_loading_screen : bool = true
export(bool) var generate_on_ready : bool = false
export(int) var spawn_height : int = 5
export(bool) var use_global_chunk_settings : bool = true
export(PropData) var test_prop : PropData
var mob_level : int = 1
var initial_generation : bool = true
var spawned : bool = false
var _editor_generate : bool
var _player_file_name : String
var _player : Entity
const VIS_UPDATE_INTERVAL = 5
var vis_update : float = 0
var _max_frame_chunk_build_temp : int
var rc : int = 0
func _enter_tree():
if !Engine.is_editor_hint() && use_global_chunk_settings:
Settings.connect("setting_changed", self, "on_setting_changed")
Settings.connect("settings_loaded", self, "on_settings_loaded")
if Settings.loaded:
on_settings_loaded()
if generate_on_ready and not Engine.is_editor_hint():
# call_deferred("generate")
generate()
func on_setting_changed(section, key, value):
if section == "game":
if key == "chunk_spawn_range":
chunk_spawn_range = value
if key == "chunk_lod_falloff":
chunk_lod_falloff = value
func on_settings_loaded():
chunk_spawn_range = Settings.get_value("game", "chunk_spawn_range")
chunk_lod_falloff = Settings.get_value("game", "chunk_lod_falloff")
vis_update += VIS_UPDATE_INTERVAL
func generate():
if level_generator != null:
level_generator.setup(self, 80, false, library)
spawn(0, 0, 0)
func _process(delta):
if initial_generation:
return
if _player == null:
set_process(false)
return
vis_update += delta
if vis_update >= VIS_UPDATE_INTERVAL:
vis_update = 0
var ppos : Vector3 = _player.get_body_3d().transform.origin
var cpos : Vector3 = ppos
var ppx : int = int(cpos.x / (chunk_size_x * voxel_scale))
var ppy : int = int(cpos.y / (chunk_size_y * voxel_scale))
var ppz : int = int(cpos.z / (chunk_size_z * voxel_scale))
cpos.x = ppx
cpos.y = ppy
cpos.z = ppz
var count : int = chunk_get_count()
var i : int = 0
while i < count:
var c : VoxelChunk = chunk_get_index(i)
var l : float = (Vector2(cpos.x, cpos.z) - Vector2(c.position_x, c.position_z)).length()
if l > chunk_spawn_range + 3:
# print("despawn " + str(Vector3(c.position_x, c.position_y, c.position_z)))
chunk_remove_index(i)
i -= 1
count -= 1
# else:
# var dx : int = abs(ppx - c.position_x)
# var dy : int = abs(ppy - c.position_y)
# var dz : int = abs(ppz - c.position_z)
#
# var mr : int = max(max(dx, dy), dz)
#
# if mr <= 1:
# c.current_lod_level = 0
# elif mr == 2:
# c.current_lod_level = 1
# elif mr == 3:# or mr == 4:
# c.current_lod_level = 2
# else:
# c.current_lod_level = 3
i += 1
for x in range(int(cpos.x) - chunk_spawn_range, chunk_spawn_range + int(cpos.x)):
for z in range(int(cpos.z) - chunk_spawn_range, chunk_spawn_range + int(cpos.z)):
var l : float = (Vector2(cpos.x, cpos.z) - Vector2(x, z)).length()
if l > chunk_spawn_range:
continue
for y in range(-1 + cpos.y, spawn_height + cpos.y):
if not chunk_has(x, y, z):
# print("spawn " + str(Vector3(x, y, z)))
chunk_create(x, y, z)
update_lods()
#func _process(delta : float) -> void:
# if not generation_queue.empty():
# var chunk : VoxelChunk = generation_queue.front()
# refresh_chunk_lod_level_data(chunk)
# level_generator.generate_chunk(chunk)
# generation_queue.remove(0)
#
# if generation_queue.empty():
# emit_signal("generation_finished")
# initial_generation = false
#
# if show_loading_screen and not Engine.editor_hint:
# get_node("..").hide_loading_screen()
func _generation_finished():
if not Engine.editor_hint:
max_frame_chunk_build_steps = _max_frame_chunk_build_temp
initial_generation = false
# for i in range(get_chunk_count()):
# get_chunk_index(i).draw_debug_voxels(555555)
if show_loading_screen and not Engine.editor_hint:
get_node("..").hide_loading_screen()
#TODO hack, do this properly
if _player:
_player.set_physics_process(true)
func get_chunk_lod_level(x : int, y : int, z : int, default : int) -> int:
# var key : String = str(x) + "," + str(y) + "," + str(z)
var ch : VoxelChunk = chunk_get(x, y, z)
if ch == null:
return default
return ch.lod_size
func _create_chunk(x : int, y : int, z : int, pchunk : VoxelChunk) -> VoxelChunk:
if !pchunk:
pchunk = TVVoxelChunk.new()
if pchunk.job_get_count() == 0:
var tj : VoxelTerrarinJob = VoxelTerrarinJob.new()
var lj : VoxelLightJob = VoxelLightJob.new()
var pj : VoxelPropJob = VoxelPropJob.new()
var prop_mesher = TVVoxelMesher.new()
prop_mesher.base_light_value = 0.45
prop_mesher.ao_strength = 0.2
prop_mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
prop_mesher.voxel_scale = voxel_scale
prop_mesher.build_flags = build_flags
prop_mesher.texture_scale = 3
pj.set_prop_mesher(prop_mesher);
var mesher : TVVoxelMesher = TVVoxelMesher.new()
mesher.base_light_value = 0.45
mesher.ao_strength = 0.2
mesher.uv_margin = Rect2(0.017, 0.017, 1 - 0.034, 1 - 0.034)
mesher.voxel_scale = voxel_scale
mesher.build_flags = build_flags
mesher.texture_scale = 3
mesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_TYPE
mesher.channel_index_isolevel = VoxelChunkDefault.DEFAULT_CHANNEL_ISOLEVEL
tj.add_mesher(mesher)
var cmesher : VoxelMesherBlocky = VoxelMesherBlocky.new()
cmesher.texture_scale = 3
cmesher.base_light_value = 0.45
cmesher.ao_strength = 0.2
cmesher.voxel_scale = voxel_scale
cmesher.build_flags = build_flags
if cmesher.build_flags & VoxelChunkDefault.BUILD_FLAG_USE_LIGHTING != 0:
cmesher.build_flags = cmesher.build_flags ^ VoxelChunkDefault.BUILD_FLAG_USE_LIGHTING
cmesher.always_add_colors = true
# cmesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_TYPE
cmesher.channel_index_type = VoxelChunkDefault.DEFAULT_CHANNEL_ALT_TYPE
tj.add_mesher(cmesher)
pchunk.job_add(lj)
pchunk.job_add(tj)
pchunk.job_add(pj)
return ._create_chunk(x, y, z, pchunk)
func spawn(start_x : int, start_y : int, start_z : int) -> void:
if not Engine.editor_hint:
_max_frame_chunk_build_temp = max_frame_chunk_build_steps
max_frame_chunk_build_steps = 0
var spv : Vector2 = Vector2(start_x, start_z)
for x in range(start_x - chunk_spawn_range, chunk_spawn_range + start_x):
for z in range(start_z - chunk_spawn_range, chunk_spawn_range + start_z):
var l : float = (spv - Vector2(x, z)).length()
if l > chunk_spawn_range:
continue
for y in range(-1 + start_y, spawn_height + start_y):
chunk_create(x, y, z)
# add_prop(Transform().translated(Vector3(0, 2, 0)), test_prop)
set_process(true)
func get_editor_generate() -> bool:
return _editor_generate
func set_editor_generate(value : bool) -> void:
if value:
library.refresh_rects()
level_generator.setup(self, current_seed, false, library)
spawn(0, 0, 0)
# else:
# spawned = false
# clear()
_editor_generate = value
func create_light(x : int, y : int, z : int, size : int, color : Color) -> void:
var chunkx : int = int(x / chunk_size_x)
var chunky : int = int(y / chunk_size_y)
var chunkz : int = int(z / chunk_size_z)
var light : VoxelLight = VoxelLight.new()
light.color = color
light.size = size
light.set_world_position(x, y, z)
light_add(light)
func setup_client_seed(pseed : int) -> void:
# _player_file_name = ""
# _player = null
Server.sset_seed(pseed)
if level_generator != null:
level_generator.setup(self, pseed, false, library)
spawn(0, 0, 0)
func load_character(file_name : String) -> void:
_player_file_name = file_name
_player = ESS.entity_spawner.load_player(file_name, Vector3(5, 30, 5), 1) as Entity
#TODO hack, do this properly
_player.set_physics_process(false)
mob_level = _player.clevel
set_player(_player.get_body())
Server.sset_seed(_player.sseed)
if level_generator != null:
level_generator.setup(self, _player.sseed, true, library)
spawn(0, 0, 0)
set_process(true)
func needs_loading_screen() -> bool:
return show_loading_screen
func save() -> void:
if _player == null or _player_file_name == "":
return
ESS.entity_spawner.save_player(_player, _player_file_name)
func get_mob_level() -> int:
return mob_level
func set_mob_level(level : int) -> void:
mob_level = level