Made game work

This commit is contained in:
Segey Lapin
2019-10-19 16:35:36 +03:00
parent 53c8a3504f
commit 69410badf6
14 changed files with 506 additions and 463 deletions

View File

@@ -183,6 +183,7 @@ func set_modifier_value(ch: Node, mod_id, value):
# var cha = ch.get_meta("mod") # var cha = ch.get_meta("mod")
# cha.modify(ch) # cha.modify(ch)
func update(): func update():
print("update")
CharacterInstanceList.update() CharacterInstanceList.update()
func remove(ch): func remove(ch):

View File

@@ -133,7 +133,7 @@ func increase_xp(ch, num):
print("next at ", ch.next_xp) print("next at ", ch.next_xp)
func init_data(): func init_data():
for ci in range(24): for ci in range(30):
var cd : = new_candidate() var cd : = new_candidate()
line[ci] = cd line[ci] = cd
team = {} team = {}

View File

@@ -1,285 +1,299 @@
extends Spatial extends Spatial
onready var characters = [preload("res://characters/female_2018.escn"), preload("res://characters/male_2018.escn")] #onready var characters = [preload("res://characters/female_2018.escn"), preload("res://characters/male_2018.escn")]
var body_mi: MeshInstance #var body_mi: MeshInstance
#var body_mesh: ArrayMesh ##var body_mesh: ArrayMesh
#var orig_body_mesh: ArrayMesh ##var orig_body_mesh: ArrayMesh
var cloth_mis: Dictionary = {} #var cloth_mis: Dictionary = {}
#var cloth_meshes: Array = [] ##var cloth_meshes: Array = []
#var cloth_orig_meshes: Array = [] ##var cloth_orig_meshes: Array = []
var clothes: Dictionary = { #var clothes: Dictionary = {
"dress": { # "dress": {
"helper": "" # "helper": ""
}, # },
"panties": { # "panties": {
"helper": "" # "helper": ""
}, # },
"pants": { # "pants": {
"helper": "tights" # "helper": "tights"
}, # },
"suit": { # "suit": {
"helper": "tights" # "helper": "tights"
}, # },
"bra": { # "bra": {
"helper": "" # "helper": ""
}, # },
"top": { # "top": {
"helper": "" # "helper": ""
} # }
} #}
#var min_point: Vector3 = Vector3() ##var min_point: Vector3 = Vector3()
#var max_point: Vector3 = Vector3() ##var max_point: Vector3 = Vector3()
#var min_normal: Vector3 = Vector3() ##var min_normal: Vector3 = Vector3()
#var max_normal: Vector3 = Vector3() ##var max_normal: Vector3 = Vector3()
#var maps = {} ##var maps = {}
#var vert_indices = {} ##var vert_indices = {}
var _vert_indices = {} #var _vert_indices = {}
var controls = {} var controls = {}
var dna: DNA #var dna: DNA
var helper_names : = ["skirt"]
func get_mi(base: Node, mesh_name: String) -> MeshInstance:
var queue = [base]
var ret: MeshInstance
while queue.size() > 0:
var item = queue.pop_front()
if item is MeshInstance && item.name == mesh_name && item.mesh:
ret = item
break
for c in item.get_children():
queue.push_back(c)
return ret
func update_modifier(value: float, modifier: String):
var start_time = OS.get_unix_time()
var should_show : = false
if body_mi.visible:
body_mi.hide()
should_show = true
var val = value / 100.0
val = clamp(val, 0.0, 1.0)
dna.set_modifier_value(modifier, val)
print(modifier, " ", val)
body_mi.mesh = dna.modify_part("body")
if should_show:
body_mi.show()
for k in cloth_mis.keys():
if cloth_mis[k].visible:
cloth_mis[k].hide()
cloth_mis[k].mesh = dna.modify_part(k)
cloth_mis[k].show()
print("modifier_finished: ", OS.get_unix_time() - start_time)
func toggle_clothes(mi: MeshInstance, cloth_name: String):
if !mi.visible:
print("mod start")
mi.mesh = dna.modify_part(cloth_name)
print("mod end")
mi.visible = !mi.visible
func find_mesh(base: Node, mesh_name: String) -> MeshInstance:
assert(base)
var queue = [base]
var mi: MeshInstance
while queue.size() > 0:
var item = queue[0]
assert(item)
queue.pop_front()
if item is MeshInstance && item.name == mesh_name:
mi = item
break
for c in item.get_children():
assert(c)
queue.push_back(c)
return mi
#func modify_mesh(orig_mesh: ArrayMesh, mi: MeshInstance, v_indices: Dictionary):
# var should_show : = false
# if mi.visible:
# mi.hide()
# should_show = true
# mi.mesh = null
# for k in maps.keys():
# maps[k].image.lock()
# maps[k].image_normal.lock()
# var surf : = 0
# var mod_mesh = ArrayMesh.new()
# var mrect: Rect2
# for k in maps.keys():
# if maps[k].value > 0.0001:
# if mrect:
# mrect = mrect.merge(maps[k].rect)
# else:
# mrect = maps[k].rect
# for surface in range(orig_mesh.get_surface_count()):
# var arrays: Array = orig_mesh.surface_get_arrays(surface)
# var uv_index: int = ArrayMesh.ARRAY_TEX_UV
# if arrays[ArrayMesh.ARRAY_TEX_UV2] && arrays[ArrayMesh.ARRAY_TEX_UV2].size() > 0:
# uv_index = ArrayMesh.ARRAY_TEX_UV2
# for index in range(arrays[ArrayMesh.ARRAY_VERTEX].size()):
# var v: Vector3 = arrays[ArrayMesh.ARRAY_VERTEX][index]
# var n: Vector3 = arrays[ArrayMesh.ARRAY_NORMAL][index]
# var uv: Vector2 = arrays[uv_index][index]
# if !mrect.has_point(uv):
# continue
# var diff : = Vector3()
# var diffn : = Vector3()
# for k in maps.keys():
# if !maps[k].rect.has_point(uv) || abs(maps[k].value) < 0.0001:
# continue
# var pos: Vector2 = Vector2(uv.x * maps[k].width, uv.y * maps[k].height)
# var offset: Color = maps[k].image.get_pixelv(pos)
# var offsetn: Color = maps[k].image_normal.get_pixelv(pos)
# var pdiff: Vector3 = Vector3(offset.r, offset.g, offset.b)
# var ndiff: Vector3 = Vector3(offsetn.r, offsetn.g, offsetn.b)
# for u in range(2):
# diff[u] = range_lerp(pdiff[u], 0.0, 1.0, min_point[u], max_point[u]) * maps[k].value
# diffn[u] = range_lerp(ndiff[u], 0.0, 1.0, min_normal[u], max_normal[u]) * maps[k].value
# if abs(diff[u]) < 0.0001:
# diff[u] = 0
# v -= diff
# n -= diffn
# arrays[ArrayMesh.ARRAY_VERTEX][index] = v
# arrays[ArrayMesh.ARRAY_NORMAL][index] = n.normalized()
# for v in v_indices.keys():
# if v_indices[v].size() <= 1:
# continue
# var vx: Vector3 = arrays[ArrayMesh.ARRAY_VERTEX][v_indices[v][0]]
# for idx in range(1, v_indices[v].size()):
# vx = vx.linear_interpolate(arrays[ArrayMesh.ARRAY_VERTEX][v_indices[v][idx]], 0.5)
# for idx in v_indices[v]:
# arrays[ArrayMesh.ARRAY_VERTEX][idx] = vx
# #
# mod_mesh.add_surface_from_arrays(ArrayMesh.PRIMITIVE_TRIANGLES, arrays) #var helper_names : = ["skirt"]
# if orig_mesh.surface_get_material(surface): #
# mod_mesh.surface_set_material(surface, orig_mesh.surface_get_material(surface).duplicate(true)) #func get_mi(base: Node, mesh_name: String) -> MeshInstance:
# surf += 1 # var queue = [base]
# for k in maps.keys(): # var ret: MeshInstance
# maps[k].image.unlock() # while queue.size() > 0:
# maps[k].image_normal.unlock() # var item = queue.pop_front()
# mi.mesh = mod_mesh # if item is MeshInstance && item.name == mesh_name && item.mesh:
# ret = item
# break
# for c in item.get_children():
# queue.push_back(c)
# return ret
#
#func update_modifier(value: float, modifier: String):
# var start_time = OS.get_unix_time()
# var should_show : = false
# if body_mi.visible:
# body_mi.hide()
# should_show = true
# var val = value / 100.0
# val = clamp(val, 0.0, 1.0)
# dna.set_modifier_value(modifier, val)
# print(modifier, " ", val)
# body_mi.mesh = dna.modify_part("body")
# if should_show: # if should_show:
# mi.show() # body_mi.show()
# for k in cloth_mis.keys():
# if cloth_mis[k].visible:
# cloth_mis[k].hide()
# cloth_mis[k].mesh = dna.modify_part(k)
# cloth_mis[k].show()
# print("modifier_finished: ", OS.get_unix_time() - start_time)
#
#func toggle_clothes(mi: MeshInstance, cloth_name: String):
# if !mi.visible:
# print("mod start")
# mi.mesh = dna.modify_part(cloth_name)
# print("mod end")
# mi.visible = !mi.visible
#
#func find_mesh(base: Node, mesh_name: String) -> MeshInstance:
# assert(base)
# var queue = [base]
# var mi: MeshInstance
# while queue.size() > 0:
# var item = queue[0]
# assert(item)
# queue.pop_front()
# if item is MeshInstance && item.name == mesh_name:
# mi = item
# break
# for c in item.get_children():
# assert(c)
# queue.push_back(c)
# return mi
##func modify_mesh(orig_mesh: ArrayMesh, mi: MeshInstance, v_indices: Dictionary):
## var should_show : = false
## if mi.visible:
## mi.hide()
## should_show = true
## mi.mesh = null
## for k in maps.keys():
## maps[k].image.lock()
## maps[k].image_normal.lock()
## var surf : = 0
## var mod_mesh = ArrayMesh.new()
## var mrect: Rect2
## for k in maps.keys():
## if maps[k].value > 0.0001:
## if mrect:
## mrect = mrect.merge(maps[k].rect)
## else:
## mrect = maps[k].rect
## for surface in range(orig_mesh.get_surface_count()):
## var arrays: Array = orig_mesh.surface_get_arrays(surface)
## var uv_index: int = ArrayMesh.ARRAY_TEX_UV
## if arrays[ArrayMesh.ARRAY_TEX_UV2] && arrays[ArrayMesh.ARRAY_TEX_UV2].size() > 0:
## uv_index = ArrayMesh.ARRAY_TEX_UV2
## for index in range(arrays[ArrayMesh.ARRAY_VERTEX].size()):
## var v: Vector3 = arrays[ArrayMesh.ARRAY_VERTEX][index]
## var n: Vector3 = arrays[ArrayMesh.ARRAY_NORMAL][index]
## var uv: Vector2 = arrays[uv_index][index]
## if !mrect.has_point(uv):
## continue
## var diff : = Vector3()
## var diffn : = Vector3()
## for k in maps.keys():
## if !maps[k].rect.has_point(uv) || abs(maps[k].value) < 0.0001:
## continue
## var pos: Vector2 = Vector2(uv.x * maps[k].width, uv.y * maps[k].height)
## var offset: Color = maps[k].image.get_pixelv(pos)
## var offsetn: Color = maps[k].image_normal.get_pixelv(pos)
## var pdiff: Vector3 = Vector3(offset.r, offset.g, offset.b)
## var ndiff: Vector3 = Vector3(offsetn.r, offsetn.g, offsetn.b)
## for u in range(2):
## diff[u] = range_lerp(pdiff[u], 0.0, 1.0, min_point[u], max_point[u]) * maps[k].value
## diffn[u] = range_lerp(ndiff[u], 0.0, 1.0, min_normal[u], max_normal[u]) * maps[k].value
## if abs(diff[u]) < 0.0001:
## diff[u] = 0
## v -= diff
## n -= diffn
## arrays[ArrayMesh.ARRAY_VERTEX][index] = v
## arrays[ArrayMesh.ARRAY_NORMAL][index] = n.normalized()
## for v in v_indices.keys():
## if v_indices[v].size() <= 1:
## continue
## var vx: Vector3 = arrays[ArrayMesh.ARRAY_VERTEX][v_indices[v][0]]
## for idx in range(1, v_indices[v].size()):
## vx = vx.linear_interpolate(arrays[ArrayMesh.ARRAY_VERTEX][v_indices[v][idx]], 0.5)
## for idx in v_indices[v]:
## arrays[ArrayMesh.ARRAY_VERTEX][idx] = vx
##
## mod_mesh.add_surface_from_arrays(ArrayMesh.PRIMITIVE_TRIANGLES, arrays)
## if orig_mesh.surface_get_material(surface):
## mod_mesh.surface_set_material(surface, orig_mesh.surface_get_material(surface).duplicate(true))
## surf += 1
## for k in maps.keys():
## maps[k].image.unlock()
## maps[k].image_normal.unlock()
## mi.mesh = mod_mesh
## if should_show:
## mi.show()
func update_slider(value: float, control: String, slider: HSlider): func update_slider(value: float, control: String, slider: HSlider):
var modifier = "" var modifier = ""
if value >= 0: modifier = controls[control]
modifier = controls[control].plus characters.set_modifier_value(ch, modifier, value / 100.0)
if controls[control].has("minus"): characters.call_deferred("update")
dna.set_modifier_value(controls[control].minus, 0.0) # if controls[control].has("minus"):
else: # dna.set_modifier_value(controls[control].minus, 0.0)
value = -value # else:
modifier = controls[control].minus # value = -value
if controls[control].has("plus"): # modifier = controls[control].minus
dna.set_modifier_value(controls[control].plus, 0.0) # if controls[control].has("plus"):
update_modifier(value, modifier) # dna.set_modifier_value(controls[control].plus, 0.0)
var ch: Node # update_modifier(value, modifier)
func rebuild_clothes_menu(): #var ch: Node
# cloth_orig_meshes.clear() #func rebuild_clothes_menu():
for c in $s/VBoxContainer/clothes.get_children(): ## cloth_orig_meshes.clear()
$s/VBoxContainer/clothes.remove_child(c) # for c in $s/VBoxContainer/clothes.get_children():
c.queue_free() # $s/VBoxContainer/clothes.remove_child(c)
$s/VBoxContainer/clothes.add_child(HSeparator.new()) # c.queue_free()
var clothes_label = Label.new() # $s/VBoxContainer/clothes.add_child(HSeparator.new())
clothes_label.text = "Clothes" # var clothes_label = Label.new()
$s/VBoxContainer/clothes.add_child(clothes_label) # clothes_label.text = "Clothes"
for cloth in clothes.keys(): # $s/VBoxContainer/clothes.add_child(clothes_label)
var cloth_mi : = find_mesh(ch, cloth) # for cloth in clothes.keys():
if !cloth_mi: # var cloth_mi : = find_mesh(ch, cloth)
continue # if !cloth_mi:
var cloth_button = Button.new() # continue
cloth_button.text = cloth_mi.name # var cloth_button = Button.new()
$s/VBoxContainer/clothes.add_child(cloth_button) # cloth_button.text = cloth_mi.name
cloth_button.connect("pressed", self, "toggle_clothes", [cloth_mi, cloth]) # $s/VBoxContainer/clothes.add_child(cloth_button)
func prepare_character(x: int) -> void: # cloth_button.connect("pressed", self, "toggle_clothes", [cloth_mi, cloth])
if ch != null: #func prepare_character(x: int) -> void:
remove_child(ch) # if ch != null:
ch.queue_free() # remove_child(ch)
ch = characters[x].instance() # ch.queue_free()
add_child(ch) # ch = characters[x].instance()
ch.rotation.y = PI # add_child(ch)
rebuild_clothes_menu() # ch.rotation.y = PI
body_mi = find_mesh(ch, "body") # rebuild_clothes_menu()
# body_mesh = body_mi.mesh.duplicate(true) # body_mi = find_mesh(ch, "body")
# orig_body_mesh = body_mi.mesh.duplicate(true) ## body_mesh = body_mi.mesh.duplicate(true)
_vert_indices = get_mi(ch, "body").get_meta("same_verts") ## orig_body_mesh = body_mi.mesh.duplicate(true)
var time = OS.get_unix_time() # _vert_indices = get_mi(ch, "body").get_meta("same_verts")
dna.add_body_mesh(body_mi.mesh, _vert_indices) # var time = OS.get_unix_time()
var elapsed1 = OS.get_unix_time() - time # dna.add_body_mesh(body_mi.mesh, _vert_indices)
# cloth_meshes.clear() # var elapsed1 = OS.get_unix_time() - time
cloth_mis.clear() ## cloth_meshes.clear()
print("body time: ", elapsed1) # cloth_mis.clear()
for cloth in clothes.keys(): # print("body time: ", elapsed1)
var cloth_mi : = find_mesh(ch, cloth) # for cloth in clothes.keys():
if !cloth_mi: # var cloth_mi : = find_mesh(ch, cloth)
continue # if !cloth_mi:
time = OS.get_unix_time() # continue
dna.add_cloth_mesh(cloth, clothes[cloth].helper, cloth_mi.mesh) # time = OS.get_unix_time()
var elapsed2 = OS.get_unix_time() - time # dna.add_cloth_mesh(cloth, clothes[cloth].helper, cloth_mi.mesh)
print("cloth time: ", elapsed2) # var elapsed2 = OS.get_unix_time() - time
cloth_mis[cloth] = cloth_mi # print("cloth time: ", elapsed2)
# prepare_cloth(body_mi, cloth_mi) # cloth_mis[cloth] = cloth_mi
# cloth_meshes.push_back(cloth_mi.mesh) ## prepare_cloth(body_mi, cloth_mi)
func button_female(): ## cloth_meshes.push_back(cloth_mi.mesh)
prepare_character(0) #func button_female():
func button_male(): # prepare_character(0)
prepare_character(1) #func button_male():
# prepare_character(1)
var ch
var mod_name_list
func init_tail():
ch = characters.spawn_character(0, Transform().rotated(Vector3(0, 1, 0), PI))
mod_name_list = characters.get_modifier_list(ch)
func _ready(): func _ready():
dna = DNA.new("res://characters/common/config.bin") call_deferred("init_tail")
# var fd = File.new() # dna = DNA.new("res://characters/common/config.bin")
# fd.open("res://characters/common/config.bin", File.READ) ## var fd = File.new()
# min_point = fd.get_var() ## fd.open("res://characters/common/config.bin", File.READ)
# max_point = fd.get_var() ## min_point = fd.get_var()
# min_normal = fd.get_var() ## max_point = fd.get_var()
# max_normal = fd.get_var() ## min_normal = fd.get_var()
# maps = fd.get_var() ## max_normal = fd.get_var()
# print(maps.keys()) ## maps = fd.get_var()
# vert_indices = fd.get_var() ## print(maps.keys())
# fd.close() ## vert_indices = fd.get_var()
# print("min: ", min_point, " max: ", max_point) ## fd.close()
# for k in maps.keys(): ## print("min: ", min_point, " max: ", max_point)
# print(k, ": ", maps[k].rect) ## for k in maps.keys():
## print(k, ": ", maps[k].rect)
#
var state : = 0 var state : = 0
func build_contols(): func build_contols():
for k in dna.get_modifier_list(): for k in mod_name_list:
if k.ends_with("_plus") && false: controls[k] = k
var cname = k.replace("_plus", "") # for k in dna.get_modifier_list():
if !controls.has(cname): # if k.ends_with("_plus") && false:
controls[cname] = {} # var cname = k.replace("_plus", "")
controls[cname].plus = k # if !controls.has(cname):
elif k.ends_with("_minus") && false: # controls[cname] = {}
var cname = k.replace("_minus", "") # controls[cname].plus = k
if !controls.has(cname): # elif k.ends_with("_minus") && false:
controls[cname] = {} # var cname = k.replace("_minus", "")
controls[cname].minus = k # if !controls.has(cname):
else: # controls[cname] = {}
var cname = k # controls[cname].minus = k
controls[cname] = {} # else:
controls[cname].plus = k # var cname = k
# controls[cname] = {}
# controls[cname].plus = k
for k in controls.keys(): for k in controls.keys():
var ok = true var ok = true
for m in helper_names: # for m in helper_names:
if k.begins_with(m + "_"): # if k.begins_with(m + "_"):
ok = false # ok = false
break # break
if !ok: # if !ok:
continue # continue
var l = Label.new() var l = Label.new()
l.text = k l.text = k
$s/VBoxContainer.add_child(l) $s/VBoxContainer.add_child(l)
var slider : = HSlider.new() var slider : = HSlider.new()
slider.rect_min_size = Vector2(180, 30) slider.rect_min_size = Vector2(180, 30)
print(controls[k]) slider.min_value = -100
slider.max_value = 100
if controls[k].has("minus") && controls[k].has("plus"):
slider.min_value = -100
slider.max_value = 100
else:
slider.min_value = 0
slider.max_value = 100
$s/VBoxContainer.add_child(slider) $s/VBoxContainer.add_child(slider)
slider.connect("value_changed", self, "update_slider", [k, slider]) slider.connect("value_changed", self, "update_slider", [k, slider])
slider.focus_mode = Control.FOCUS_CLICK slider.focus_mode = Control.FOCUS_CLICK
# print(controls[k])
#
# if controls[k].has("minus") && controls[k].has("plus"):
# slider.min_value = -100
# slider.max_value = 100
# else:
# slider.min_value = 0
# slider.max_value = 100
# $s/VBoxContainer.add_child(slider)
# slider.connect("value_changed", self, "update_slider", [k, slider])
# slider.focus_mode = Control.FOCUS_CLICK
if !world.next_scene: if !world.next_scene:
$s/VBoxContainer/ok.hide() $s/VBoxContainer/ok.hide()
else: else:
@@ -291,11 +305,12 @@ func next_scene():
func _process(delta): func _process(delta):
match(state): match(state):
0: 0:
# find_same_verts() ## find_same_verts()
prepare_character(1) # prepare_character(1)
state = 1 state = 1
1: 1:
# $Panel.hide() ## $Panel.hide()
assert(body_mi.mesh) # assert(body_mi.mesh)
assert(ch)
build_contols() build_contols()
state = 2 state = 2

View File

@@ -1,10 +1,13 @@
[gd_scene load_steps=4 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://characters/customization/customize_player.gd" type="Script" id=1] [ext_resource path="res://characters/customization/customize_player.gd" type="Script" id=1]
[ext_resource path="res://characters/customization/cam.gd" type="Script" id=2] [ext_resource path="res://characters/customization/cam.gd" type="Script" id=2]
[sub_resource type="PlaneMesh" id=1] [sub_resource type="PlaneMesh" id=1]
[sub_resource type="BoxShape" id=2]
extents = Vector3( 1, 0.1, 1 )
[node name="customize_player" type="Spatial"] [node name="customize_player" type="Spatial"]
script = ExtResource( 1 ) script = ExtResource( 1 )
@@ -65,3 +68,9 @@ margin_right = 31.0
margin_bottom = 24.0 margin_bottom = 24.0
size_flags_horizontal = 3 size_flags_horizontal = 3
text = "OK" text = "OK"
[node name="StaticBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0 )
shape = SubResource( 2 )

View File

@@ -176,156 +176,156 @@ func add_body_mesh(mesh: ArrayMesh, same_indices: Dictionary) -> Array:
# maps[k].image.unlock() # maps[k].image.unlock()
# maps[k].image_normal.unlock() # maps[k].image_normal.unlock()
# return mod_mesh # return mod_mesh
func modify_part(part_name) -> ArrayMesh: #func modify_part(part_name) -> ArrayMesh:
# var mesh = meshes[part_name].orig_mesh ## var mesh = meshes[part_name].orig_mesh
# var indices = meshes[part_name].same_indices ## var indices = meshes[part_name].same_indices
# return modify_mesh(mesh, indices) ## return modify_mesh(mesh, indices)
return _mod_part(part_name) # return _mod_part(part_name)
func set_modifier_value(modifier: String, value: float): #func set_modifier_value(modifier: String, value: float):
maps[modifier].value = value # maps[modifier].value = value
func get_mesh_modifier(m_name: String, arrays: Array) -> Array: #func get_mesh_modifier(m_name: String, arrays: Array) -> Array:
maps[m_name].image.lock() # maps[m_name].image.lock()
maps[m_name].image_normal.lock() # maps[m_name].image_normal.lock()
var indices = PoolIntArray() # var indices = PoolIntArray()
var mod_vertex = PoolVector3Array() # var mod_vertex = PoolVector3Array()
var mod_normal = PoolVector3Array() # var mod_normal = PoolVector3Array()
var uv_index: int = ArrayMesh.ARRAY_TEX_UV # var uv_index: int = ArrayMesh.ARRAY_TEX_UV
if arrays[ArrayMesh.ARRAY_TEX_UV2] && arrays[ArrayMesh.ARRAY_TEX_UV2].size() > 0: # if arrays[ArrayMesh.ARRAY_TEX_UV2] && arrays[ArrayMesh.ARRAY_TEX_UV2].size() > 0:
uv_index = ArrayMesh.ARRAY_TEX_UV2 # uv_index = ArrayMesh.ARRAY_TEX_UV2
var mrect: Rect2 = maps[m_name].rect # var mrect: Rect2 = maps[m_name].rect
var count = 0 # var count = 0
var max_count = arrays[ArrayMesh.ARRAY_VERTEX].size() # var max_count = arrays[ArrayMesh.ARRAY_VERTEX].size()
var width: int = maps[m_name].width # var width: int = maps[m_name].width
var height: int = maps[m_name].height # var height: int = maps[m_name].height
indices.resize(max_count) # indices.resize(max_count)
mod_vertex.resize(max_count) # mod_vertex.resize(max_count)
mod_normal.resize(max_count) # mod_normal.resize(max_count)
if uv_index != ArrayMesh.ARRAY_TEX_UV2: # if uv_index != ArrayMesh.ARRAY_TEX_UV2:
print("not on uv2") # print("not on uv2")
for index in range(arrays[ArrayMesh.ARRAY_VERTEX].size()): # for index in range(arrays[ArrayMesh.ARRAY_VERTEX].size()):
var uv: Vector2 = arrays[uv_index][index] # var uv: Vector2 = arrays[uv_index][index]
if !mrect.has_point(uv): # if !mrect.has_point(uv):
continue # continue
var diff: = Vector3() # var diff: = Vector3()
var diffn: = Vector3() # var diffn: = Vector3()
var pos: Vector2 = Vector2(uv.x * width, uv.y * height) # var pos: Vector2 = Vector2(uv.x * width, uv.y * height)
var offset: Color = maps[m_name].image.get_pixelv(pos) # var offset: Color = maps[m_name].image.get_pixelv(pos)
var offsetn: Color = maps[m_name].image_normal.get_pixelv(pos) # var offsetn: Color = maps[m_name].image_normal.get_pixelv(pos)
var pdiff: Vector3 = Vector3(offset.r, offset.g, offset.b) # var pdiff: Vector3 = Vector3(offset.r, offset.g, offset.b)
var ndiff: Vector3 = Vector3(offsetn.r, offsetn.g, offsetn.b) # var ndiff: Vector3 = Vector3(offsetn.r, offsetn.g, offsetn.b)
for u in range(3): # for u in range(3):
diff[u] = range_lerp(pdiff[u], 0.0, 1.0, maps[m_name].min_point[u], maps[m_name].min_point[u] + maps[m_name].point_scaler[u]) # diff[u] = range_lerp(pdiff[u], 0.0, 1.0, maps[m_name].min_point[u], maps[m_name].min_point[u] + maps[m_name].point_scaler[u])
diffn[u] = range_lerp(ndiff[u], 0.0, 1.0, maps[m_name].min_normal[u], maps[m_name].min_normal[u] + maps[m_name].normal_scaler[u]) # diffn[u] = range_lerp(ndiff[u], 0.0, 1.0, maps[m_name].min_normal[u], maps[m_name].min_normal[u] + maps[m_name].normal_scaler[u])
if abs(diff[u]) < 0.0001: # if abs(diff[u]) < 0.0001:
diff[u] = 0 # diff[u] = 0
if diff.length() > 0.001: # if diff.length() > 0.001:
indices[count] = index # indices[count] = index
mod_vertex[count] = diff # mod_vertex[count] = diff
mod_normal[count] = diffn # mod_normal[count] = diffn
count += 1 # count += 1
indices.resize(count) # indices.resize(count)
mod_vertex.resize(count) # mod_vertex.resize(count)
mod_normal.resize(count) # mod_normal.resize(count)
maps[m_name].image.unlock() # maps[m_name].image.unlock()
maps[m_name].image_normal.unlock() # maps[m_name].image_normal.unlock()
return [indices, mod_vertex, mod_normal] # return [indices, mod_vertex, mod_normal]
func apply_modifier(mod: Array, arrays: Array, value: float, offset = 0.0): #func apply_modifier(mod: Array, arrays: Array, value: float, offset = 0.0):
var value_: float = clamp(value, 0.0, 1.0) # var value_: float = clamp(value, 0.0, 1.0)
var indices: PoolIntArray = mod[0] # var indices: PoolIntArray = mod[0]
var mod_vertex: PoolVector3Array = mod[1] # var mod_vertex: PoolVector3Array = mod[1]
var mod_normal: PoolVector3Array = mod[2] # var mod_normal: PoolVector3Array = mod[2]
for count in range(indices.size()): # for count in range(indices.size()):
var index: int = indices[count] # var index: int = indices[count]
var diff: Vector3 = mod_vertex[count] # var diff: Vector3 = mod_vertex[count]
var diffn: Vector3 = mod_normal[count] # var diffn: Vector3 = mod_normal[count]
var n = (arrays[ArrayMesh.ARRAY_NORMAL][index] - diffn).normalized() * offset # var n = (arrays[ArrayMesh.ARRAY_NORMAL][index] - diffn).normalized() * offset
arrays[ArrayMesh.ARRAY_VERTEX][index] -= diff * value_ - n # arrays[ArrayMesh.ARRAY_VERTEX][index] -= diff * value_ - n
# do not normalize now # # do not normalize now
arrays[ArrayMesh.ARRAY_NORMAL][index] -= diffn * value_ # arrays[ArrayMesh.ARRAY_NORMAL][index] -= diffn * value_
func _mod_part(part_name: String) -> ArrayMesh: #func _mod_part(part_name: String) -> ArrayMesh:
print("modifying ", part_name) # print("modifying ", part_name)
print("helper:", meshes[part_name].helper) # print("helper:", meshes[part_name].helper)
var start_time = OS.get_unix_time() # var start_time = OS.get_unix_time()
# var mesh: ArrayMesh = meshes[part_name].orig_mesh ## var mesh: ArrayMesh = meshes[part_name].orig_mesh
var mod_mesh: = ArrayMesh.new() # var mod_mesh: = ArrayMesh.new()
var indices: Dictionary = meshes[part_name].same_indices # var indices: Dictionary = meshes[part_name].same_indices
var surface: int = 0 # var surface: int = 0
if meshes[part_name].has("surface"): # if meshes[part_name].has("surface"):
surface = meshes[part_name].surface # surface = meshes[part_name].surface
# var arrays: Array = mesh.surface_get_arrays(surface) ## var arrays: Array = mesh.surface_get_arrays(surface)
var arrays: Array = meshes[part_name].orig_arrays.duplicate() # var arrays: Array = meshes[part_name].orig_arrays.duplicate()
if part_name == "body": # if part_name == "body":
for mod in meshes[part_name].modifiers.keys(): # for mod in meshes[part_name].modifiers.keys():
var mod_data = meshes[part_name].modifiers[mod] # var mod_data = meshes[part_name].modifiers[mod]
apply_modifier(mod_data, arrays, maps[mod].value) # apply_modifier(mod_data, arrays, maps[mod].value)
else: # else:
for mod in meshes[part_name].modifiers.keys(): # for mod in meshes[part_name].modifiers.keys():
var mod_data = meshes[part_name].modifiers[mod] # var mod_data = meshes[part_name].modifiers[mod]
apply_modifier(mod_data, arrays, maps[mod].value, 0.0002) # apply_modifier(mod_data, arrays, maps[mod].value, 0.0002)
for v in indices.keys(): # for v in indices.keys():
if indices[v].size() <= 1: # if indices[v].size() <= 1:
continue # continue
var vx: Vector3 = arrays[ArrayMesh.ARRAY_VERTEX][indices[v][0]] # var vx: Vector3 = arrays[ArrayMesh.ARRAY_VERTEX][indices[v][0]]
for idx in range(1, indices[v].size()): # for idx in range(1, indices[v].size()):
vx = vx.linear_interpolate(arrays[ArrayMesh.ARRAY_VERTEX][indices[v][idx]], 0.5) # vx = vx.linear_interpolate(arrays[ArrayMesh.ARRAY_VERTEX][indices[v][idx]], 0.5)
for idx in indices[v]: # for idx in indices[v]:
arrays[ArrayMesh.ARRAY_VERTEX][idx] = vx # arrays[ArrayMesh.ARRAY_VERTEX][idx] = vx
mod_mesh.add_surface_from_arrays(ArrayMesh.PRIMITIVE_TRIANGLES, arrays) # mod_mesh.add_surface_from_arrays(ArrayMesh.PRIMITIVE_TRIANGLES, arrays)
if meshes[part_name].material: # if meshes[part_name].material:
mod_mesh.surface_set_material(surface, meshes[part_name].material.duplicate(true)) # mod_mesh.surface_set_material(surface, meshes[part_name].material.duplicate(true))
# if mesh.surface_get_material(surface): ## if mesh.surface_get_material(surface):
# mod_mesh.surface_set_material(surface, mesh.surface_get_material(surface).duplicate(true)) ## mod_mesh.surface_set_material(surface, mesh.surface_get_material(surface).duplicate(true))
var elapsed = OS.get_unix_time() - start_time # var elapsed = OS.get_unix_time() - start_time
print("modified ", part_name, " ", elapsed) # print("modified ", part_name, " ", elapsed)
return mod_mesh # return mod_mesh
func load_maps(path: String): #func load_maps(path: String):
maps = {} # maps = {}
var fd: File = File.new() # var fd: File = File.new()
fd.open(path, File.READ) # fd.open(path, File.READ)
if !fd.is_open(): # if !fd.is_open():
print("Could not open " + path) # print("Could not open " + path)
print(fd.get_len()) # print(fd.get_len())
var count = fd.get_var() # var count = fd.get_var()
print(count) # print(count)
for c in range(count): # for c in range(count):
var map_name = fd.get_var() # var map_name = fd.get_var()
map_name = map_name.replace("base:", "") # map_name = map_name.replace("base:", "")
var rect = fd.get_var() # var rect = fd.get_var()
var map_min_point = fd.get_var() # var map_min_point = fd.get_var()
var point_scaler = fd.get_var() # var point_scaler = fd.get_var()
var map_min_normal = fd.get_var() # var map_min_normal = fd.get_var()
var normal_scaler = fd.get_var() # var normal_scaler = fd.get_var()
var map_width = fd.get_var() # var map_width = fd.get_var()
var map_height = fd.get_var() # var map_height = fd.get_var()
var data_size = fd.get_var() # var data_size = fd.get_var()
var data = fd.get_var() # var data = fd.get_var()
var map_normal_width = fd.get_var() # var map_normal_width = fd.get_var()
var map_normal_height = fd.get_var() # var map_normal_height = fd.get_var()
var normal_data_size = fd.get_var() # var normal_data_size = fd.get_var()
var normal_data = fd.get_var() # var normal_data = fd.get_var()
maps[map_name] = {} # maps[map_name] = {}
maps[map_name].rect = rect # maps[map_name].rect = rect
maps[map_name].min_point = map_min_point # maps[map_name].min_point = map_min_point
maps[map_name].point_scaler = point_scaler # maps[map_name].point_scaler = point_scaler
maps[map_name].min_normal = map_min_normal # maps[map_name].min_normal = map_min_normal
maps[map_name].normal_scaler = normal_scaler # maps[map_name].normal_scaler = normal_scaler
maps[map_name].width = map_width # maps[map_name].width = map_width
maps[map_name].height = map_height # maps[map_name].height = map_height
maps[map_name].normal_width = map_normal_width # maps[map_name].normal_width = map_normal_width
maps[map_name].normal_height = map_normal_height # maps[map_name].normal_height = map_normal_height
data = data.decompress(data_size, File.COMPRESSION_DEFLATE) # data = data.decompress(data_size, File.COMPRESSION_DEFLATE)
maps[map_name].image = Image.new() # maps[map_name].image = Image.new()
maps[map_name].image.create_from_data(maps[map_name].width, maps[map_name].height, false, Image.FORMAT_RGB8, data) # maps[map_name].image.create_from_data(maps[map_name].width, maps[map_name].height, false, Image.FORMAT_RGB8, data)
normal_data = normal_data.decompress(normal_data_size, File.COMPRESSION_DEFLATE) # normal_data = normal_data.decompress(normal_data_size, File.COMPRESSION_DEFLATE)
maps[map_name].image_normal = Image.new() # maps[map_name].image_normal = Image.new()
maps[map_name].image_normal.create_from_data(maps[map_name].normal_width, maps[map_name].normal_height, false, Image.FORMAT_RGB8, normal_data) # maps[map_name].image_normal.create_from_data(maps[map_name].normal_width, maps[map_name].normal_height, false, Image.FORMAT_RGB8, normal_data)
print(map_name, " ", map_width, " ", map_height, " ", data_size, " ", data.size(), " ", map_normal_width, " ", map_normal_height, " ", normal_data_size, " ", normal_data.size()) # print(map_name, " ", map_width, " ", map_height, " ", data_size, " ", data.size(), " ", map_normal_width, " ", map_normal_height, " ", normal_data_size, " ", normal_data.size())
maps[map_name].value = 0.0 # maps[map_name].value = 0.0
fd.close() # fd.close()
func _init(path: String): #func _init(path: String):
load_maps("res://characters/blendmaps.bin") # load_maps("res://characters/blendmaps.bin")
# var fd = File.new() # var fd = File.new()
# fd.open(path, File.READ) # fd.open(path, File.READ)
# min_point = fd.get_var() # min_point = fd.get_var()

View File

@@ -81,8 +81,8 @@ script = ExtResource( 1 )
[node name="female_2018" parent="female_2018" index="0"] [node name="female_2018" parent="female_2018" index="0"]
bones/132/bound_children = [ NodePath("item_carry") ] bones/132/bound_children = [ NodePath("item_carry") ]
[node name="item_carry" type="BoneAttachment" parent="female_2018/female_2018" index="13"] [node name="item_carry" type="BoneAttachment" parent="female_2018/female_2018" index="1"]
transform = Transform( 0.816538, -0.555132, -0.158408, 0.505615, 0.555284, 0.660309, -0.278598, -0.619263, 0.734095, 0.174373, 0.783361, -0.0350451 ) transform = Transform( 0.816539, -0.555132, -0.158407, 0.505615, 0.555285, 0.660311, -0.2786, -0.619263, 0.734095, 0.174373, 0.783361, -0.035045 )
bone_name = "wrist_R" bone_name = "wrist_R"
[node name="ball_carry" type="Spatial" parent="female_2018/female_2018/item_carry"] [node name="ball_carry" type="Spatial" parent="female_2018/female_2018/item_carry"]

View File

@@ -77,8 +77,8 @@ script = ExtResource( 2 )
[node name="male_g_2018" parent="male_2018" index="0"] [node name="male_g_2018" parent="male_2018" index="0"]
bones/110/bound_children = [ NodePath("item_carry") ] bones/110/bound_children = [ NodePath("item_carry") ]
[node name="item_carry" type="BoneAttachment" parent="male_2018/male_g_2018" index="9"] [node name="item_carry" type="BoneAttachment" parent="male_2018/male_g_2018" index="1"]
transform = Transform( 0.579234, -0.742538, -0.336341, 0.736249, 0.299448, 0.606851, -0.349893, -0.59914, 0.720144, 0.334017, 1.00794, -0.175007 ) transform = Transform( 0.57822, -0.742842, -0.337411, 0.736408, 0.297145, 0.607789, -0.351231, -0.599909, 0.71885, 0.334138, 1.00818, -0.174576 )
bone_name = "wrist_R" bone_name = "wrist_R"
[node name="ball_carry" type="Spatial" parent="male_2018/male_g_2018/item_carry"] [node name="ball_carry" type="Spatial" parent="male_2018/male_g_2018/item_carry"]

View File

@@ -95,6 +95,8 @@ func spawn_character(cd, xform, k):
cd.scene = char_sc cd.scene = char_sc
cd.id = k cd.id = k
char_sc.set_meta("data", cd) char_sc.set_meta("data", cd)
func characters_done():
characters.update()
characters.update() characters.update()
func _ready(): func _ready():
@@ -112,7 +114,7 @@ func _ready():
queue.push_back(c) queue.push_back(c)
var master_xform = $master.global_transform var master_xform = $master.global_transform
$master.queue_free() $master.queue_free()
master = characters.spawn_character(1, master_xform) master = characters.spawn_character(0, master_xform)
master.add_to_group("master") master.add_to_group("master")
controls.master_node = master controls.master_node = master
world.master_node = master world.master_node = master
@@ -126,10 +128,11 @@ func _ready():
for k in world.line.keys(): for k in world.line.keys():
var cd = world.line[k] var cd = world.line[k]
var char_xform = Transform() var char_xform = Transform()
var nav: Navigation2D = get_node("nav") var nav: Navigation = get_node("nav")
var p = nav.get_closest_point(get_node("line_spawn").global_transform.origin + Vector3(randf() * 20.0 - 10.0, 0.0, randf() * 20 - 10.0)) var p = nav.get_closest_point(get_node("line_spawn").global_transform.origin + Vector3(randf() * 20.0 - 10.0, 0.0, randf() * 20 - 10.0))
char_xform.origin = p char_xform.origin = p
call_deferred("spawn_character", cd, char_xform, k) call_deferred("spawn_character", cd, char_xform, k)
call_deferred("characters_done")
var tut_quest = Quest.new("Tutorial", "This quest shortly introduces to a game") var tut_quest = Quest.new("Tutorial", "This quest shortly introduces to a game")
tut_quest.connect("started", self, "start_quest") tut_quest.connect("started", self, "start_quest")
tut_quest.connect("complete", self, "complete_quest") tut_quest.connect("complete", self, "complete_quest")

File diff suppressed because one or more lines are too long

View File

@@ -108,6 +108,11 @@ characters="*res://autoloads/characters.gd"
notifications="*res://autoloads/notifications.gd" notifications="*res://autoloads/notifications.gd"
roadmap="*res://autoloads/roadmap.gd" roadmap="*res://autoloads/roadmap.gd"
[debug]
settings/stdout/print_fps=true
settings/stdout/verbose_stdout=true
[input] [input]
move_west={ move_west={
@@ -148,7 +153,6 @@ limits/message_queue/max_size_kb=2048
[rendering] [rendering]
quality/driver/fallback_to_gles2=true quality/driver/fallback_to_gles2=true
threads/thread_model=2
vram_compression/import_etc=true vram_compression/import_etc=true
threads/thread_model.web=1 threads/thread_model.web=1
quality/driver/driver_name.web="GLES2" quality/driver/driver_name.web="GLES2"

View File

@@ -5,6 +5,7 @@ extends Spatial
# var b = "text" # var b = "text"
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
var vehicle_x = 0.0
func start(): func start():
print("Started") print("Started")
var forest var forest
@@ -108,6 +109,7 @@ func _ready():
$"car1/front-door-right".set_surface_material(0, car_mat) $"car1/front-door-right".set_surface_material(0, car_mat)
$"car1/trunk_rotate/trunk_cover".set_surface_material(0, car_mat) $"car1/trunk_rotate/trunk_cover".set_surface_material(0, car_mat)
$"car1/floor".set_surface_material(0, car_bottom_mat) $"car1/floor".set_surface_material(0, car_bottom_mat)
vehicle_x = $car1.translation.x
var narration = [ var narration = [
"It was never a good sign to go to forest in a car trunk...", "It was never a good sign to go to forest in a car trunk...",
@@ -136,13 +138,13 @@ func _process(delta):
var trig: int = randi() % 2 var trig: int = randi() % 2
if Input.is_action_just_pressed("move_east") && trig == 1: if Input.is_action_just_pressed("move_east") && trig == 1:
if $progress.value < 100: if $progress.value < 100:
$progress.value += (2 + randi() % 4) $progress.value += (4 + randi() % 4)
if Input.is_action_just_pressed("move_west") && trig == 0: if Input.is_action_just_pressed("move_west") && trig == 0:
if $progress.value < 100: if $progress.value < 100:
$progress.value += (2 + randi() % 4) $progress.value += (4 + randi() % 4)
if randf() > 0.9: if randf() > 0.9:
if $progress.value > 0: if $progress.value > 0:
$progress.value -= (1 + randi() % 2) $progress.value -= (1 + randi() % 3)
if $progress.value >= 99: if $progress.value >= 99:
_state = STATE_KICK_TRUNK _state = STATE_KICK_TRUNK
STATE_KICK_TRUNK: STATE_KICK_TRUNK:
@@ -236,3 +238,12 @@ func _physics_process(delta):
$car1.engine_force = (1.0 - delta * 0.2) $car1.engine_force = (1.0 - delta * 0.2)
if car_speed < 10: if car_speed < 10:
$car1.brake = 4000.0 $car1.brake = 4000.0
if _state != STATE_KICK_TRUNK:
if $car1.translation.x < vehicle_x - 0.2:
$car1.steering = -0.03
$car1.engine_force = 0.0
elif $car1.translation.x > vehicle_x + 0.2:
$car1.steering = 0.03
$car1.engine_force = 0.0
else:
$car1.steering *= (1.0 - delta) * 0.2

View File

@@ -5,23 +5,23 @@
[ext_resource path="res://vehicles/cars/car_car1.tscn" type="PackedScene" id=3] [ext_resource path="res://vehicles/cars/car_car1.tscn" type="PackedScene" id=3]
[ext_resource path="res://fonts/DroidSansFallback.ttf" type="DynamicFontData" id=4] [ext_resource path="res://fonts/DroidSansFallback.ttf" type="DynamicFontData" id=4]
[sub_resource type="ProceduralSky" id=7] [sub_resource type="ProceduralSky" id=1]
sky_energy = 0.7 sky_energy = 0.7
sun_energy = 0.5 sun_energy = 0.5
[sub_resource type="Environment" id=8] [sub_resource type="Environment" id=2]
background_mode = 2 background_mode = 2
background_sky = SubResource( 7 ) background_sky = SubResource( 1 )
[sub_resource type="BoxShape" id=1] [sub_resource type="BoxShape" id=3]
extents = Vector3( 100, 0.2, 100 ) extents = Vector3( 100, 0.2, 100 )
[sub_resource type="CubeMesh" id=2] [sub_resource type="CubeMesh" id=4]
size = Vector3( 8, 0.2, 300 ) size = Vector3( 8, 0.2, 300 )
subdivide_width = 4 subdivide_width = 4
subdivide_depth = 300 subdivide_depth = 300
[sub_resource type="SpatialMaterial" id=3] [sub_resource type="SpatialMaterial" id=5]
albedo_color = Color( 0.34902, 0.34902, 0.34902, 1 ) albedo_color = Color( 0.34902, 0.34902, 0.34902, 1 )
metallic = 0.1 metallic = 0.1
roughness = 0.8 roughness = 0.8
@@ -29,23 +29,23 @@ roughness = 0.8
[sub_resource type="BoxShape" id=6] [sub_resource type="BoxShape" id=6]
extents = Vector3( 2, 1, 8 ) extents = Vector3( 2, 1, 8 )
[sub_resource type="SpatialMaterial" id=9] [sub_resource type="SpatialMaterial" id=7]
albedo_color = Color( 0.176471, 0.678431, 0.243137, 1 ) albedo_color = Color( 0.176471, 0.678431, 0.243137, 1 )
[sub_resource type="PlaneMesh" id=10] [sub_resource type="PlaneMesh" id=8]
material = SubResource( 9 ) material = SubResource( 7 )
size = Vector2( 100, 300 ) size = Vector2( 100, 300 )
subdivide_width = 200 subdivide_width = 200
subdivide_depth = 200 subdivide_depth = 200
[sub_resource type="StyleBoxFlat" id=11] [sub_resource type="StyleBoxFlat" id=9]
bg_color = Color( 1, 0, 0, 1 ) bg_color = Color( 1, 0, 0, 1 )
border_blend = true border_blend = true
[sub_resource type="StyleBoxFlat" id=12] [sub_resource type="StyleBoxFlat" id=10]
bg_color = Color( 0.6, 0.6, 0.6, 0 ) bg_color = Color( 0.6, 0.6, 0.6, 0 )
[sub_resource type="DynamicFont" id=13] [sub_resource type="DynamicFont" id=11]
use_mipmaps = true use_mipmaps = true
use_filter = true use_filter = true
font_data = ExtResource( 4 ) font_data = ExtResource( 4 )
@@ -59,13 +59,13 @@ script = ExtResource( 2 )
target_path = NodePath("../cam") target_path = NodePath("../cam")
[node name="Camera" type="Camera" parent="vehicle_camera"] [node name="Camera" type="Camera" parent="vehicle_camera"]
environment = SubResource( 8 ) environment = SubResource( 2 )
[node name="StaticBody" type="StaticBody" parent="."] [node name="StaticBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"] [node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0 )
shape = SubResource( 1 ) shape = SubResource( 3 )
[node name="DirectionalLight" type="DirectionalLight" parent="."] [node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.990268, -0.134431, 0.0360206, 0, 0.258819, 0.965926, -0.139173, -0.956526, 0.2563, 0, 20, 0 ) transform = Transform( 0.990268, -0.134431, 0.0360206, 0, 0.258819, 0.965926, -0.139173, -0.956526, 0.2563, 0, 20, 0 )
@@ -79,8 +79,8 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4, 0 )
[node name="road" type="MeshInstance" parent="."] [node name="road" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.1, 0 )
mesh = SubResource( 2 ) mesh = SubResource( 4 )
material/0 = SubResource( 3 ) material/0 = SubResource( 5 )
[node name="Area" type="Area" parent="."] [node name="Area" type="Area" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.03741, 0, -80.0024 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.03741, 0, -80.0024 )
@@ -94,12 +94,12 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 2.5, 0.4, 76.3702 )
[node name="ground" type="MeshInstance" parent="."] [node name="ground" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -54, 0, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -54, 0, 0 )
mesh = SubResource( 10 ) mesh = SubResource( 8 )
material/0 = null material/0 = null
[node name="ground2" type="MeshInstance" parent="."] [node name="ground2" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 54, 0, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 54, 0, 0 )
mesh = SubResource( 10 ) mesh = SubResource( 8 )
material/0 = null material/0 = null
[node name="progress" type="ProgressBar" parent="."] [node name="progress" type="ProgressBar" parent="."]
@@ -114,9 +114,9 @@ margin_bottom = -8.94751
rect_min_size = Vector2( 64, 64 ) rect_min_size = Vector2( 64, 64 )
size_flags_horizontal = 3 size_flags_horizontal = 3
size_flags_vertical = 1 size_flags_vertical = 1
custom_styles/fg = SubResource( 11 ) custom_styles/fg = SubResource( 9 )
custom_styles/bg = SubResource( 12 ) custom_styles/bg = SubResource( 10 )
custom_fonts/font = SubResource( 13 ) custom_fonts/font = SubResource( 11 )
custom_colors/font_color = Color( 0, 0, 0, 0 ) custom_colors/font_color = Color( 0, 0, 0, 0 )
custom_colors/font_color_shadow = Color( 0.564706, 0.109804, 0.109804, 0.384314 ) custom_colors/font_color_shadow = Color( 0.564706, 0.109804, 0.109804, 0.384314 )
__meta__ = { __meta__ = {

View File

@@ -150,7 +150,7 @@ func _process(delta):
xform.origin.z = 5.0 xform.origin.z = 5.0
xform.basis = xform.basis.rotated(Vector3(0, 1, 0), PI) xform.basis = xform.basis.rotated(Vector3(0, 1, 0), PI)
if randf() > 0.5: if randf() > 0.5:
c = characters.spawn_character(1, xform) c = characters.spawn_character(0, xform)
# c = characters.characters[1].instance() # c = characters.characters[1].instance()
# add_child(c) # add_child(c)
# c.translation.x = $Camera.translation.x + 3.0 # c.translation.x = $Camera.translation.x + 3.0
@@ -199,7 +199,7 @@ func _process(delta):
var remove_ids = [] var remove_ids = []
for ie in range(_characters.size()): for ie in range(_characters.size()):
var e = _characters[ie] var e = _characters[ie]
if abs($Camera.translation.x + 3.0 - e.scene.translation.x) > 6.0: if abs($Camera.translation.x + 3.0 - e.scene.translation.x) > 26.0:
characters.remove(e.scene) characters.remove(e.scene)
# e.cha.remove_work_meshes(e.mesh_id) # e.cha.remove_work_meshes(e.mesh_id)
# e.scene.queue_free() # e.scene.queue_free()