46 lines
1.1 KiB
GDScript
46 lines
1.1 KiB
GDScript
@tool
|
|
extends SceneTree
|
|
|
|
func _init():
|
|
var models = {
|
|
"Oldpop": "res://assets/characters/Oldpop.glb",
|
|
"Bob": "res://assets/characters/Bob.glb",
|
|
"Gatot": "res://assets/characters/Gatot.glb",
|
|
"Masbro": "res://assets/characters/Masbro.glb"
|
|
}
|
|
|
|
for name in models:
|
|
print("\n=== Inspecting %s ===" % name)
|
|
var scene = load(models[name]).instantiate()
|
|
_inspect_node(scene)
|
|
|
|
quit()
|
|
|
|
func _inspect_node(node: Node):
|
|
if node is MeshInstance3D:
|
|
_print_mesh_uv_bounds(node)
|
|
for child in node.get_children():
|
|
_inspect_node(child)
|
|
|
|
func _print_mesh_uv_bounds(mi: MeshInstance3D):
|
|
var mesh = mi.mesh
|
|
if not mesh: return
|
|
|
|
var min_uv = Vector2(1e10, 1e10)
|
|
var max_uv = Vector2(-1e10, -1e10)
|
|
|
|
for s in mesh.get_surface_count():
|
|
var arrays = mesh.surface_get_arrays(s)
|
|
var uvs = arrays[Mesh.ARRAY_TEX_UV]
|
|
if not uvs: continue
|
|
|
|
for uv in uvs:
|
|
min_uv.x = min(min_uv.x, uv.x)
|
|
min_uv.y = min(min_uv.y, uv.y)
|
|
max_uv.x = max(max_uv.x, uv.x)
|
|
max_uv.y = max(max_uv.y, uv.y)
|
|
|
|
print("- Mesh: %s" % mi.name)
|
|
print(" UV Min: %s" % min_uv)
|
|
print(" UV Max: %s" % max_uv)
|