-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrender_dance_test.gd
More file actions
77 lines (66 loc) · 2.44 KB
/
Copy pathrender_dance_test.gd
File metadata and controls
77 lines (66 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
## Visual check of the retargeted animation: builds Starter_01, plays the clip
## and renders a filmstrip of poses to user://render_dance_<n>.png. Needs a window:
## godot -s res://tests/render_dance_test.gd --resolution 480x640
extends SceneTree
const LIBRARY := "res://demos/animations/silly_dancing.fbx" # imports as an AnimationLibrary
const ANIMATION := "mixamo_com"
const TIMES: Array[float] = [0.0, 0.9, 1.8, 2.7]
## Toggle to compare the combined-mesh path against separate part meshes.
const COMBINE := true
func _init() -> void:
call_deferred("_run")
func _run() -> void:
ProjectSettings.set_setting("kickdot/build/combine_meshes", COMBINE)
var recipe := SKRecipe.load_from_file("res://synty_assets/characters/Starter_01.sk")
var library := SKPartLibrary.new()
library.scan()
var colors := SKColorEngine.new()
colors.setup()
var builder := SKCharacterBuilder.new(library, colors)
builder.animation_library = load(LIBRARY)
var character := builder.build(recipe)
if character == null:
printerr("RENDER DANCE: build failed")
quit(1)
return
root.add_child(character)
var light := DirectionalLight3D.new()
light.rotation_degrees = Vector3(-45, 30, 0)
light.light_energy = 1.2
root.add_child(light)
var fill := DirectionalLight3D.new()
fill.rotation_degrees = Vector3(-20, -120, 0)
fill.light_energy = 0.5
root.add_child(fill)
var environment := WorldEnvironment.new()
var env := Environment.new()
env.background_mode = Environment.BG_COLOR
env.background_color = Color(0.2, 0.22, 0.25)
env.ambient_light_source = Environment.AMBIENT_SOURCE_COLOR
env.ambient_light_color = Color(0.7, 0.7, 0.75)
env.ambient_light_energy = 0.6
environment.environment = env
root.add_child(environment)
var camera := Camera3D.new()
camera.position = Vector3(0, 1.0, 3.0)
camera.look_at_from_position(camera.position, Vector3(0, 0.95, 0))
root.add_child(camera)
camera.make_current()
var player: AnimationPlayer = null
for child in character.get_children():
if child is AnimationPlayer:
player = child
if player == null:
printerr("RENDER DANCE: no AnimationPlayer on the character")
quit(1)
return
player.play(ANIMATION)
for i in TIMES.size():
player.seek(TIMES[i], true)
for f in 4:
await process_frame
var image := root.get_viewport().get_texture().get_image()
var path := "user://render_dance_%d.png" % i
image.save_png(path)
print("RENDER DANCE: t=%.2fs -> %s" % [TIMES[i], ProjectSettings.globalize_path(path)])
quit(0)