ce4c4e7d13
Session 2026-07-23/24 additions on top of the existing Quaternius bed: - bake_lena.gd: 6-piece bake on QuatSkin Lena (chiefs-mark/iron-spine arms, voyagers/storm-bearer legs, star-eye chest, hearth-warmth back); global-axis wrap frame + 3cm junction blend kill the elbow split line - demirror_lena.gd: tri-level split of mirror-shared limb UVs (arms 100%->0%, legs 99%->5% crotch-only residual) - reuv_lena.gd: Quaternius-style semantic re-UV (16 islands, cylinder limbs + cylinder head/torso with planar caps) + texture transfer; fixes armpit/chin/ cheek planar smears; single 4096 atlas, per-side tattoos native - main_lena / anim_lena viewers (18 UAL clips, U light toggle) + probes + shots Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
239 lines
7.8 KiB
GDScript
239 lines
7.8 KiB
GDScript
# Animation test: the tattooed Quaternius Regular Male driven by UAL1 clips.
|
|
# Controls:
|
|
# ←/→ or A/D previous / next animation
|
|
# Space pause / resume
|
|
# left-drag orbit camera, scroll wheel zooms
|
|
# Saves a few mid-animation shots to shots-anim/ first, then goes interactive.
|
|
extends Node3D
|
|
|
|
const GLTF_PATH := "C:/Users/CAN/tinqs-ltd/ariki-game/assets/quaternius/source-models/Regular_Male_FullBody.gltf"
|
|
const BAKED_PATH := "C:/Users/CAN/tinqs-ltd/tattoo-test/baked_body.png"
|
|
const NORMAL_PATH := "C:/Users/CAN/tinqs-ltd/ariki-game/assets/quaternius/source-models/T_Regular_Male_Normal_png.png"
|
|
const EYE_PATH := "C:/Users/CAN/tinqs-ltd/ariki-game/assets/quaternius/source-models/T_Eye_Brown.png"
|
|
const HAIR_PATH := "C:/Users/CAN/tinqs-ltd/ariki-game/assets/quaternius/source-models/T_Hair_1_BaseColor.png"
|
|
const UAL1 := "C:/Users/CAN/tinqs-ltd/ariki-game/assets/quaternius/anim-lib-1/Universal Animation Library[Standard]/Unreal-Godot/UAL1_Standard.glb"
|
|
const SHOT_DIR := "C:/Users/CAN/tinqs-ltd/tattoo-test/shots-anim/"
|
|
const TAKE_SHOTS := true
|
|
|
|
# gallery order: locomotion first, then actions
|
|
const CLIPS := [
|
|
"Idle_Loop", "Walk_Loop", "Jog_Fwd_Loop", "Sprint_Loop",
|
|
"Crouch_Idle_Loop", "Crouch_Fwd_Loop", "Jump_Loop",
|
|
"Swim_Idle_Loop", "Swim_Fwd_Loop",
|
|
"Dance_Loop", "Punch_Jab", "Punch_Cross", "Roll", "Interact",
|
|
"Fixing_Kneeling", "Sitting_Idle_Loop", "Spell_Simple_Shoot", "Death01",
|
|
]
|
|
|
|
var model: Node3D
|
|
var skel: Skeleton3D
|
|
var cam: Camera3D
|
|
var player: AnimationPlayer
|
|
var hud: Label
|
|
var clip_idx := 0
|
|
|
|
var interactive := false
|
|
var dragging := false
|
|
var orbit_yaw := 0.0
|
|
var orbit_pitch := 0.08
|
|
var orbit_dist := 3.4
|
|
var orbit_target := Vector3(0, 1.0, 0)
|
|
|
|
func _ready() -> void:
|
|
DirAccess.make_dir_recursive_absolute(SHOT_DIR)
|
|
|
|
var env := Environment.new()
|
|
env.background_mode = Environment.BG_COLOR
|
|
env.background_color = Color(0.12, 0.13, 0.16)
|
|
env.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
|
|
env.ambient_light_color = Color(0.75, 0.78, 0.85)
|
|
env.ambient_light_energy = 0.7
|
|
env.tonemap_mode = Environment.TONE_MAPPER_FILMIC
|
|
var we := WorldEnvironment.new()
|
|
we.environment = env
|
|
add_child(we)
|
|
|
|
var sun := DirectionalLight3D.new()
|
|
sun.rotation_degrees = Vector3(-40, -35, 0)
|
|
sun.light_energy = 1.5
|
|
add_child(sun)
|
|
var fill := DirectionalLight3D.new()
|
|
fill.rotation_degrees = Vector3(-15, 140, 0)
|
|
fill.light_energy = 0.6
|
|
add_child(fill)
|
|
var under := DirectionalLight3D.new()
|
|
under.rotation_degrees = Vector3(35, 0, 0)
|
|
under.light_energy = 0.35
|
|
add_child(under)
|
|
|
|
# ground plane so locomotion reads against something
|
|
var ground := MeshInstance3D.new()
|
|
var plane := PlaneMesh.new()
|
|
plane.size = Vector2(12, 12)
|
|
ground.mesh = plane
|
|
var gmat := StandardMaterial3D.new()
|
|
gmat.albedo_color = Color(0.16, 0.17, 0.21)
|
|
gmat.roughness = 1.0
|
|
ground.set_surface_override_material(0, gmat)
|
|
add_child(ground)
|
|
|
|
var doc := GLTFDocument.new()
|
|
var state := GLTFState.new()
|
|
if doc.append_from_file(GLTF_PATH, state) != OK:
|
|
push_error("GLTF load failed")
|
|
return
|
|
model = doc.generate_scene(state)
|
|
add_child(model)
|
|
|
|
var baked := ImageTexture.create_from_image(Image.load_from_file(BAKED_PATH))
|
|
var body_normal := ImageTexture.create_from_image(Image.load_from_file(NORMAL_PATH))
|
|
var eye_tex := ImageTexture.create_from_image(Image.load_from_file(EYE_PATH))
|
|
var hair_tex := ImageTexture.create_from_image(Image.load_from_file(HAIR_PATH))
|
|
|
|
var stack: Array = [model]
|
|
while not stack.is_empty():
|
|
var n: Node = stack.pop_back()
|
|
if n is Skeleton3D and skel == null:
|
|
skel = n
|
|
if n is MeshInstance3D:
|
|
var lname := String(n.name).to_lower()
|
|
var mat := StandardMaterial3D.new()
|
|
mat.roughness = 0.85
|
|
if lname.contains("regularmale"):
|
|
mat.albedo_texture = baked
|
|
mat.normal_enabled = true
|
|
mat.normal_texture = body_normal
|
|
elif lname.contains("eye") and not lname.contains("brow"):
|
|
mat.albedo_texture = eye_tex
|
|
else:
|
|
mat.albedo_texture = hair_tex
|
|
for s in n.mesh.get_surface_count():
|
|
n.set_surface_override_material(s, mat)
|
|
for c in n.get_children():
|
|
stack.push_back(c)
|
|
|
|
_load_ual_clips()
|
|
|
|
cam = Camera3D.new()
|
|
cam.fov = 50
|
|
add_child(cam)
|
|
cam.current = true
|
|
|
|
hud = Label.new()
|
|
hud.position = Vector2(16, 12)
|
|
hud.add_theme_font_size_override("font_size", 22)
|
|
hud.add_theme_color_override("font_color", Color(0.95, 0.95, 0.9))
|
|
add_child(hud)
|
|
|
|
_play_clip(0)
|
|
_update_cam()
|
|
|
|
if TAKE_SHOTS:
|
|
await _take_shots()
|
|
print("SHOTS_DONE")
|
|
_play_clip(0)
|
|
interactive = true
|
|
|
|
# pulls the wanted UAL1 clips onto a local AnimationPlayer, remapping the
|
|
# "Armature/Skeleton3D" track prefix to this scene's skeleton (game approach,
|
|
# see PlayerController.LoadUalLibrary)
|
|
func _load_ual_clips() -> void:
|
|
var doc := GLTFDocument.new()
|
|
var state := GLTFState.new()
|
|
if doc.append_from_file(UAL1, state) != OK:
|
|
push_error("UAL1 load failed")
|
|
return
|
|
var ual := doc.generate_scene(state)
|
|
var src: AnimationPlayer = null
|
|
var stack: Array = [ual]
|
|
while not stack.is_empty():
|
|
var n: Node = stack.pop_back()
|
|
if n is AnimationPlayer:
|
|
src = n
|
|
break
|
|
for c in n.get_children():
|
|
stack.push_back(c)
|
|
if src == null:
|
|
push_error("no AnimationPlayer in UAL1")
|
|
return
|
|
|
|
player = AnimationPlayer.new()
|
|
add_child(player)
|
|
var skel_path := String(get_path_to(skel))
|
|
var lib := AnimationLibrary.new()
|
|
for clip_name in CLIPS:
|
|
if not src.has_animation(clip_name):
|
|
push_warning("UAL1 missing clip: " + clip_name)
|
|
continue
|
|
var anim := src.get_animation(clip_name).duplicate() as Animation
|
|
anim.loop_mode = Animation.LOOP_LINEAR
|
|
for i in anim.get_track_count():
|
|
var path := String(anim.track_get_path(i))
|
|
if path.contains("Armature/Skeleton3D"):
|
|
anim.track_set_path(i, path.replace("Armature/Skeleton3D", skel_path))
|
|
lib.add_animation(clip_name, anim)
|
|
player.add_animation_library("", lib)
|
|
print("loaded %d clips" % lib.get_animation_list().size())
|
|
ual.queue_free()
|
|
|
|
func _play_clip(idx: int) -> void:
|
|
clip_idx = wrapi(idx, 0, CLIPS.size())
|
|
var clip: String = CLIPS[clip_idx]
|
|
if player and player.has_animation(clip):
|
|
player.play(clip)
|
|
_update_hud()
|
|
|
|
func _update_hud() -> void:
|
|
if hud:
|
|
hud.text = "[%d/%d] %s\n←/→ switch Space pause drag rotate scroll zoom" \
|
|
% [clip_idx + 1, CLIPS.size(), CLIPS[clip_idx]]
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
if not interactive:
|
|
return
|
|
if event is InputEventKey and event.pressed and not event.echo:
|
|
match event.keycode:
|
|
KEY_RIGHT, KEY_D:
|
|
_play_clip(clip_idx + 1)
|
|
KEY_LEFT, KEY_A:
|
|
_play_clip(clip_idx - 1)
|
|
KEY_SPACE:
|
|
if player.is_playing():
|
|
player.pause()
|
|
else:
|
|
player.play()
|
|
elif event is InputEventMouseButton:
|
|
if event.button_index == MOUSE_BUTTON_LEFT:
|
|
dragging = event.pressed
|
|
elif event.pressed and event.button_index == MOUSE_BUTTON_WHEEL_UP:
|
|
orbit_dist = clampf(orbit_dist * 0.90, 0.35, 8.0)
|
|
_update_cam()
|
|
elif event.pressed and event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
|
|
orbit_dist = clampf(orbit_dist / 0.90, 0.35, 8.0)
|
|
_update_cam()
|
|
elif event is InputEventMouseMotion and dragging:
|
|
orbit_yaw -= event.relative.x * 0.008
|
|
orbit_pitch = clampf(orbit_pitch + event.relative.y * 0.008, -1.3, 1.3)
|
|
_update_cam()
|
|
|
|
func _update_cam() -> void:
|
|
var dir := Vector3(
|
|
sin(orbit_yaw) * cos(orbit_pitch),
|
|
sin(orbit_pitch),
|
|
cos(orbit_yaw) * cos(orbit_pitch))
|
|
cam.look_at_from_position(orbit_target + dir * orbit_dist, orbit_target)
|
|
|
|
func _snap(shot_name: String) -> void:
|
|
await RenderingServer.frame_post_draw
|
|
var img := get_viewport().get_texture().get_image()
|
|
img.save_png(SHOT_DIR + shot_name + ".png")
|
|
print("shot saved: ", SHOT_DIR + shot_name + ".png")
|
|
|
|
func _take_shots() -> void:
|
|
for spec in [["Jog_Fwd_Loop", 0.4], ["Dance_Loop", 1.2], ["Punch_Jab", 0.5]]:
|
|
var clip: String = spec[0]
|
|
if not player.has_animation(clip):
|
|
continue
|
|
player.play(clip)
|
|
await get_tree().create_timer(spec[1]).timeout
|
|
await _snap("anim_" + clip.to_lower())
|