Files
Diabolo/Demon_v0.19/reviews/infernal_v01/review.gd
T

88 lines
5.5 KiB
GDScript

extends Node3D
var paused=false
var actor
var carrier
var camera: Camera3D
var heading: Label
var folder="res://captures/infernal"
var max_error=0.0
var max_yaw=0.0
func _ready():call_deferred("run")
func setup_studio():
var world=WorldEnvironment.new();add_child(world);world.environment=Environment.new()
world.environment.background_mode=Environment.BG_COLOR;world.environment.background_color=Color("242932")
world.environment.ambient_light_source=Environment.AMBIENT_SOURCE_COLOR;world.environment.ambient_light_color=Color("d1d9e5");world.environment.ambient_light_energy=.7
world.environment.tonemap_mode=Environment.TONE_MAPPER_FILMIC
for at in [Vector3(-3,5,5),Vector3(4,3,2),Vector3(0,4,-4)]:
var light=OmniLight3D.new();add_child(light);light.position=at;light.light_energy=3.5;light.omni_range=30;light.shadow_enabled=true
var floor_node=MeshInstance3D.new();add_child(floor_node);floor_node.mesh=BoxMesh.new();floor_node.mesh.size=Vector3(80,.08,80);floor_node.position=Vector3(0,-.045,10)
var material=StandardMaterial3D.new();material.albedo_color=Color("454b55");material.roughness=.85;floor_node.material_override=material
camera=Camera3D.new();add_child(camera);camera.projection=Camera3D.PROJECTION_ORTHOGONAL;camera.current=true
var layer=CanvasLayer.new();add_child(layer);heading=Label.new();layer.add_child(heading);heading.position=Vector2(30,22);heading.add_theme_font_size_override("font_size",24)
carrier=Node3D.new();add_child(carrier)
actor=preload("res://succubus_actor.gd").new(preload("res://reviews/infernal_v01/infernal_game.glb"));carrier.add_child(actor);actor.rotation=Vector3.ZERO
actor.gait=preload("res://reviews/infernal_v01/infernal_gait.gd").new();actor.configure(self);actor.set_process(false)
func advance(direction,speed):
carrier.position+=direction*speed/24.0
if direction.length_squared()>.1:actor.rotation.y=lerp_angle(actor.rotation.y,atan2(direction.x,direction.z),10.0/24)
actor._process(1.0/24)
for foot in actor.gait.feet:
max_error=maxf(max_error,actor.gait.point("foot."+foot.side).distance_to(foot.target))
max_yaw=maxf(max_yaw,absf(wrapf(foot.yaw-actor.global_rotation.y,-PI,PI)))
func reset():
actor.restore_animation_pose();carrier.position=Vector3.ZERO;actor.rotation=Vector3.ZERO;actor.striking=false;actor.animator.play(actor.clips["Idle"],0.0,1.0);actor.animator.seek(0,true);actor.remember_animation_pose();actor.reset_gait()
func save_frame(sequence,frame):
await RenderingServer.frame_post_draw
assert(get_viewport().get_texture().get_image().save_png(folder+"/"+sequence+"/%03d.png"%frame)==OK)
func run():
for sequence in ["full","outfit","action","portrait"]:DirAccess.make_dir_recursive_absolute(folder+"/"+sequence)
setup_studio();await get_tree().process_frame
if "--qa-stills" in OS.get_cmdline_user_args():
DirAccess.make_dir_recursive_absolute(folder+"/still")
for index in range(4):
advance(Vector3.ZERO,0)
var angle=index*PI/2;var focus=Vector3(0,1.25,0);camera.size=3.0;camera.position=focus+Vector3(sin(angle)*5,.25,cos(angle)*5);camera.look_at(focus)
heading.text="ПОКРАСКА · ПРОВЕРКА СТОРОН";await save_frame("still",index)
var focus=Vector3(0,2.1,0);camera.size=.92;camera.position=focus+Vector3(0,.07,5);camera.look_at(focus)
heading.text="ЛИЦО · ПРОВЕРКА ПОКРАСКИ";await save_frame("still",4)
actor.strike(1.8)
for frame in range(24):advance(Vector3.ZERO,0)
focus=Vector3(0,1.25,0);camera.size=3.15;camera.position=focus+Vector3(2,.6,7);camera.look_at(focus)
heading.text="WHIP · ПРОВЕРКА";await save_frame("still",5)
reset()
for detail in [[6,1.56,1.15,0.0,"КОРСЕТ И ВОРОТНИК · ПО ЛИНИЯМ СКУЛЬПТА"],[7,1.32,.70,0.0,"НИЖНЯЯ КРОМКА КОРСЕТА"],[8,.32,.80,0.0,"САПОГИ · КРАЙ ПО ОБОДКУ"],[9,1.56,1.15,PI,"КОРСЕТ · ВИД СЗАДИ"]]:
advance(Vector3.ZERO,0)
var detail_focus=Vector3(0,detail[1],0);camera.size=detail[2];camera.position=detail_focus+Vector3(sin(detail[3])*5,.02,cos(detail[3])*5);camera.look_at(detail_focus)
heading.text=detail[4];await save_frame("still",detail[0])
get_tree().quit();return
heading.text="INFERNAL / STL · ХОДЬБА, ПОВОРОТ И ОСТАНОВКА"
for frame in range(144):
var direction=Vector3.BACK if frame<72 else Vector3(.7,0,.7).normalized()
advance(direction,2.5 if frame<110 else 0)
var focus=carrier.position+Vector3(0,1.25,0);camera.size=3.15;camera.position=focus+Vector3(2.0,.7,7);camera.look_at(focus)
await save_frame("full",frame)
reset();heading.text="ПОКРАСКА · КРАСНАЯ КОЖА / ЧЁРНЫЙ КОМПЛЕКТ"
for frame in range(120):
advance(Vector3.ZERO,0)
var focus=Vector3(0,1.25,0);var angle=TAU*frame/120;camera.size=3.0;camera.position=focus+Vector3(sin(angle)*5,.25,cos(angle)*5);camera.look_at(focus)
await save_frame("outfit",frame)
reset();heading.text="ПЕРЕНОС АНИМАЦИИ · WHIP"
for frame in range(96):
if frame==12:actor.strike(1.8)
advance(Vector3.ZERO,0)
var focus=Vector3(0,1.25,0);camera.size=3.15;camera.position=focus+Vector3(2,.6,7);camera.look_at(focus)
await save_frame("action",frame)
reset();heading.text="ЛИЦО · КРУПНЫЙ ПЛАН"
for frame in range(72):
advance(Vector3.ZERO,0)
var focus=Vector3(0,2.10,0);var angle=sin(TAU*frame/72)*.22;camera.size=.92;camera.position=focus+Vector3(sin(angle)*5,.07,cos(angle)*5);camera.look_at(focus)
await save_frame("portrait",frame)
print("INFERNAL REVIEW METRICS ",JSON.stringify({"max_ik_error":max_error,"max_ankle_twist_degrees":rad_to_deg(max_yaw)}))
get_tree().quit()