feat: externe 3D-Assets, AutoRigPro-Rig und Asset-Sync
- Asset-Manifest mit Hash, Platzierung und Rig-Metadaten - tools/sync_assets.sh prueft Quelle und Ziel und kopiert aus dem Workbench-Archiv nach assets/external (gitignored) - Skater mit AutoRigPro geriggt: 226 Control-, 30 Deform-Bones - glTF-Export inkl. gebackenem Testclip, Godot-Import verifiziert - Manifest-Test mit 48 Assertions (1123 gesamt) - Phase-1-Exporte schliessen assets/external aus - Doku, Roadmap und Findings aktualisiert
This commit is contained in:
parent
05dee8da2b
commit
8861cbae92
16 changed files with 949 additions and 8 deletions
87
rinkplanner/tests/manual/capture_rig.gd
Normal file
87
rinkplanner/tests/manual/capture_rig.gd
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
extends SceneTree
|
||||
|
||||
## Rendert ein externes GLB mit Kamera, Licht und Boden für die Sichtprüfung.
|
||||
##
|
||||
## Aufruf:
|
||||
## xvfb-run -a godot --path rinkplanner \
|
||||
## --script res://tests/manual/capture_rig.gd -- 640 840 /tmp/opencode/godot_rig.png
|
||||
|
||||
const MODEL_PATH := "res://assets/external/characters/skater_figure_rigged_deform_v002.glb"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_capture.call_deferred()
|
||||
|
||||
|
||||
func _capture() -> void:
|
||||
var args := OS.get_cmdline_user_args()
|
||||
var width := int(args[0]) if args.size() > 0 else 640
|
||||
var height := int(args[1]) if args.size() > 1 else 840
|
||||
var output := args[2] if args.size() > 2 else "user://capture_rig.png"
|
||||
var model_path := args[3] if args.size() > 3 else MODEL_PATH
|
||||
var anim_time := float(args[4]) if args.size() > 4 else -1.0
|
||||
|
||||
var packed := load(model_path) as PackedScene
|
||||
if packed == null:
|
||||
push_error("GLB konnte nicht geladen werden: " + model_path)
|
||||
quit(1)
|
||||
return
|
||||
|
||||
var scene := Node3D.new()
|
||||
root.add_child(scene)
|
||||
var instance := packed.instantiate()
|
||||
scene.add_child(instance)
|
||||
|
||||
if anim_time >= 0.0:
|
||||
var players := instance.find_children("*", "AnimationPlayer", true, false)
|
||||
if not players.is_empty():
|
||||
var player := players[0] as AnimationPlayer
|
||||
var animation_names := player.get_animation_list()
|
||||
if not animation_names.is_empty():
|
||||
player.play(animation_names[0])
|
||||
player.seek(anim_time, true)
|
||||
player.pause()
|
||||
|
||||
var environment := Environment.new()
|
||||
environment.background_mode = Environment.BG_COLOR
|
||||
environment.background_color = Color("d9dee6")
|
||||
environment.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
|
||||
environment.ambient_light_color = Color("ffffff")
|
||||
environment.ambient_light_energy = 0.7
|
||||
var world_environment := WorldEnvironment.new()
|
||||
world_environment.environment = environment
|
||||
scene.add_child(world_environment)
|
||||
|
||||
var key_light := DirectionalLight3D.new()
|
||||
key_light.rotation_degrees = Vector3(-50.0, -35.0, 0.0)
|
||||
key_light.light_energy = 1.4
|
||||
scene.add_child(key_light)
|
||||
|
||||
var ground_mesh := PlaneMesh.new()
|
||||
ground_mesh.size = Vector2(6.0, 6.0)
|
||||
var ground := MeshInstance3D.new()
|
||||
ground.mesh = ground_mesh
|
||||
var ground_material := StandardMaterial3D.new()
|
||||
ground_material.albedo_color = Color("cfd6df")
|
||||
ground.set_surface_override_material(0, ground_material)
|
||||
scene.add_child(ground)
|
||||
|
||||
var camera := Camera3D.new()
|
||||
camera.fov = 42.0
|
||||
scene.add_child(camera)
|
||||
camera.look_at_from_position(
|
||||
Vector3(2.6, 1.45, 3.9),
|
||||
Vector3(0.0, 0.95, 0.0),
|
||||
Vector3.UP
|
||||
)
|
||||
camera.current = true
|
||||
|
||||
root.size = Vector2i(width, height)
|
||||
await process_frame
|
||||
await process_frame
|
||||
await process_frame
|
||||
|
||||
var image := root.get_texture().get_image()
|
||||
image.save_png(output)
|
||||
print("SAVED ", output)
|
||||
quit(0)
|
||||
1
rinkplanner/tests/manual/capture_rig.gd.uid
Normal file
1
rinkplanner/tests/manual/capture_rig.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dogoc8fyx1pj2
|
||||
57
rinkplanner/tests/manual/inspect_rig.gd
Normal file
57
rinkplanner/tests/manual/inspect_rig.gd
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
extends SceneTree
|
||||
|
||||
## Headless-Prüfung für ein externes GLB mit Skelett.
|
||||
##
|
||||
## Aufruf:
|
||||
## godot --headless --path rinkplanner --script res://tests/manual/inspect_rig.gd
|
||||
|
||||
const MODEL_PATH := "res://assets/external/characters/skater_figure_rigged_deform_v002.glb"
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
var args := OS.get_cmdline_user_args()
|
||||
var model_path := args[0] if args.size() > 0 else MODEL_PATH
|
||||
var packed := load(model_path) as PackedScene
|
||||
if packed == null:
|
||||
push_error("GLB konnte nicht geladen werden: " + model_path)
|
||||
quit(1)
|
||||
return
|
||||
|
||||
var instance := packed.instantiate()
|
||||
root.add_child(instance)
|
||||
|
||||
var skeletons := instance.find_children("*", "Skeleton3D", true, false)
|
||||
var meshes := instance.find_children("*", "MeshInstance3D", true, false)
|
||||
var animations := instance.find_children("*", "AnimationPlayer", true, false)
|
||||
|
||||
print("INSTANCE: ", instance.name)
|
||||
print("SKELETONS: ", skeletons.size())
|
||||
for skeleton: Skeleton3D in skeletons:
|
||||
print(" BONES: ", skeleton.get_bone_count())
|
||||
print(" ROOT_BONES: ", skeleton.get_bone_count() if skeleton.get_bone_count() == 0 else _root_bones(skeleton))
|
||||
|
||||
print("MESHES: ", meshes.size())
|
||||
for mesh_instance: MeshInstance3D in meshes:
|
||||
var aabb := mesh_instance.get_aabb()
|
||||
print(" AABB_SIZE: ", aabb.size, " SKIN: ", mesh_instance.skin != null)
|
||||
var material := mesh_instance.get_active_material(0)
|
||||
print(" MATERIAL: ", material.resource_name if material != null else "<none>")
|
||||
|
||||
print("ANIMATION_PLAYERS: ", animations.size())
|
||||
for player: AnimationPlayer in animations:
|
||||
for animation_name: String in player.get_animation_list():
|
||||
var animation := player.get_animation(animation_name)
|
||||
print(" ANIMATION: ", animation_name, " LENGTH: ", animation.length)
|
||||
quit(0)
|
||||
|
||||
|
||||
func _root_bones(skeleton: Skeleton3D) -> PackedStringArray:
|
||||
var roots := PackedStringArray()
|
||||
for index: int in range(skeleton.get_bone_count()):
|
||||
if skeleton.get_bone_parent(index) == -1:
|
||||
roots.append(skeleton.get_bone_name(index))
|
||||
return roots
|
||||
1
rinkplanner/tests/manual/inspect_rig.gd.uid
Normal file
1
rinkplanner/tests/manual/inspect_rig.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c8rpij6kym7hd
|
||||
258
rinkplanner/tests/run_asset_manifest_tests.gd
Normal file
258
rinkplanner/tests/run_asset_manifest_tests.gd
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
extends SceneTree
|
||||
|
||||
## Headless-Prüfung für das externe Asset-Manifest.
|
||||
##
|
||||
## Prüft Schema, Pfade, Hashes und – falls vorhanden – die synchronisierten
|
||||
## Dateien. Fehlt ein Asset (z. B. in CI ohne Workbench), wird der Dateicheck
|
||||
## übersprungen, ohne den Test fehlschlagen zu lassen.
|
||||
##
|
||||
## Aufruf:
|
||||
## godot --headless --path rinkplanner --script res://tests/run_asset_manifest_tests.gd
|
||||
|
||||
const MANIFEST_PATH := "res://assets/asset_manifest.json"
|
||||
const EXTERNAL_PREFIX := "assets/external/"
|
||||
const ALLOWED_KINDS := ["character", "prop", "rink", "animation"]
|
||||
const ALLOWED_FORMATS := ["glb", "gltf", "png"]
|
||||
|
||||
|
||||
var _assertions: int = 0
|
||||
var _failures: PackedStringArray = PackedStringArray()
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
_run.call_deferred()
|
||||
|
||||
|
||||
func _run() -> void:
|
||||
_check(FileAccess.file_exists(MANIFEST_PATH), "manifest exists")
|
||||
|
||||
var parsed: Variant = _read_json(MANIFEST_PATH)
|
||||
_check(parsed is Dictionary, "manifest is valid JSON")
|
||||
if not parsed is Dictionary:
|
||||
_finish()
|
||||
return
|
||||
|
||||
var document: Dictionary = parsed
|
||||
_check(
|
||||
int(document.get("schema_version", 0)) == 1,
|
||||
"manifest uses schema version 1"
|
||||
)
|
||||
|
||||
var assets: Variant = document.get("assets", null)
|
||||
_check(assets is Array, "manifest contains an asset list")
|
||||
if not assets is Array:
|
||||
_finish()
|
||||
return
|
||||
|
||||
var asset_list: Array = assets
|
||||
_check(not asset_list.is_empty(), "asset list is not empty")
|
||||
|
||||
var seen_ids := {}
|
||||
var seen_targets := {}
|
||||
for entry: Variant in asset_list:
|
||||
_check(entry is Dictionary, "asset entry is an object")
|
||||
if not entry is Dictionary:
|
||||
continue
|
||||
_validate_asset(entry, seen_ids, seen_targets)
|
||||
|
||||
_finish()
|
||||
|
||||
|
||||
func _validate_asset(
|
||||
asset: Dictionary,
|
||||
seen_ids: Dictionary,
|
||||
seen_targets: Dictionary
|
||||
) -> void:
|
||||
for key: String in [
|
||||
"id",
|
||||
"version",
|
||||
"kind",
|
||||
"format",
|
||||
"source",
|
||||
"target",
|
||||
"sha256",
|
||||
"bytes",
|
||||
"placement",
|
||||
"rig",
|
||||
"animations",
|
||||
]:
|
||||
_check(asset.has(key), "asset has field '%s'" % key)
|
||||
|
||||
var asset_id := str(asset.get("id", ""))
|
||||
_check(not asset_id.is_empty(), "asset id is not empty")
|
||||
_check(not asset_id.contains(" "), "asset id has no spaces")
|
||||
_check(not seen_ids.has(asset_id), "asset id '%s' is unique" % asset_id)
|
||||
seen_ids[asset_id] = true
|
||||
|
||||
var version := int(asset.get("version", 0))
|
||||
_check(version >= 1, "asset '%s' has a positive version" % asset_id)
|
||||
|
||||
var kind := str(asset.get("kind", ""))
|
||||
_check(kind in ALLOWED_KINDS, "asset '%s' has a known kind" % asset_id)
|
||||
|
||||
var format := str(asset.get("format", ""))
|
||||
_check(format in ALLOWED_FORMATS, "asset '%s' has a known format" % asset_id)
|
||||
|
||||
var source := str(asset.get("source", ""))
|
||||
_check(_is_relative_path(source), "asset '%s' source is relative" % asset_id)
|
||||
_check(not source.contains(".."), "asset '%s' source has no '..'" % asset_id)
|
||||
|
||||
var target := str(asset.get("target", ""))
|
||||
_check(
|
||||
target.begins_with(EXTERNAL_PREFIX),
|
||||
"asset '%s' target lives under %s" % [asset_id, EXTERNAL_PREFIX]
|
||||
)
|
||||
_check(_is_relative_path(target), "asset '%s' target is relative" % asset_id)
|
||||
_check(not target.contains(".."), "asset '%s' target has no '..'" % asset_id)
|
||||
_check(
|
||||
not seen_targets.has(target),
|
||||
"asset '%s' target is unique" % asset_id
|
||||
)
|
||||
seen_targets[target] = true
|
||||
|
||||
var sha256 := str(asset.get("sha256", ""))
|
||||
_check(sha256.length() == 64, "asset '%s' has a SHA-256 length" % asset_id)
|
||||
_check(_is_hex(sha256), "asset '%s' has a hexadecimal SHA-256" % asset_id)
|
||||
|
||||
var size := int(asset.get("bytes", 0))
|
||||
_check(size > 0, "asset '%s' has a positive size" % asset_id)
|
||||
|
||||
var placement: Variant = asset.get("placement", null)
|
||||
_check(placement is Dictionary, "asset '%s' has placement data" % asset_id)
|
||||
if placement is Dictionary:
|
||||
_validate_placement(asset_id, placement)
|
||||
|
||||
var rig: Variant = asset.get("rig", null)
|
||||
_check(rig is Dictionary, "asset '%s' has rig data" % asset_id)
|
||||
if rig is Dictionary:
|
||||
_validate_rig(asset_id, rig)
|
||||
|
||||
var animations: Variant = asset.get("animations", null)
|
||||
_check(animations is Array, "asset '%s' lists animations" % asset_id)
|
||||
if animations is Array:
|
||||
for animation: Variant in animations:
|
||||
_check(animation is String, "asset '%s' animation is a string" % asset_id)
|
||||
|
||||
if asset.has("source_scene"):
|
||||
var scene_path := str(asset.get("source_scene", ""))
|
||||
_check(
|
||||
_is_relative_path(scene_path),
|
||||
"asset '%s' scene path is relative" % asset_id
|
||||
)
|
||||
|
||||
_validate_synced_file(asset_id, target, sha256, size)
|
||||
|
||||
|
||||
func _validate_placement(asset_id: String, placement: Dictionary) -> void:
|
||||
_check(
|
||||
str(placement.get("up_axis", "")) == "Y",
|
||||
"asset '%s' uses Y as up axis" % asset_id
|
||||
)
|
||||
_check(
|
||||
str(placement.get("facing", "")) in ["+Z", "-Z", "+X", "-X"],
|
||||
"asset '%s' has a valid facing" % asset_id
|
||||
)
|
||||
_check(
|
||||
not str(placement.get("pivot", "")).is_empty(),
|
||||
"asset '%s' defines a pivot" % asset_id
|
||||
)
|
||||
_check(
|
||||
float(placement.get("height_m", 0.0)) > 0.0,
|
||||
"asset '%s' has a positive height" % asset_id
|
||||
)
|
||||
_check(
|
||||
placement.get("ground_offset_m", null) is float
|
||||
or placement.get("ground_offset_m", null) is int,
|
||||
"asset '%s' has a numeric ground offset" % asset_id
|
||||
)
|
||||
|
||||
|
||||
func _validate_rig(asset_id: String, rig: Dictionary) -> void:
|
||||
var control_bones := int(rig.get("control_bones", 0))
|
||||
var deform_bones := int(rig.get("deform_bones", 0))
|
||||
_check(control_bones > 0, "asset '%s' has control bones" % asset_id)
|
||||
_check(deform_bones > 0, "asset '%s' has deform bones" % asset_id)
|
||||
_check(
|
||||
deform_bones <= control_bones,
|
||||
"asset '%s' keeps deform bones within the control rig" % asset_id
|
||||
)
|
||||
_check(
|
||||
not str(rig.get("bind", "")).is_empty(),
|
||||
"asset '%s' names its bind method" % asset_id
|
||||
)
|
||||
|
||||
|
||||
func _validate_synced_file(
|
||||
asset_id: String,
|
||||
target: String,
|
||||
expected_sha: String,
|
||||
expected_size: int
|
||||
) -> void:
|
||||
var absolute := "res://" + target
|
||||
if not FileAccess.file_exists(absolute):
|
||||
print(
|
||||
"SKIP: asset '%s' is not synced (%s); run tools/sync_assets.sh --sync"
|
||||
% [asset_id, target]
|
||||
)
|
||||
return
|
||||
|
||||
var file := FileAccess.open(absolute, FileAccess.READ)
|
||||
_check(file != null, "asset '%s' can be opened" % asset_id)
|
||||
if file == null:
|
||||
return
|
||||
|
||||
_check(
|
||||
file.get_length() == expected_size,
|
||||
"asset '%s' has the expected size" % asset_id
|
||||
)
|
||||
var bytes := file.get_buffer(file.get_length())
|
||||
var context := HashingContext.new()
|
||||
context.start(HashingContext.HASH_SHA256)
|
||||
context.update(bytes)
|
||||
_check(
|
||||
context.finish().hex_encode() == expected_sha,
|
||||
"asset '%s' has the expected SHA-256" % asset_id
|
||||
)
|
||||
|
||||
|
||||
func _is_relative_path(path: String) -> bool:
|
||||
return (
|
||||
not path.is_empty()
|
||||
and not path.begins_with("/")
|
||||
and not path.contains("\\")
|
||||
and not path.contains(":")
|
||||
)
|
||||
|
||||
|
||||
func _is_hex(text: String) -> bool:
|
||||
if text.is_empty():
|
||||
return false
|
||||
for character: String in text:
|
||||
if not "0123456789abcdef".contains(character):
|
||||
return false
|
||||
return true
|
||||
|
||||
|
||||
func _read_json(path: String) -> Variant:
|
||||
var file := FileAccess.open(path, FileAccess.READ)
|
||||
if file == null:
|
||||
return null
|
||||
return JSON.parse_string(file.get_as_text())
|
||||
|
||||
|
||||
func _check(condition: bool, message: String) -> void:
|
||||
_assertions += 1
|
||||
if not condition:
|
||||
_failures.append(message)
|
||||
|
||||
|
||||
func _finish() -> void:
|
||||
if _failures.is_empty():
|
||||
print("PASS: %d assertions" % _assertions)
|
||||
quit(0)
|
||||
return
|
||||
|
||||
for failure: String in _failures:
|
||||
printerr("FAIL: %s" % failure)
|
||||
printerr("%d of %d assertions failed" % [_failures.size(), _assertions])
|
||||
quit(1)
|
||||
1
rinkplanner/tests/run_asset_manifest_tests.gd.uid
Normal file
1
rinkplanner/tests/run_asset_manifest_tests.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bcyd8l8y1ichl
|
||||
Loading…
Add table
Add a link
Reference in a new issue