updates
This commit is contained in:
parent
276d43613d
commit
4298caf5cb
552 changed files with 42990 additions and 776 deletions
|
|
@ -1,35 +1,77 @@
|
|||
extends SceneTree
|
||||
## Builds res://game/resources/player_animations.res: the KayKit Rig_Medium clips the farmer
|
||||
## uses, copied out of the shared animation files into one AnimationLibrary so the player
|
||||
## scene's AnimationPlayer can reference (and the editor can preview) them.
|
||||
## Tracks for bones the mannequin lacks (handslot.l/.r) are dropped; loop flags are set here
|
||||
## because every source clip is imported as non-looping. Source assets are not modified.
|
||||
## Re-run after editing CLIPS (editor closed):
|
||||
## Builds the KayKit animation libraries the game's characters use, copied out of the shared
|
||||
## animation files into one AnimationLibrary per rig so AnimationPlayers can reference (and the
|
||||
## editor can preview) them:
|
||||
## res://game/resources/player_animations.res Rig_Medium: the scarecrow and ground thieves
|
||||
## res://game/resources/breaker_animations.res Rig_Large: the fence breaker
|
||||
## Tracks for bones the mannequin lacks (handslot.l/.r on the medium one) are dropped; loop flags
|
||||
## are set here because every source clip is imported as non-looping. Source assets are not
|
||||
## modified. Re-run after editing BUILDS (editor closed):
|
||||
## godot --headless --path . --script res://game/tools/build_player_animations.gd
|
||||
|
||||
const MANNEQUIN := "res://assets/kaykit_characters/characters/Mannequin_Medium.glb"
|
||||
const ANIM_DIR := "res://assets/kaykit_characters/animations/Rig_Medium/"
|
||||
const OUTPUT := "res://game/resources/player_animations.res"
|
||||
const SKELETON_PATH := "Rig_Medium/Skeleton3D"
|
||||
const KIT := "res://assets/kaykit_characters/"
|
||||
## Per library: mannequin, animation folder, skeleton path, output, and clips (name as in
|
||||
## KayKit -> [source file, loops]).
|
||||
const BUILDS := [
|
||||
{
|
||||
"mannequin": KIT + "characters/Mannequin_Medium.glb",
|
||||
"anims": KIT + "animations/Rig_Medium/",
|
||||
"skeleton": "Rig_Medium/Skeleton3D",
|
||||
"output": "res://game/resources/player_animations.res",
|
||||
"clips": {
|
||||
"Idle_A": ["Rig_Medium_General.glb", true],
|
||||
"Idle_B": ["Rig_Medium_General.glb", true],
|
||||
"Interact": ["Rig_Medium_General.glb", false],
|
||||
"PickUp": ["Rig_Medium_General.glb", false],
|
||||
"Use_Item": ["Rig_Medium_General.glb", false],
|
||||
"Walking_A": ["Rig_Medium_MovementBasic.glb", true],
|
||||
"Running_A": ["Rig_Medium_MovementBasic.glb", true],
|
||||
"Sneaking": ["Rig_Medium_MovementAdvanced.glb", true],
|
||||
"Digging": ["Rig_Medium_Tools.glb", true],
|
||||
"Chopping": ["Rig_Medium_Tools.glb", true],
|
||||
"Hammering": ["Rig_Medium_Tools.glb", true],
|
||||
"Lockpicking": ["Rig_Medium_Tools.glb", true],
|
||||
"Melee_Unarmed_Attack_Punch_A": ["Rig_Medium_CombatMelee.glb", true],
|
||||
"Hit_A": ["Rig_Medium_General.glb", false],
|
||||
"Waving": ["Rig_Medium_Simulation.glb", false],
|
||||
"Cheering": ["Rig_Medium_Simulation.glb", true],
|
||||
"Death_A": ["Rig_Medium_General.glb", false],
|
||||
},
|
||||
},
|
||||
{
|
||||
"mannequin": KIT + "characters/Mannequin_Large.glb",
|
||||
"anims": KIT + "animations/Rig_Large/",
|
||||
"skeleton": "Rig_Large/Skeleton3D",
|
||||
"output": "res://game/resources/breaker_animations.res",
|
||||
"clips": {
|
||||
"Idle_A": ["Rig_Large_General.glb", true],
|
||||
"Walking_A": ["Rig_Large_MovementBasic.glb", true],
|
||||
"Running_A": ["Rig_Large_MovementBasic.glb", true],
|
||||
"Melee_2H_Idle": ["Rig_Large_CombatMelee.glb", true],
|
||||
"Melee_2H_Attack": ["Rig_Large_CombatMelee.glb", true],
|
||||
"Melee_2H_Slam": ["Rig_Large_CombatMelee.glb", true],
|
||||
"Hit_A": ["Rig_Large_General.glb", false],
|
||||
"Death_A": ["Rig_Large_General.glb", false],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
## Clip name (kept as in KayKit) -> [source file, loops].
|
||||
const CLIPS := {
|
||||
"Idle_A": ["Rig_Medium_General.glb", true],
|
||||
"Idle_B": ["Rig_Medium_General.glb", true],
|
||||
"Interact": ["Rig_Medium_General.glb", false],
|
||||
"PickUp": ["Rig_Medium_General.glb", false],
|
||||
"Use_Item": ["Rig_Medium_General.glb", false],
|
||||
"Walking_A": ["Rig_Medium_MovementBasic.glb", true],
|
||||
"Running_A": ["Rig_Medium_MovementBasic.glb", true],
|
||||
"Digging": ["Rig_Medium_Tools.glb", true],
|
||||
"Chopping": ["Rig_Medium_Tools.glb", true],
|
||||
"Hammering": ["Rig_Medium_Tools.glb", true],
|
||||
"Waving": ["Rig_Medium_Simulation.glb", false],
|
||||
}
|
||||
var _mannequin := ""
|
||||
var _anim_dir := ""
|
||||
var _output := ""
|
||||
var _skeleton := ""
|
||||
var _clips := {}
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
var ok := _build()
|
||||
var ok := true
|
||||
for b: Dictionary in BUILDS:
|
||||
_mannequin = b["mannequin"]
|
||||
_anim_dir = b["anims"]
|
||||
_output = b["output"]
|
||||
_skeleton = b["skeleton"]
|
||||
_clips = b["clips"]
|
||||
ok = _build() and ok
|
||||
quit(0 if ok else 1)
|
||||
|
||||
|
||||
|
|
@ -41,10 +83,10 @@ func _build() -> bool:
|
|||
var sources := {} # file -> instantiated scene root (freed at the end)
|
||||
var dropped := 0
|
||||
var ok := true
|
||||
for clip: String in CLIPS:
|
||||
var file: String = CLIPS[clip][0]
|
||||
for clip: String in _clips:
|
||||
var file: String = _clips[clip][0]
|
||||
if not sources.has(file):
|
||||
var scene := load(ANIM_DIR + file) as PackedScene
|
||||
var scene := load(_anim_dir + file) as PackedScene
|
||||
if scene == null:
|
||||
push_error("missing animation file " + file)
|
||||
ok = false
|
||||
|
|
@ -58,36 +100,36 @@ func _build() -> bool:
|
|||
var anim := player.get_animation(clip).duplicate(true) as Animation
|
||||
for t in range(anim.get_track_count() - 1, -1, -1):
|
||||
var path := anim.track_get_path(t)
|
||||
var keep := String(path.get_concatenated_names()) == SKELETON_PATH \
|
||||
var keep := String(path.get_concatenated_names()) == _skeleton \
|
||||
and path.get_subname_count() == 1 and bones.has(String(path.get_subname(0)))
|
||||
if not keep:
|
||||
anim.remove_track(t)
|
||||
dropped += 1
|
||||
anim.loop_mode = Animation.LOOP_LINEAR if CLIPS[clip][1] else Animation.LOOP_NONE
|
||||
anim.loop_mode = Animation.LOOP_LINEAR if _clips[clip][1] else Animation.LOOP_NONE
|
||||
library.add_animation(clip, anim)
|
||||
for file: String in sources:
|
||||
(sources[file] as Node).free()
|
||||
if not ok:
|
||||
return false
|
||||
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(OUTPUT.get_base_dir()))
|
||||
var err := ResourceSaver.save(library, OUTPUT)
|
||||
DirAccess.make_dir_recursive_absolute(ProjectSettings.globalize_path(_output.get_base_dir()))
|
||||
var err := ResourceSaver.save(library, _output)
|
||||
if err != OK:
|
||||
push_error("could not save %s (error %d)" % [OUTPUT, err])
|
||||
push_error("could not save %s (error %d)" % [_output, err])
|
||||
return false
|
||||
print("saved %s: %d clips, %d foreign tracks dropped" % [OUTPUT, library.get_animation_list().size(), dropped])
|
||||
print("saved %s: %d clips, %d foreign tracks dropped" % [_output, library.get_animation_list().size(), dropped])
|
||||
return true
|
||||
|
||||
|
||||
func _mannequin_bones() -> Dictionary:
|
||||
var scene := load(MANNEQUIN) as PackedScene
|
||||
var scene := load(_mannequin) as PackedScene
|
||||
if scene == null:
|
||||
push_error("missing mannequin " + MANNEQUIN)
|
||||
push_error("missing mannequin " + _mannequin)
|
||||
return {}
|
||||
var root := scene.instantiate()
|
||||
var skel := root.get_node_or_null(SKELETON_PATH) as Skeleton3D
|
||||
var skel := root.get_node_or_null(_skeleton) as Skeleton3D
|
||||
var bones := {}
|
||||
if skel == null:
|
||||
push_error("mannequin skeleton not found at " + SKELETON_PATH)
|
||||
push_error("mannequin skeleton not found at " + _skeleton)
|
||||
else:
|
||||
for b in skel.get_bone_count():
|
||||
bones[skel.get_bone_name(b)] = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue