Large update with mostly rewritten character subsystem

This commit is contained in:
Segey Lapin
2019-10-17 08:48:21 +03:00
parent 6e18c898b4
commit 0945ef76ee
224 changed files with 77854 additions and 13113 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,14 @@
extends Spatial
var gender = "female"
var skeleton
var test = true
func _ready():
print(characters.accessory_data)
if test:
var hf = MeshInstance.new()
add_child(hf)
var hb = MeshInstance.new()
add_child(hb)
characters.spawn_accessory(hf, "female", "hair", "front_hair1")
characters.spawn_accessory(hb, "female", "hair", "back_hair1")

View File

@@ -0,0 +1,9 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://characters/hair/hair.gd" type="Script" id=1]
[node name="hair" type="Spatial"]
script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.25491, 1.24916 )

View File

@@ -0,0 +1,2 @@
extends Spatial

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

@@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/haircard2.png-f2f618dfd3d31d77bc8652376923829e.s3tc.stex"
path.etc2="res://.import/haircard2.png-f2f618dfd3d31d77bc8652376923829e.etc2.stex"
metadata={
"imported_formats": [ "s3tc", "etc2" ],
"vram_texture": true
}
[deps]
source_file="res://characters/hair/haircard2.png"
dest_files=[ "res://.import/haircard2.png-f2f618dfd3d31d77bc8652376923829e.s3tc.stex", "res://.import/haircard2.png-f2f618dfd3d31d77bc8652376923829e.etc2.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=1
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=false
svg/scale=1.0

View File

@@ -0,0 +1,59 @@
tool
extends EditorScenePostImport
const base_path: String = "res://characters/accessory"
const conf_path: String = "res://characters/accessory.json"
func post_import(scene):
var confdata = {}
var gender = ""
var scname = scene.filename.get_basename().get_file()
print(scname)
if scname.find("female") >= 0:
gender = "female"
elif scname.find("male") >= 0:
gender = "male"
var fd = File.new()
var d = Directory.new()
if !d.dir_exists(base_path + "/" + gender + "/hair"):
d.make_dir_recursive(base_path + "/" + gender + "/hair")
if fd.file_exists(conf_path):
fd.open(conf_path, File.READ)
var confs = fd.get_as_text()
var json = JSON.parse(confs)
confdata = json.result
fd.close()
var queue = [scene]
if !confdata.has(gender):
confdata[gender] = {}
confdata[gender].hair = {}
var rm_objs = []
while queue.size() > 0:
var item = queue.pop_front()
if item is MeshInstance && item.name.find("hair") >= 0:
var mesh: ArrayMesh = item.mesh
var mesh_path = base_path + "/" + gender + "/hair/" + item.name + ".mesh"
confdata[gender].hair[item.name] = {"path": mesh_path, "materials": []}
for m in range(mesh.get_surface_count()):
var material: Material = mesh.surface_get_material(m)
material.albedo_texture = load("res://characters/hair/haircard2.png")
material.params_use_alpha_scissor = true
material.params_alpha_scissor_threshold = 0.5
var mat_name = material.resource_name
if mat_name.length() == 0:
mat_name = "Material"
var mat_path = base_path + "/" + gender + "/hair/" + mat_name + ".tres"
if !fd.file_exists(mat_path):
ResourceSaver.save(mat_path, material)
confdata[gender].hair[item.name].materials.push_back({"path": mat_path, "name": mat_name})
if !fd.file_exists(mesh_path):
ResourceSaver.save(mesh_path, mesh)
rm_objs.push_back(item)
for c in item.get_children():
queue.push_back(c)
for item in rm_objs:
item.queue_free()
fd.open(conf_path, File.WRITE)
fd.store_string(JSON.print(confdata, "\t", true))
fd.close()
return scene

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff