65 lines
2.3 KiB
GDScript
65 lines
2.3 KiB
GDScript
|
|
# Probe the QuatSkin Lena GLB: skeleton bones, meshes, UV/weight arrays, textures.
|
||
|
|
# Run: tinqs.console.exe --headless --path tattoo-test -s res://probe_lena.gd
|
||
|
|
extends SceneTree
|
||
|
|
|
||
|
|
const GLB_PATH := "C:/Users/CAN/tinqs-ltd/ariki-game/assets/quaternius/derived-bodies/Ariki_Female_QuatSkin.glb"
|
||
|
|
|
||
|
|
func _init() -> void:
|
||
|
|
var doc := GLTFDocument.new()
|
||
|
|
var state := GLTFState.new()
|
||
|
|
if doc.append_from_file(GLB_PATH, state) != OK:
|
||
|
|
push_error("GLB load failed")
|
||
|
|
quit(1)
|
||
|
|
return
|
||
|
|
var scene := doc.generate_scene(state)
|
||
|
|
|
||
|
|
var skel: Skeleton3D = null
|
||
|
|
var stack: Array = [scene]
|
||
|
|
while not stack.is_empty():
|
||
|
|
var n: Node = stack.pop_back()
|
||
|
|
if n is Skeleton3D and skel == null:
|
||
|
|
skel = n
|
||
|
|
if n is MeshInstance3D or n.get_class() == "ImporterMeshInstance3D":
|
||
|
|
var mesh = n.mesh
|
||
|
|
if mesh is ImporterMesh:
|
||
|
|
mesh = mesh.get_mesh()
|
||
|
|
print("MESH node=", n.name, " surfaces=", mesh.get_surface_count())
|
||
|
|
for s in mesh.get_surface_count():
|
||
|
|
var arrays: Array = mesh.surface_get_arrays(s)
|
||
|
|
var v: PackedVector3Array = arrays[Mesh.ARRAY_VERTEX]
|
||
|
|
var uv = arrays[Mesh.ARRAY_TEX_UV]
|
||
|
|
var bones = arrays[Mesh.ARRAY_BONES]
|
||
|
|
var nrm = arrays[Mesh.ARRAY_NORMAL]
|
||
|
|
var mat: Material = mesh.surface_get_material(s)
|
||
|
|
var matname: String = mat.resource_name if mat else "none"
|
||
|
|
var texinfo := "no-tex"
|
||
|
|
if mat is BaseMaterial3D and mat.albedo_texture:
|
||
|
|
var img: Image = mat.albedo_texture.get_image()
|
||
|
|
texinfo = "%dx%d" % [img.get_width(), img.get_height()]
|
||
|
|
print(" surf %d: verts=%d uv=%s normals=%s bones=%s mat=%s tex=%s" % [
|
||
|
|
s, v.size(),
|
||
|
|
"yes" if uv != null else "NO",
|
||
|
|
"yes" if nrm != null else "NO",
|
||
|
|
str(bones.size() / v.size()) + "x" if bones != null and v.size() > 0 else "NO",
|
||
|
|
matname, texinfo])
|
||
|
|
if n.get("skin") != null and n.skin != null:
|
||
|
|
print(" skin binds=", n.skin.get_bind_count())
|
||
|
|
for c in n.get_children():
|
||
|
|
stack.push_back(c)
|
||
|
|
|
||
|
|
if skel:
|
||
|
|
print("SKELETON bones=", skel.get_bone_count())
|
||
|
|
var names := []
|
||
|
|
for i in skel.get_bone_count():
|
||
|
|
names.append(skel.get_bone_name(i))
|
||
|
|
print(" names: ", ", ".join(names))
|
||
|
|
for bn in ["upperarm_r", "lowerarm_r", "hand_r", "spine_03", "clavicle_r"]:
|
||
|
|
var idx := skel.find_bone(bn)
|
||
|
|
if idx >= 0:
|
||
|
|
print(" %s idx=%d pos=%s" % [bn, idx, skel.get_bone_global_rest(idx).origin])
|
||
|
|
else:
|
||
|
|
print(" %s NOT FOUND" % bn)
|
||
|
|
else:
|
||
|
|
print("NO SKELETON")
|
||
|
|
quit()
|