Update Voxelman, and the engine to the latest and work on getting props to work again. Also brought back the test props.

This commit is contained in:
Relintai 2020-06-23 20:58:14 +02:00
parent b587a63f60
commit 1f52100aaa
7 changed files with 291 additions and 27 deletions

2
HEADS
View File

@ -1 +1 @@
{"engine": {"3.2": "a662b853dd5de7d47a8c5ebee3ae35cf66490d3f", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "97f10512f8832394389e1109154b8af34a2ef2c6"}, "entity_spell_system": {"master": "59dbd6ceb162b7ceb29745864b9302081c5bed1f"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "718823a1ebdc937772726ea8071fd767aca20991"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "034116552c9a5e3d090be4903ea2e41a795d8419"}, "procedural_animations": {"master": "9226d21781ea05828570e592874aa319df0dc53d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "26cc4e9b3d904ef78f42f33fdfd97ad5c12ef69d"}, "mesh_utils": {"master": "4f69ec67b861ce4475cfd17946dfaa586c888d94"}, "broken_seals_module": {"master": "0e5c54a70f8e90f95cbf11419b959a5f67562d48"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}
{"engine": {"3.2": "7ec072f7e7963d593170be367a74ef58e764675a", "master": "8c73e813134001e575b6f59e3b0100471c007410"}, "world_generator": {"master": "97f10512f8832394389e1109154b8af34a2ef2c6"}, "entity_spell_system": {"master": "59dbd6ceb162b7ceb29745864b9302081c5bed1f"}, "ui_extensions": {"master": "6fe4f69fea8d71043b08d959b8085404c9c4fe47"}, "voxelman": {"master": "0b717eb5b2a7acc98dab1669c45dd69c262cb028"}, "texture_packer": {"master": "2993ed34f34cfa6a5e61b7913380231e9c55eda6"}, "fastnoise": {"master": "d0e3f1c759332cf0d9a5d7e0e71d0b0278310651"}, "mesh_data_resource": {"master": "034116552c9a5e3d090be4903ea2e41a795d8419"}, "procedural_animations": {"master": "9226d21781ea05828570e592874aa319df0dc53d"}, "ess_data": {"master": "3bd637fdd3304b64a18287a49a6b7387acf2f5de"}, "props": {"master": "26cc4e9b3d904ef78f42f33fdfd97ad5c12ef69d"}, "mesh_utils": {"master": "4f69ec67b861ce4475cfd17946dfaa586c888d94"}, "broken_seals_module": {"master": "0e5c54a70f8e90f95cbf11419b959a5f67562d48"}, "thread_pool": {"master": "93320fe864128d706bcc47fc7ed0731e6e9bcf69"}}

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,7 @@ dest_files=[ "res://.import/huf_calf_left.gltf-8e616bf74161c9cc3335bb03a6585c30.
[params]
collider_type=0
offset=Vector3( 0, 0, 0 )
rotation=Vector3( 0, 0, 0 )
scale=Vector3( 0.011, 0.011, 0.011 )

View File

@ -0,0 +1,38 @@
[gd_resource type="PropData" load_steps=7 format=2]
[ext_resource path="res://modules/species/Human/Female/right_fingers_base.tres" type="MeshDataResource" id=1]
[sub_resource type="PropDataLight" id=4]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.073, 0, 11.7378 )
light_color = Color( 0.909804, 0.129412, 0.129412, 1 )
light_size = 4
[sub_resource type="PropDataLight" id=5]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12.2294, 0, -23.6387 )
light_color = Color( 0.266667, 0.937255, 0.0823529, 1 )
light_size = 18
[sub_resource type="PackedScene" id=3]
_bundled = {
"conn_count": 0,
"conns": PoolIntArray( ),
"editable_instances": [ ],
"names": PoolStringArray( ),
"node_count": 0,
"node_paths": [ ],
"nodes": PoolIntArray( ),
"variants": [ ],
"version": 2
}
[sub_resource type="PropDataScene" id=6]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.06597, 0, 16.5242 )
scene = SubResource( 3 )
[sub_resource type="PropDataMesh" id=7]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 0, 0, 0 )
mesh = ExtResource( 1 )
[resource]
props = [ SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ) ]

View File

@ -0,0 +1,39 @@
[gd_resource type="PropData" load_steps=8 format=2]
[ext_resource path="res://prop_tool/dada.tres" type="PropData" id=2]
[sub_resource type="PropDataLight" id=1]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.073, 0, 11.7378 )
light_color = Color( 0.909804, 0.129412, 0.129412, 1 )
light_size = 4
[sub_resource type="PropDataLight" id=2]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.322, 0, -0.816227 )
light_color = Color( 0.266667, 0.937255, 0.0823529, 1 )
light_size = 6
[sub_resource type="PackedScene" id=3]
_bundled = {
"conn_count": 0,
"conns": PoolIntArray( ),
"editable_instances": [ ],
"names": PoolStringArray( ),
"node_count": 0,
"node_paths": [ ],
"nodes": PoolIntArray( ),
"variants": [ ],
"version": 2
}
[sub_resource type="PropDataScene" id=4]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.06597, 0, 16.5242 )
scene = SubResource( 3 )
[sub_resource type="PropDataMesh" id=5]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 6.52468 )
[sub_resource type="PropDataProp" id=6]
prop = ExtResource( 2 )
[resource]
props = [ SubResource( 1 ), SubResource( 2 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ]

44
game/prop_tool/dada.tres Normal file
View File

@ -0,0 +1,44 @@
[gd_resource type="PropData" load_steps=9 format=2]
[ext_resource path="res://prop_tool/ToolTes2at.tres" type="PropData" id=1]
[sub_resource type="PropDataLight" id=4]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 13.073, 0, 11.7378 )
light_color = Color( 0.909804, 0.129412, 0.129412, 1 )
[sub_resource type="PropDataLight" id=5]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -4.322, 0, -0.816227 )
light_color = Color( 0.266667, 0.937255, 0.0823529, 1 )
[sub_resource type="PackedScene" id=3]
_bundled = {
"conn_count": 0,
"conns": PoolIntArray( ),
"editable_instances": [ ],
"names": PoolStringArray( ),
"node_count": 0,
"node_paths": [ ],
"nodes": PoolIntArray( ),
"variants": [ ],
"version": 2
}
[sub_resource type="PropDataScene" id=6]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1.06597, 0, 16.5242 )
scene = SubResource( 3 )
snap_to_mesh = false
snap_axis = Vector3( 0, -1, 0 )
[sub_resource type="PropDataProp" id=7]
prop = ExtResource( 1 )
[sub_resource type="PropDataProp" id=8]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -6.80673 )
prop = ExtResource( 1 )
[sub_resource type="PropDataProp" id=9]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 20.5188, 0, 15.6823 )
prop = ExtResource( 1 )
[resource]
props = [ SubResource( 4 ), SubResource( 5 ), SubResource( 6 ), SubResource( 7 ), SubResource( 8 ), SubResource( 9 ) ]

View File

@ -30,6 +30,9 @@ var _textures : Array
var _prop_material : SpatialMaterial
var _entities_spawned : bool
var _prop_mesh_instance_rid : RID
var _prop_mesh_rid : RID
func _create_meshers():
var mesher : TVVoxelMesher = TVVoxelMesher.new()
mesher.base_light_value = 0.45
@ -49,6 +52,7 @@ func _create_meshers():
_prop_texture_packer.background_color = Color(0, 0, 0, 1)
_prop_texture_packer.texture_flags = Texture.FLAG_MIPMAPS
#func _build_phase(phase):
# if phase == VoxelChunkDefault.BUILD_PHASE_SETUP:
# ._build_phase(phase)
@ -162,28 +166,166 @@ func _create_meshers():
# else:
# ._build_phase(phase)
func _prop_added(prop):
pass
#func generate_random_ao() -> void:
# var noise : OpenSimplexNoise = OpenSimplexNoise.new()
# noise.seed = 123
# noise.octaves = 4
# noise.period = 30
# noise.persistence = 0.3
#
# for x in range(0, size_x + 1):
# for z in range(0, size_z + 1):
# for y in range(0, size_y + 1):
# var val : float = noise.get_noise_3d(x + (position_x * size_x), y + (position_y * size_y), z + (position_z * size_z))
#
# val *= 0.6
#
# if val > 1:
# val = 1
#
# if val < 0:
# val = -val
#
# set_voxel(int(val * 255.0), x, y, z, VoxelChunkDefault.DEFAULT_CHANNEL_RANDOM_AO)
func spawn_prop_entities(parent_transform : Transform, prop : PropData):
for i in range(prop.get_prop_count()):
var p : PropDataEntry = prop.get_prop(i)
if p is PropDataEntity:
var pentity : PropDataEntity = p as PropDataEntity
if pentity.entity_data_id != 0:
ESS.spawn_mob(pentity.entity_data_id, pentity.level, parent_transform.origin)
if p is PropDataProp and p.prop != null:
var vmanpp : PropDataProp = p as PropDataProp
spawn_prop_entities(get_prop_mesh_transform(parent_transform * p.transform, vmanpp.snap_to_mesh, vmanpp.snap_axis), p.prop)
func build_phase_prop_mesh() -> void:
if get_prop_count() == 0:
# next_phase()
return
if _prop_mesh_rid == RID():
allocate_prop_mesh()
if _prop_material == null:
_prop_material = SpatialMaterial.new()
_prop_material.flags_vertex_lighting = true
_prop_material.vertex_color_use_as_albedo = true
_prop_material.params_specular_mode = SpatialMaterial.SPECULAR_DISABLED
_prop_material.metallic = 0
VisualServer.instance_geometry_set_material_override(_prop_mesh_instance_rid, _prop_material.get_rid())
for i in range(get_prop_mesher_count()):
get_prop_mesher(i).material = _prop_material
for i in range(get_prop_count()):
var prop : VoxelChunkPropData = get_prop(i)
if prop.mesh != null and prop.mesh_texture != null:
var at : AtlasTexture = _prop_texture_packer.add_texture(prop.mesh_texture)
_textures.append(at)
if prop.prop != null:
prop.prop.add_textures_into(_prop_texture_packer)
if _prop_texture_packer.get_texture_count() > 0:
_prop_texture_packer.merge()
_prop_material.albedo_texture = _prop_texture_packer.get_generated_texture(0)
for i in range(get_prop_count()):
var prop : VoxelChunkPropData = get_prop(i)
if prop.mesh != null:
var t : Transform = get_prop_transform(prop, prop.snap_to_mesh, prop.snap_axis)
for j in range(get_prop_mesher_count()):
prop.prop.add_meshes_into(get_prop_mesher(j), _prop_texture_packer, t, get_voxel_world())
if prop.prop != null:
var vmanpp : PropData = prop.prop as PropData
var t : Transform = get_prop_transform(prop, vmanpp.snap_to_mesh, vmanpp.snap_axis)
for j in range(get_prop_mesher_count()):
prop.prop.add_meshes_into(get_prop_mesher(j), _prop_texture_packer, t, get_voxel_world())
for i in range(get_prop_mesher_count()):
get_prop_mesher(i).bake_colors(self)
get_prop_mesher(i).build_mesh_into(_prop_mesh_rid)
get_prop_mesher(i).material = null
if not _entities_spawned:
for i in range(get_prop_count()):
var prop : VoxelChunkPropData = get_prop(i)
if prop.prop != null:
spawn_prop_entities(get_prop_transform(prop, false, Vector3(0, -1, 0)), prop.prop)
# next_phase()
func get_prop_transform(prop : VoxelChunkPropData, snap_to_mesh: bool, snap_axis: Vector3) -> Transform:
var pos : Vector3 = Vector3(prop.x * voxel_scale, prop.y * voxel_scale, prop.z * voxel_scale)
var t : Transform = Transform(Basis(prop.rotation).scaled(prop.scale), pos)
if snap_to_mesh:
var global_pos : Vector3 = get_voxel_world().to_global(t.origin)
var world_snap_axis : Vector3 = get_voxel_world().to_global(t.xform(snap_axis))
var world_snap_dir : Vector3 = (world_snap_axis - global_pos) * 100
var space_state : PhysicsDirectSpaceState = get_voxel_world().get_world().direct_space_state
var result : Dictionary = space_state.intersect_ray(global_pos - world_snap_dir, global_pos + world_snap_dir, [], 1)
if result.size() > 0:
t.origin = get_voxel_world().to_local(result["position"])
return t
func get_prop_mesh_transform(base_transform : Transform, snap_to_mesh: bool, snap_axis: Vector3) -> Transform:
if snap_to_mesh:
var pos : Vector3 = get_voxel_world().to_global(base_transform.origin)
var world_snap_axis : Vector3 = get_voxel_world().to_global(base_transform.xform(snap_axis))
var world_snap_dir : Vector3 = (world_snap_axis - pos) * 100
var space_state : PhysicsDirectSpaceState = get_voxel_world().get_world().direct_space_state
var result : Dictionary = space_state.intersect_ray(pos - world_snap_dir, pos + world_snap_dir, [], 1)
if result.size() > 0:
base_transform.origin = get_voxel_world().to_local(result["position"])
return base_transform
func _build_phase(phase):
if phase == VoxelChunkDefault.BUILD_PHASE_PROP_SETUP:
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)
func build_phase_lights() -> void:
var vl : VoxelLight = VoxelLight.new()
for i in range(get_prop_count()):
var prop : VoxelChunkPropData = get_prop(i)
if prop.light == null and prop.prop == null:
continue
var t : Transform = get_prop_transform(prop, prop.snap_to_mesh, prop.snap_axis)
if prop.light != null:
var pl : PropDataLight = prop.light
vl.set_world_position(prop.x + position_x * size_x, prop.y + position_y * size_y, prop.z + position_z * size_z)
vl.color = pl.light_color
vl.size = pl.light_size
bake_light(vl)
if prop.prop != null:
prop.prop.add_prop_lights_into(self, t, true)
func allocate_prop_mesh():
pass