diff --git a/assets/models/characters/batrix.glb b/assets/models/characters/batrix.glb index 9c63208..63005fb 100644 --- a/assets/models/characters/batrix.glb +++ b/assets/models/characters/batrix.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:51862a792eee74a793cd2f89d13d5c2a5f1fa85e52a038463b973a4422fb3ff7 -size 706128 +oid sha256:58a709e125b8da488eae0e79df1ddc6c1cc28931d999f4c68bfa2f75c220bb97 +size 704784 diff --git a/assets/models/characters/batrix.glb.import b/assets/models/characters/batrix.glb.import index fd7743d..f393faa 100644 --- a/assets/models/characters/batrix.glb.import +++ b/assets/models/characters/batrix.glb.import @@ -29,7 +29,7 @@ animation/import=true animation/fps=30 animation/trimming=false animation/remove_immutable_tracks=true -animation/import_rest_as_RESET=false +animation/import_rest_as_RESET=true import_script/path="" _subresources={ "materials": { diff --git a/resources/materials/characters/batrix_mat.tres b/resources/materials/characters/batrix_mat.tres index 6fe10ac..2409deb 100644 --- a/resources/materials/characters/batrix_mat.tres +++ b/resources/materials/characters/batrix_mat.tres @@ -3,4 +3,5 @@ [ext_resource type="Texture2D" uid="uid://cv5cnlgxx3rud" path="res://assets/textures/characters/batrix_diffuse.png" id="1_8x1pe"] [resource] +cull_mode = 2 albedo_texture = ExtResource("1_8x1pe") diff --git a/scenes/player.tscn b/scenes/player.tscn index dbada43..441b8c9 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://b73y71y3efmv"] +[gd_scene load_steps=28 format=3 uid="uid://b73y71y3efmv"] [ext_resource type="Script" path="res://scripts/player/player.gd" id="1_xt3i8"] [ext_resource type="Material" uid="uid://cc18ee0wbfoud" path="res://resources/materials/debug/debug_player.tres" id="2_0p422"] @@ -6,6 +6,8 @@ [ext_resource type="PackedScene" uid="uid://b4q85h3ndkh5u" path="res://assets/models/characters/batrix.glb" id="3_ld2i8"] [ext_resource type="Script" path="res://scripts/player/player_animator.gd" id="4_adlgp"] [ext_resource type="Material" uid="uid://bdi02rpvdukem" path="res://resources/materials/debug/debug_attack.tres" id="4_ll2ct"] +[ext_resource type="Script" path="res://scripts/effects/bone_to_flatten.gd" id="6_cumn2"] +[ext_resource type="Script" path="res://scripts/effects/bone_flattener.gd" id="6_iug5b"] [sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_tes4q"] animation = &"+idle_L" @@ -32,11 +34,60 @@ states/+idle_R/position = Vector2(351, 168) transitions = ["Start", "+idle_L", SubResource("AnimationNodeStateMachineTransition_tdamk"), "+idle_R", "+idle_L", SubResource("AnimationNodeStateMachineTransition_gk5g1"), "+idle_L", "+idle_R", SubResource("AnimationNodeStateMachineTransition_v3m8c")] [sub_resource type="AnimationNodeBlendTree" id="AnimationNodeBlendTree_f4bn3"] -graph_offset = Vector2(-111.839, -0.760132) nodes/StateMachine/node = SubResource("AnimationNodeStateMachine_yk01a") nodes/StateMachine/position = Vector2(40, 140) node_connections = [&"output", 0, &"StateMachine"] +[sub_resource type="Curve" id="Curve_03vie"] +_data = [Vector2(0.952555, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_x7hu0"] +min_value = -1.0 +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.145985, 1), 0.0, 0.0, 0, 0, Vector2(0.80292, -1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 4 + +[sub_resource type="Resource" id="Resource_komvq"] +script = ExtResource("6_cumn2") +bone_names = PackedStringArray("Tuft_base") +amount_by_pitch_curve = SubResource("Curve_03vie") +amount_by_yaw_curve = SubResource("Curve_x7hu0") +consider_side = true +yaw_fraction = 1.0 +do_position = false +position_x_amount = 0.0 +do_rotation = true +rotation_x_amount = 0.0 +mirror_rot_x = false +consider_side_rot_x = false +rotation_y_amount = 0.53 +mirror_rot_y = false +consider_side_rot_y = false +rotation_z_amount = 0.0 +mirror_rot_z = false +consider_side_rot_z = false +do_scale = false + +[sub_resource type="Curve" id="Curve_dj6ba"] +_data = [Vector2(0, 0), 0.0, 0.333126, 0, 0, Vector2(1, 1), 2.20052, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_4c21p"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 2 + +[sub_resource type="Curve" id="Curve_6imy2"] +_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.265734, 0.538352), 1.71284, 1.71284, 0, 0, Vector2(0.86014, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] +point_count = 4 + +[sub_resource type="Curve" id="Curve_2gav4"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0] +point_count = 1 + +[sub_resource type="Curve" id="Curve_suux4"] +_data = [Vector2(0, 1), 0.0, 0.0, 0, 0] +point_count = 1 + [sub_resource type="CylinderShape3D" id="CylinderShape3D_apl1i"] height = 1.8 radius = 0.3 @@ -61,293 +112,145 @@ _collision_debug_material = ExtResource("2_0p422") [node name="Model" parent="." instance=ExtResource("3_ld2i8")] [node name="Skeleton3D" parent="Model/Armature" index="0"] -bones/0/position = Vector3(0.567539, 1.0142, -0.0385139) -bones/0/rotation = Quaternion(-0.653816, -0.159578, -0.724422, 0.149238) -bones/1/position = Vector3(9.7503e-05, 0.0319142, -0.124524) -bones/1/rotation = Quaternion(0.000141483, 0.789452, 0.613812, -0.000224471) -bones/4/position = Vector3(-0.0330688, 0.915834, -0.0303839) -bones/4/rotation = Quaternion(0.197308, 0.0228376, -0.108266, 0.974077) -bones/5/rotation = Quaternion(0.0752077, 0.21432, -0.0629145, 0.971829) -bones/6/rotation = Quaternion(-0.418388, 0.157329, -0.0353445, 0.89384) -bones/7/rotation = Quaternion(0.347296, -0.0558377, 0.309901, 0.883306) +bones/0/rotation = Quaternion(0.500003, -0.499997, -0.499997, 0.500003) +bones/1/rotation = Quaternion(-0.500006, 0.5, 0.499994, 0.5) +bones/6/rotation = Quaternion(-0.0323581, 2.46001e-07, 8.00608e-09, 0.999476) +bones/7/rotation = Quaternion(0.123965, -2.40098e-07, -2.92456e-09, 0.992287) bones/7/scale = Vector3(1, 1, 1) -bones/8/rotation = Quaternion(-0.227834, -0.357695, -0.0924454, 0.900888) -bones/9/rotation = Quaternion(0.197471, 0.678974, 0.678974, -0.19747) -bones/9/scale = Vector3(0.891616, 1, 1.06075) -bones/10/position = Vector3(0.0152963, 0.000225159, -0.00485514) -bones/10/rotation = Quaternion(1.45713e-08, -0.00367792, -1.21489e-07, 0.999993) -bones/10/scale = Vector3(0.999936, 1, 0.397139) -bones/11/position = Vector3(0.0392888, -1.14826e-06, -0.00333351) -bones/12/position = Vector3(-0.0495715, -2.66398e-06, 0.0147187) -bones/13/position = Vector3(-0.00910764, -2.60105e-08, 0.000409521) -bones/14/position = Vector3(-0.0134209, 3.92448e-08, -0.0184936) -bones/17/scale = Vector3(0.891616, 1, 1.06075) -bones/18/position = Vector3(-0.0156255, 0.000225219, -0.00384245) -bones/18/rotation = Quaternion(7.07843e-09, -0.00302151, 8.84941e-08, 0.999995) -bones/18/scale = Vector3(0.999946, 1, 0.538637) -bones/19/position = Vector3(-0.0392888, -1.11645e-06, -0.00209811) -bones/19/rotation = Quaternion(-6.21725e-15, -5.94129e-08, -1.49012e-07, 1) -bones/20/position = Vector3(0.0495715, -2.6437e-06, 0.030169) -bones/21/position = Vector3(0.00910762, -2.19886e-08, 0.00452035) -bones/22/position = Vector3(0.0134209, 7.85662e-08, -0.0283991) -bones/25/position = Vector3(0.0439141, 0.0799136, 0.0942768) -bones/25/rotation = Quaternion(0.161417, 0.667625, 0.688436, -0.232975) -bones/25/scale = Vector3(1, 1, 1) -bones/29/position = Vector3(-0.0447405, 0.0806959, 0.0937516) -bones/29/rotation = Quaternion(-0.160114, 0.667183, 0.68874, 0.234237) -bones/29/scale = Vector3(1, 1, 1) -bones/33/rotation = Quaternion(-0.0377882, -0.558876, 0.827082, -0.0465429) -bones/33/scale = Vector3(1, 1, 1) -bones/34/rotation = Quaternion(-0.0770293, 0.0106829, 0.115433, 0.990266) -bones/35/rotation = Quaternion(-0.00282362, 0.992799, -0.117349, 0.0238882) -bones/36/rotation = Quaternion(0.627063, -1.5307e-07, -1.28063e-06, 0.778968) -bones/37/rotation = Quaternion(-0.034235, -3.57418e-07, 8.86969e-08, 0.999414) -bones/39/rotation = Quaternion(0.438293, 0.0820193, -0.386483, 0.807343) -bones/39/scale = Vector3(1, 1, 1) -bones/40/rotation = Quaternion(-0.604731, 3.40943e-07, 4.58113e-07, 0.79643) -bones/40/scale = Vector3(1, 1, 1) -bones/41/rotation = Quaternion(0.0772043, -1.03966e-06, -1.20713e-07, 0.997015) +bones/8/rotation = Quaternion(-0.0917916, -2.67583e-15, 2.18848e-08, 0.995778) +bones/9/position = Vector3(-0.074, 0.011816, 0.0814253) +bones/9/rotation = Quaternion(1.15202e-07, 0.707107, 0.707107, -5.33851e-08) +bones/9/scale = Vector3(1, 1, 1) +bones/21/rotation = Quaternion(0.19747, 0.678974, 0.678974, -0.19747) +bones/31/rotation = Quaternion(-6.21725e-15, -5.94129e-08, -1.49012e-07, 1) +bones/37/rotation = Quaternion(0.19747, 0.678974, 0.678974, -0.19747) +bones/37/scale = Vector3(1, 1, 1) +bones/41/rotation = Quaternion(-0.19747, 0.678974, 0.678974, 0.19747) bones/41/scale = Vector3(1, 1, 1) -bones/42/rotation = Quaternion(-0.414233, 5.12702e-07, 8.90282e-07, 0.910171) -bones/43/rotation = Quaternion(0.046704, 0.031091, -0.532742, 0.844416) -bones/44/rotation = Quaternion(0.0317562, -0.516807, -0.588499, 0.620944) -bones/44/scale = Vector3(1, 1, 1) -bones/45/position = Vector3(-3.06314e-09, 0.281682, 2.96818e-08) -bones/45/rotation = Quaternion(0.0833555, -5.13783e-05, -4.83194e-05, 0.99652) +bones/45/rotation = Quaternion(4.66323e-07, -0.535908, 0.844276, -1.6823e-07) bones/45/scale = Vector3(1, 1, 1) -bones/46/rotation = Quaternion(0.00109405, 0.0100829, -1.09932e-05, 0.999949) -bones/47/position = Vector3(5.95018e-09, 0.0684659, -0.000149837) -bones/47/rotation = Quaternion(-0.384737, 0.0170222, -0.0147176, 0.922752) -bones/47/scale = Vector3(1, 1, 1) -bones/48/rotation = Quaternion(0.272952, 0.938437, 0.146398, 0.152975) -bones/49/rotation = Quaternion(0.58496, -0.153924, -0.0835467, 0.791928) -bones/50/rotation = Quaternion(0.510623, -0.0271032, -0.0393668, 0.858475) -bones/51/rotation = Quaternion(-0.329205, -0.636159, 0.30397, 0.628115) -bones/51/scale = Vector3(1, 1.10703, 1) -bones/52/rotation = Quaternion(-0.343634, -0.682552, 0.10805, 0.635896) -bones/52/scale = Vector3(1, 1.10703, 1) -bones/53/rotation = Quaternion(-0.0266082, 0.706555, -0.0266833, 0.706654) -bones/54/rotation = Quaternion(0.535804, 0.00768629, 0.0119315, 0.844223) -bones/54/scale = Vector3(1, 1, 1) -bones/55/rotation = Quaternion(0.620825, 0.0125364, 0.0158731, 0.783688) -bones/55/scale = Vector3(1, 1, 1) -bones/56/rotation = Quaternion(0.62093, -3.82302e-08, 2.35013e-08, 0.783866) -bones/57/rotation = Quaternion(-0.435356, 5.24382e-07, 1.1264e-06, 0.900258) -bones/57/scale = Vector3(1, 1.25706, 1) -bones/58/rotation = Quaternion(-0.435242, -0.00883197, 0.0181977, 0.900086) -bones/58/scale = Vector3(1, 1.25706, 1) -bones/59/rotation = Quaternion(-0.48135, -0.0244882, 0.0222, 0.875905) -bones/59/scale = Vector3(1, 1.1547, 1) -bones/61/rotation = Quaternion(0.535937, -0.00176, -0.00295408, 0.844251) -bones/61/scale = Vector3(1, 1, 1) -bones/62/rotation = Quaternion(0.62095, 0.00112225, 0.0014593, 0.783848) -bones/62/scale = Vector3(1, 1, 1) -bones/63/rotation = Quaternion(0.620932, 4.63237e-08, 1.17948e-09, 0.783865) -bones/64/rotation = Quaternion(-0.435355, 4.84367e-07, 1.16872e-06, 0.900259) -bones/64/scale = Vector3(1, 1.25706, 1) -bones/65/rotation = Quaternion(-0.435332, -0.000824713, 0.00164675, 0.900268) -bones/65/scale = Vector3(1, 1.25706, 1) -bones/66/rotation = Quaternion(-0.481708, 0.000115779, -0.00210062, 0.876329) -bones/66/scale = Vector3(1, 1.15478, 1) -bones/67/rotation = Quaternion(0.0361992, 0.706123, 0.0361283, 0.70624) -bones/68/rotation = Quaternion(0.535632, -0.020768, -0.0328374, 0.843557) -bones/69/rotation = Quaternion(0.620849, -0.00966183, -0.0122125, 0.783776) -bones/70/rotation = Quaternion(0.620931, 2.63989e-08, 1.24416e-08, 0.783866) -bones/71/rotation = Quaternion(-0.435356, 5.20539e-07, 1.16337e-06, 0.900259) -bones/71/scale = Vector3(1, 1.25706, 1) -bones/72/rotation = Quaternion(-0.435311, 0.00677148, -0.0140055, 0.900146) -bones/72/scale = Vector3(1, 1.25706, 1) -bones/73/rotation = Quaternion(-0.480719, 0.0323988, -0.0414881, 0.875293) -bones/73/scale = Vector3(1, 1.15484, 1) -bones/74/rotation = Quaternion(0.0569009, 0.704803, 0.0568902, 0.704825) +bones/46/rotation = Quaternion(-0.0181733, 2.38379e-07, 1.14098e-08, 0.999835) +bones/47/rotation = Quaternion(-1.20807e-07, 0.993087, -0.117383, 7.85287e-07) +bones/49/rotation = Quaternion(-0.034235, -3.57418e-07, 8.86969e-08, 0.999414) +bones/50/rotation = Quaternion(0.276203, -0.650931, -0.650931, -0.276203) +bones/51/rotation = Quaternion(0.403888, -2.98082e-07, -3.85178e-07, 0.914808) +bones/51/scale = Vector3(1, 1, 1) +bones/52/rotation = Quaternion(-0.512846, 3.82068e-07, 4.27952e-07, 0.858481) +bones/52/scale = Vector3(1, 1, 1) +bones/53/rotation = Quaternion(0.0772044, -1.03801e-06, -1.2885e-07, 0.997015) +bones/53/scale = Vector3(1, 1, 1) +bones/56/rotation = Quaternion(0.000780555, -0.0237052, 0.0502717, 0.998454) +bones/56/scale = Vector3(1, 1, 1) +bones/57/scale = Vector3(1, 1, 1) +bones/59/rotation = Quaternion(0.00161688, 2.38418e-07, 1.03441e-09, 0.999999) +bones/59/scale = Vector3(1, 1, 1) +bones/60/rotation = Quaternion(0.228541, 0.947226, 0.209053, -0.0826344) +bones/61/rotation = Quaternion(0.133438, -0.0949905, -0.147138, 0.97546) +bones/62/rotation = Quaternion(0.0362919, -0.00490006, -0.0475428, 0.998198) +bones/64/rotation = Quaternion(-0.497004, -0.574613, 0.266856, 0.592954) +bones/65/rotation = Quaternion(-0.0266082, 0.706555, -0.0266833, 0.706654) +bones/66/rotation = Quaternion(-8.29555e-05, 9.48293e-05, 0.0141926, 0.999899) +bones/66/scale = Vector3(1, 1, 1) +bones/67/rotation = Quaternion(2.73443e-05, -2.92389e-05, 0.0202266, 0.999795) +bones/67/scale = Vector3(1, 1, 1) +bones/70/rotation = Quaternion(-0.706943, -0.0143225, 0.0142829, 0.706981) +bones/71/rotation = Quaternion(-0.706726, -0.024286, 0.0243834, 0.70665) +bones/73/rotation = Quaternion(-7.74054e-05, 9.75834e-05, -0.00343725, 0.999994) +bones/73/scale = Vector3(1, 1, 1) +bones/74/rotation = Quaternion(2.5122e-05, -2.6431e-05, 0.00184074, 0.999998) bones/74/scale = Vector3(1, 1, 1) -bones/75/rotation = Quaternion(0.535595, -0.0227343, -0.0358256, 0.843408) -bones/76/rotation = Quaternion(0.62034, -0.0256826, -0.032427, 0.783241) -bones/77/rotation = Quaternion(0.620872, 1.78234e-09, -2.45018e-09, 0.783912) -bones/78/rotation = Quaternion(-0.43539, 5.31999e-07, 1.17767e-06, 0.900242) -bones/78/scale = Vector3(1, 1.25698, 1) -bones/79/rotation = Quaternion(-0.435017, 0.0180107, -0.0372377, 0.899472) -bones/79/scale = Vector3(1, 1.25698, 1) -bones/80/rotation = Quaternion(-0.479243, 0.0566498, -0.05705, 0.873992) -bones/80/scale = Vector3(1, 1.15485, 1) -bones/81/position = Vector3(6.08182e-09, 0.0684659, -0.000149772) -bones/81/rotation = Quaternion(-0.83341, 0.0114436, 0.000868296, 0.552536) -bones/82/position = Vector3(-4.93142e-09, 0.281682, 1.00855e-07) -bones/82/rotation = Quaternion(-0.67656, -2.96772e-06, -6.07607e-05, 0.736388) -bones/82/scale = Vector3(1, 1.00044, 1) -bones/83/position = Vector3(0.000916025, -0.00419328, -0.00166347) -bones/83/rotation = Quaternion(0.180101, 0.00275758, -0.0409847, 0.98279) -bones/83/scale = Vector3(1.12362, 1, 1) -bones/84/position = Vector3(-5.44242e-09, 0.0159595, 0.000181339) -bones/84/rotation = Quaternion(-0.0876969, 0.00686067, 0.0793036, 0.992962) -bones/85/rotation = Quaternion(-0.625566, -0.00166807, -0.42609, 0.653538) -bones/86/rotation = Quaternion(0.277777, 0.0519763, 0.711991, 0.642812) +bones/77/rotation = Quaternion(-0.707088, -0.00131944, 0.00128381, 0.707123) +bones/78/rotation = Quaternion(-0.707143, 0.0011801, -0.00107765, 0.707069) +bones/79/rotation = Quaternion(0.0361992, 0.706123, 0.0361283, 0.70624) +bones/81/rotation = Quaternion(-8.66251e-06, 9.56188e-06, -0.0155723, 0.999879) +bones/84/rotation = Quaternion(-0.707027, 0.0110055, -0.0109902, 0.707015) +bones/85/rotation = Quaternion(-0.706096, 0.0385178, -0.038402, 0.706024) +bones/86/rotation = Quaternion(0.0569009, 0.704803, 0.0568902, 0.704825) bones/86/scale = Vector3(1, 1, 1) -bones/87/rotation = Quaternion(0.694119, -0.0603821, 0.287612, 0.657139) -bones/87/scale = Vector3(1, 1, 1) -bones/88/position = Vector3(-8.39234e-08, 0.321426, -1.59652e-08) -bones/88/rotation = Quaternion(0.309542, 0.179254, 0.0888089, 0.929605) -bones/88/scale = Vector3(1, 1, 1) -bones/89/rotation = Quaternion(0.00106878, 0.214214, -0.000234455, 0.976786) -bones/90/position = Vector3(3.52468e-08, 0.0500794, -0.000109642) -bones/90/rotation = Quaternion(-0.164376, 0.243553, -0.0827229, 0.952271) -bones/90/scale = Vector3(1, 1, 1) -bones/91/rotation = Quaternion(-0.493568, 0.843461, 0.0982686, 0.187904) -bones/92/rotation = Quaternion(0.52804, 0.147693, 0.0941253, 0.830964) -bones/93/rotation = Quaternion(0.449224, 0.0242785, 0.0411689, 0.89214) -bones/94/rotation = Quaternion(-0.350045, 0.622991, -0.32694, 0.618434) -bones/94/scale = Vector3(1, 1.06804, 1) -bones/95/rotation = Quaternion(-0.366656, 0.669855, -0.130948, 0.632227) -bones/95/scale = Vector3(1, 1.06804, 1) -bones/96/rotation = Quaternion(-0.0266082, -0.706555, 0.0266833, 0.706654) -bones/97/rotation = Quaternion(0.588383, -0.00842914, -0.0114187, 0.808458) -bones/97/scale = Vector3(1, 1, 1) -bones/98/rotation = Quaternion(0.688839, -0.0139141, -0.0146803, 0.724632) +bones/87/rotation = Quaternion(-7.06026e-06, 1.40335e-05, -0.0424302, 0.999099) +bones/88/rotation = Quaternion(-1.06996e-07, 1.17384e-07, -0.0413655, 0.999144) +bones/90/rotation = Quaternion(-0.707107, 8.47153e-07, 9.00539e-07, 0.707107) +bones/91/rotation = Quaternion(-0.706502, 0.0292507, -0.0292488, 0.706501) +bones/92/rotation = Quaternion(-0.70463, 0.0592111, -0.0591898, 0.704619) +bones/93/rotation = Quaternion(-0.708275, 5.03263e-14, -2.84259e-07, 0.705936) +bones/94/rotation = Quaternion(-0.705843, -3.79543e-06, -5.06699e-05, 0.708368) +bones/97/rotation = Quaternion(-0.704198, -0.0522797, 0.0188281, 0.707826) +bones/98/rotation = Quaternion(0.0365982, -0.0425263, 0.740578, 0.669624) bones/98/scale = Vector3(1, 1, 1) -bones/99/rotation = Quaternion(0.688961, -2.70708e-08, -6.68325e-09, 0.724799) -bones/100/rotation = Quaternion(-0.39436, -4.76081e-07, -1.15066e-06, 0.918956) -bones/100/scale = Vector3(1, 1.37539, 1) -bones/101/rotation = Quaternion(-0.394254, 0.0080034, -0.0185771, 0.918779) -bones/101/scale = Vector3(1, 1.37539, 1) -bones/102/rotation = Quaternion(-0.453246, 0.0243879, -0.0218395, 0.890784) -bones/102/scale = Vector3(1, 1.21298, 1) -bones/104/rotation = Quaternion(0.542345, 0.0017824, 0.00294063, 0.840149) -bones/104/scale = Vector3(1, 1, 1) -bones/105/rotation = Quaternion(0.647328, -0.00117137, -0.00142015, 0.762209) -bones/105/scale = Vector3(1, 1, 1) -bones/106/rotation = Quaternion(0.64731, 4.27792e-08, 6.69029e-08, 0.762227) -bones/107/rotation = Quaternion(-0.419934, -5.57363e-07, -1.02599e-06, 0.907555) -bones/107/scale = Vector3(1, 1.29838, 1) -bones/108/rotation = Quaternion(-0.419911, 0.000796474, -0.0016606, 0.907564) -bones/108/scale = Vector3(1, 1.29838, 1) -bones/109/rotation = Quaternion(-0.478372, -0.000101237, 0.00211347, 0.878155) -bones/109/scale = Vector3(1, 1.16111, 1) -bones/110/rotation = Quaternion(0.0361992, -0.706123, -0.0361283, 0.70624) -bones/111/rotation = Quaternion(0.461427, 0.0178797, 0.0344952, 0.886327) -bones/111/scale = Vector3(1, 1, 1) -bones/112/rotation = Quaternion(0.573375, 0.00892216, 0.0127629, 0.819145) -bones/113/rotation = Quaternion(0.573451, -2.10681e-10, -1.21527e-08, 0.81924) -bones/114/rotation = Quaternion(-0.461816, -5.41306e-07, -1.12121e-06, 0.886976) -bones/114/scale = Vector3(1, 1.19474, 1) -bones/115/rotation = Quaternion(-0.461768, -0.00718372, 0.013798, 0.886864) -bones/115/scale = Vector3(1, 1.19474, 1) -bones/116/rotation = Quaternion(-0.517814, -0.0335062, 0.0412293, 0.853842) -bones/116/scale = Vector3(1, 1.09458, 1) -bones/117/rotation = Quaternion(0.0569009, -0.704803, -0.0568902, 0.704825) +bones/99/rotation = Quaternion(0.000780569, 0.0237052, -0.0502716, 0.998454) +bones/99/scale = Vector3(1, 1, 1) +bones/100/rotation = Quaternion(0.00234516, 3.8331e-05, 3.29257e-05, 0.999997) +bones/100/scale = Vector3(1, 1, 1) +bones/102/rotation = Quaternion(0.00161688, -2.38418e-07, -1.03441e-09, 0.999999) +bones/102/scale = Vector3(1, 1, 1) +bones/104/rotation = Quaternion(0.133438, 0.0949905, 0.147138, 0.97546) +bones/105/rotation = Quaternion(0.0362919, 0.00490006, 0.0475427, 0.998198) +bones/106/rotation = Quaternion(-0.467553, 0.526138, -0.458035, 0.542933) +bones/107/rotation = Quaternion(-0.497004, 0.574613, -0.266856, 0.592954) +bones/108/rotation = Quaternion(-0.0266082, -0.706555, 0.0266833, 0.706654) +bones/109/rotation = Quaternion(-8.29556e-05, -9.48397e-05, -0.0141926, 0.999899) +bones/109/scale = Vector3(1, 1, 1) +bones/110/scale = Vector3(1, 1, 1) +bones/112/rotation = Quaternion(-0.707107, -8.48703e-07, -8.9898e-07, 0.707107) +bones/113/rotation = Quaternion(-0.706943, 0.0143225, -0.0142829, 0.706981) +bones/116/rotation = Quaternion(-7.74053e-05, -9.75928e-05, 0.00343725, 0.999994) +bones/116/scale = Vector3(1, 1, 1) +bones/117/rotation = Quaternion(2.5122e-05, 2.64312e-05, -0.00184074, 0.999998) bones/117/scale = Vector3(1, 1, 1) -bones/118/rotation = Quaternion(0.394033, 0.0167214, 0.0389964, 0.918116) -bones/119/rotation = Quaternion(0.510238, 0.0211242, 0.035565, 0.859038) -bones/120/rotation = Quaternion(0.510675, -1.3473e-09, 1.5118e-08, 0.859774) -bones/121/rotation = Quaternion(-0.494634, -7.10919e-07, -1.03484e-06, 0.869102) -bones/121/scale = Vector3(1, 1.13164, 1) -bones/122/rotation = Quaternion(-0.49421, -0.0204615, 0.0359496, 0.868358) -bones/122/scale = Vector3(1, 1.13164, 1) -bones/123/rotation = Quaternion(-0.54785, -0.057849, 0.0581314, 0.832547) -bones/123/scale = Vector3(1, 1.05697, 1) -bones/124/position = Vector3(5.52811e-08, 0.0500794, -0.000109639) -bones/124/rotation = Quaternion(-0.759002, 0.116573, 0.0579373, 0.637942) -bones/125/position = Vector3(-6.60822e-08, 0.321426, 1.29505e-08) -bones/125/rotation = Quaternion(-0.582632, 0.0324997, 0.0965117, 0.806331) -bones/125/scale = Vector3(1, 1.03364, 1) -bones/126/position = Vector3(0.00645463, 0.000163225, -0.00321279) -bones/126/rotation = Quaternion(0.248427, -0.0258538, 0.267814, 0.930533) -bones/126/scale = Vector3(1, 1, 1) -bones/127/position = Vector3(-3.17814e-08, 0.0159596, 0.000181336) -bones/127/rotation = Quaternion(-0.0586372, 0.00568235, 0.12181, 0.990804) -bones/128/rotation = Quaternion(-0.373453, -0.106792, 0.0786078, 0.918123) -bones/129/position = Vector3(-0.02041, 0.110161, 0.0701683) -bones/129/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47963e-09, 0.999476) -bones/130/position = Vector3(-0.0231925, 0.0525023, 0.0957312) -bones/130/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47954e-09, 0.999476) -bones/131/position = Vector3(-0.0475043, 0.00182771, 0.0759945) -bones/131/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47955e-09, 0.999476) -bones/132/position = Vector3(0.0532017, 0.0600999, -0.104689) -bones/132/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47962e-09, 0.999476) -bones/133/position = Vector3(0.104047, 0.0637267, -0.0160225) -bones/133/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/134/position = Vector3(0.106215, 0.114178, -0.0470338) -bones/134/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/135/position = Vector3(0.0917037, 0.121637, 0.0437928) -bones/135/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/136/position = Vector3(0.078934, 0.0459583, 0.052201) -bones/136/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/137/position = Vector3(0.0455176, 0.0771403, 0.0871385) -bones/137/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) -bones/138/position = Vector3(0.0373181, 0.0229446, 0.0927835) -bones/138/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) -bones/139/position = Vector3(0.0452006, 0.139723, 0.0583473) -bones/139/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/140/position = Vector3(0.0680997, 0.177867, 0.0200778) -bones/140/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/141/position = Vector3(0.0623736, 0.193042, -0.0184664) -bones/141/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/142/position = Vector3(0.0631897, 0.189603, -0.0461285) -bones/142/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/143/position = Vector3(0.0916513, 0.157254, -0.0646591) -bones/143/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/144/position = Vector3(0.0568553, 0.144026, -0.0749491) -bones/144/rotation = Quaternion(0.0319005, -0.0215006, 0.268606, 0.962482) -bones/145/position = Vector3(-0.0718999, 0.0483116, -0.0838896) -bones/145/rotation = Quaternion(0.124908, 0.242139, 0.00659811, 0.962145) -bones/146/position = Vector3(-0.0955872, 0.0917892, -0.0608931) -bones/146/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/147/position = Vector3(-0.0925815, 0.0663705, 0.0173447) -bones/147/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/148/position = Vector3(-0.0917248, 0.0210278, -0.026088) -bones/148/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/149/position = Vector3(-0.0631635, 0.0598989, 0.0637847) -bones/149/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) -bones/150/position = Vector3(-0.0828961, 0.0140553, 0.0384805) -bones/150/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) -bones/151/position = Vector3(-0.0410443, 0.11106, 0.0530752) -bones/151/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/152/position = Vector3(-0.0563174, 0.131123, 0.0429151) -bones/152/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/153/position = Vector3(-0.0737954, 0.15438, 0.0136747) -bones/153/rotation = Quaternion(0.124908, 0.242139, 0.00659811, 0.962145) -bones/154/position = Vector3(-0.0844317, 0.156474, -0.0120187) -bones/154/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/155/position = Vector3(-0.0995648, 0.120594, -0.0449083) -bones/155/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/156/position = Vector3(-0.049779, 0.1293, -0.0740087) -bones/156/rotation = Quaternion(0.124908, 0.242139, 0.0065981, 0.962145) -bones/157/rotation = Quaternion(0.848756, 0.155256, -0.100081, 0.495473) -bones/157/scale = Vector3(1, 1, 1.00001) -bones/158/rotation = Quaternion(0.337552, -2.94285e-06, -7.1888e-07, 0.941307) -bones/159/position = Vector3(-1.40953e-09, 0.418127, 2.56939e-08) -bones/159/rotation = Quaternion(-0.450139, -0.0181762, 0.0388274, 0.891929) -bones/161/position = Vector3(-4.39908e-10, 0.418127, 7.55137e-08) -bones/161/rotation = Quaternion(-0.754362, -0.0111454, 0.0100554, 0.656287) -bones/162/rotation = Quaternion(-0.614397, -7.88994e-07, -1.52511e-06, 0.788997) -bones/162/scale = Vector3(1, 1.02664, 1) -bones/163/rotation = Quaternion(0.95203, 0.023815, 0.226157, 0.204758) -bones/163/scale = Vector3(1, 1, 1.00001) -bones/164/rotation = Quaternion(0.336338, 2.43808e-06, 7.36547e-07, 0.941741) -bones/165/position = Vector3(4.68801e-09, 0.418118, -3.46755e-07) -bones/165/rotation = Quaternion(-0.448537, -0.0045005, -0.111262, 0.886801) -bones/166/rotation = Quaternion(-0.565256, 1.55693e-07, 1.60298e-07, 0.824915) -bones/167/position = Vector3(4.6618e-09, 0.418118, -3.26966e-07) -bones/167/rotation = Quaternion(-0.754062, 0.0137002, -0.0365619, 0.655641) -bones/168/rotation = Quaternion(-0.614905, 6.01749e-07, 1.41535e-06, 0.788601) -bones/168/scale = Vector3(1, 1.02631, 1) -bones/169/position = Vector3(0.0131965, 1.27598, 0.182876) -bones/169/rotation = Quaternion(0.0037819, 0.611829, 0.790888, -0.0120893) -bones/169/scale = Vector3(1, 1, 1) -bones/171/position = Vector3(0.00823645, -4.35762e-08, -0.00197221) -bones/171/scale = Vector3(0.810685, 1, 1) -bones/172/position = Vector3(0.00823868, -6.36361e-08, -0.0102093) -bones/173/position = Vector3(-0.0103476, -9.26259e-08, 0.0194797) -bones/173/scale = Vector3(0.810686, 1, 1) -bones/174/position = Vector3(-0.0212752, -7.89344e-08, 0.0112212) -bones/174/scale = Vector3(0.810685, 1, 1) -bones/175/position = Vector3(-0.0138112, -8.59878e-08, -0.0106828) -bones/176/position = Vector3(0.0165712, -8.41906e-08, 0.00987144) -bones/176/scale = Vector3(0.810685, 1, 1) -bones/177/position = Vector3(0.0269392, -3.1346e-08, 0.00129779) -bones/177/scale = Vector3(0.810685, 1, 1) -bones/178/position = Vector3(0.0186913, -3.10398e-08, -0.0116519) -bones/179/position = Vector3(-0.0319375, -5.05976e-08, -0.00811294) -bones/180/position = Vector3(0.0299649, -5.19561e-09, -0.011494) +bones/119/rotation = Quaternion(-0.707107, -8.47159e-07, -9.00524e-07, 0.707107) +bones/120/rotation = Quaternion(-0.707088, 0.00131944, -0.00128381, 0.707123) +bones/121/rotation = Quaternion(-0.707143, -0.00118011, 0.00107765, 0.707069) +bones/122/rotation = Quaternion(0.0361992, -0.706123, -0.0361283, 0.70624) +bones/123/scale = Vector3(1, 1, 1) +bones/126/rotation = Quaternion(-0.707107, -8.47681e-07, -9.00015e-07, 0.707107) +bones/127/rotation = Quaternion(-0.707027, -0.0110055, 0.0109902, 0.707015) +bones/128/rotation = Quaternion(-0.706096, -0.0385178, 0.038402, 0.706024) +bones/129/rotation = Quaternion(0.0569009, -0.704803, -0.0568902, 0.704825) +bones/129/scale = Vector3(1, 1, 1) +bones/131/rotation = Quaternion(-1.06334e-07, -1.19982e-07, 0.0413655, 0.999144) +bones/133/rotation = Quaternion(-0.707107, -8.49787e-07, -8.97905e-07, 0.707107) +bones/134/rotation = Quaternion(-0.706502, -0.0292508, 0.0292488, 0.706501) +bones/135/rotation = Quaternion(-0.70463, -0.0592111, 0.0591898, 0.704619) +bones/140/rotation = Quaternion(-0.704198, 0.0522797, -0.018828, 0.707826) +bones/141/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47963e-09, 0.999476) +bones/142/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47954e-09, 0.999476) +bones/143/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47955e-09, 0.999476) +bones/144/rotation = Quaternion(0.0323581, -3.23524e-09, 4.47962e-09, 0.999476) +bones/145/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/146/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/147/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/148/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/149/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/150/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/151/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/152/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99411e-11, 0.999476) +bones/153/rotation = Quaternion(0.032358, -3.08697e-09, -9.99404e-11, 0.999476) +bones/154/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99409e-11, 0.999476) +bones/155/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/156/rotation = Quaternion(0.0323581, -3.08697e-09, -9.99408e-11, 0.999476) +bones/157/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81471e-09, 0.999476) +bones/158/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/159/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/160/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/161/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/162/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/163/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/164/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81471e-09, 0.999476) +bones/165/rotation = Quaternion(0.032358, -2.41381e-07, -7.81469e-09, 0.999476) +bones/166/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81471e-09, 0.999476) +bones/167/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/168/rotation = Quaternion(0.0323581, -2.41381e-07, -7.81472e-09, 0.999476) +bones/169/rotation = Quaternion(0.999437, 1.66876e-08, 3.38767e-07, -0.0335376) +bones/169/scale = Vector3(1, 1, 1.00001) +bones/170/rotation = Quaternion(0.0296713, -1.19064e-07, 1.37491e-08, 0.99956) +bones/174/rotation = Quaternion(-0.730424, -1.13568e-07, -2.27149e-07, 0.682994) +bones/175/rotation = Quaternion(0.999437, 3.26797e-08, -1.37802e-07, -0.0335376) +bones/175/scale = Vector3(1, 1, 1.00001) +bones/176/rotation = Quaternion(0.0296713, 1.1925e-07, -7.47368e-09, 0.99956) +bones/180/rotation = Quaternion(-0.730424, 1.08982e-07, 2.31437e-07, 0.682994) + +[node name="AnimationPlayer" parent="Model" index="1"] +autoplay = "RESET" [node name="AnimationTree" type="AnimationTree" parent="." node_paths=PackedStringArray("player")] root_node = NodePath("../Model") @@ -358,6 +261,24 @@ parameters/StateMachine/conditions/side_R = false script = ExtResource("4_adlgp") player = NodePath("..") +[node name="BoneFlattener" type="Node3D" parent="." node_paths=PackedStringArray("skeleton")] +script = ExtResource("6_iug5b") +skeleton = NodePath("../Model/Armature/Skeleton3D") +bones_to_flatten = Array[ExtResource("6_cumn2")]([SubResource("Resource_komvq")]) +mirror_y_angle = 0.05 +mouth_corner_pos_z = -0.043 +mouth_pos_z_curve = SubResource("Curve_dj6ba") +mouth_corner_pos_x = 0.074 +mouth_corner_pos_y = 0.005 +mouth_corner_rot_y = 0.703 +mouth_rot_y_curve = SubResource("Curve_4c21p") +mouth_corner_rot_x = -0.49 +mouth_corner_rot_z = -0.525 +mouth_value_yaw_curve = SubResource("Curve_6imy2") +mouth_front_pitch_curve = SubResource("Curve_2gav4") +mouth_front_yaw_curve = SubResource("Curve_suux4") +mouth_hide_rot_y = 6.283 + [node name="CollisionShape3D" type="CollisionShape3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0) shape = SubResource("CylinderShape3D_apl1i") diff --git a/scripts/effects/bone_flattener.gd b/scripts/effects/bone_flattener.gd new file mode 100644 index 0000000..3d40db6 --- /dev/null +++ b/scripts/effects/bone_flattener.gd @@ -0,0 +1,291 @@ +@tool +class_name BoneFlattener +extends Node3D + +@export var skeleton: Skeleton3D +@export var bones_to_flatten: Array[BoneToFlatten] = [] +@export var mirror_y_angle: float + +@export_group("Bone names") +@export var head_bone_name: String = "Head" +@export var mouth_bone_name: String = "Mouth_base" + +@export_group("Mouth") +@export var mouth_center_pos_z: float: + set(value): + update_gizmos() + mouth_center_pos_z = value + +@export var mouth_corner_pos_z: float: + set(value): + update_gizmos() + mouth_corner_pos_z = value + +@export var mouth_pos_z_curve: Curve: + set(value): + update_gizmos() + mouth_pos_z_curve = value + +@export var mouth_corner_pos_x: float: + set(value): + update_gizmos() + mouth_corner_pos_x = value + +@export var mouth_center_pos_y: float: + set(value): + update_gizmos() + mouth_center_pos_y = value + +@export var mouth_corner_pos_y: float: + set(value): + update_gizmos() + mouth_corner_pos_y = value + +@export var mouth_corner_rot_y: float: + set(value): + update_gizmos() + mouth_corner_rot_y = value + +@export var mouth_rot_y_curve: Curve: + set(value): + update_gizmos() + mouth_rot_y_curve = value + +@export var mouth_corner_rot_x: float: + set(value): + update_gizmos() + mouth_corner_rot_x = value + +@export var mouth_corner_rot_z: float: + set(value): + update_gizmos() + mouth_corner_rot_z = value + +@export var mouth_value_yaw_curve: Curve: + set(value): + update_gizmos() + mouth_value_yaw_curve = value + +@export var mouth_front_pitch_curve: Curve +@export var mouth_front_yaw_curve: Curve +@export var mouth_hide_rot_y: float + +@export_group("Eyes") +@export var from_pupil_z_min: float +@export var from_pupil_z_max: float +@export var from_pupil_x_min: float +@export var from_pupil_x_max: float +@export var to_spec_z: float +@export var to_spec_x: float + +var _mouth_bone: int +var _head_bone: int +var _bone_indices: Dictionary = {} + +var _angle: Vector3 = Vector3() + + +func _ready() -> void: + assert(skeleton, str(self) + ": skeleton missing!") + _head_bone = skeleton.find_bone(head_bone_name) + assert(_head_bone != -1, str(self) + ": _head_bone missing!") + _mouth_bone = skeleton.find_bone(mouth_bone_name) + assert(_mouth_bone != -1, str(self) + ": _mouth_bone missing!") + + for bone_to_flatten in bones_to_flatten: + if bone_to_flatten == null: + continue + for bone_name in bone_to_flatten.bone_names: + var bone_index := skeleton.find_bone(bone_name) + assert(bone_index != -1, bone_name + " missing!") + _bone_indices[bone_name] = bone_index + + +func _process(_delta: float) -> void: + if skeleton == null: + return + + _get_angle() + _handle_mouth() + + for i in range(bones_to_flatten.size()): + var bone_to_flatten := bones_to_flatten[i] + if bone_to_flatten == null: + continue + for bone_name in bone_to_flatten.bone_names: + if not _bone_indices.has(bone_name): + continue + var bone_index: int = _bone_indices[bone_name] as int + _handle_position(bone_to_flatten, bone_index) + _handle_rotation(bone_to_flatten, bone_index) + _handle_scale(bone_to_flatten, bone_index) + + +func mouth_pose(normalized: Vector3) -> Vector3: + var pos: Vector3 = Vector3.ZERO + pos.x = normalized.y * mouth_corner_pos_x + var depth_value := mouth_pos_z_curve.sample(absf(normalized.y)) + pos.z = remap(depth_value, 0, 1, mouth_center_pos_z, mouth_corner_pos_z) + pos.y = remap(depth_value, 0, 1, mouth_center_pos_y, mouth_corner_pos_y) + + return pos + + +func global_bone_transform(bone_idx: int) -> Transform3D: + var transform_local := skeleton.get_bone_global_pose(bone_idx) + return skeleton.global_transform * transform_local + + +func _get_angle() -> void: + var camera: Camera3D + if Engine.is_editor_hint(): + var editor_interface := Engine.get_singleton("EditorInterface") + camera = editor_interface.get_editor_viewport_3d().get_camera_3d() + else: + camera = get_tree().root.get_viewport().get_camera_3d() + + var head_transform := global_bone_transform(_head_bone) + var head_transform_rotated := ( + head_transform + . looking_at( + camera.global_position, + Vector3.UP, + true, + ) + ) + var head_rot := head_transform.basis.get_rotation_quaternion() + var head_rotated_rot := head_transform_rotated.basis.get_rotation_quaternion() + var diff := (head_rot.inverse() * head_rotated_rot).normalized() + _angle = diff.get_euler() + + +func _handle_mouth() -> void: + if ( + mouth_value_yaw_curve == null + or mouth_rot_y_curve == null + or mouth_pos_z_curve == null + or mouth_front_pitch_curve == null + or mouth_front_yaw_curve == null + ): + return + + var bone_transform := skeleton.get_bone_rest(_mouth_bone) + var bone_rot := bone_transform.basis.get_euler() + var bone_pos := bone_transform.origin + var normalized := Vector3.ZERO + normalized.y = clampf(_angle.y / (PI / 2), -1, 1) + normalized.x = clampf(_angle.x / (PI / 2), -1, 1) + normalized.y = ( + mouth_value_yaw_curve.sample(absf(normalized.y)) * signf(normalized.y) + ) + + bone_pos += mouth_pose(normalized) + skeleton.set_bone_pose_position(_mouth_bone, bone_pos) + + var corner_angle_value := ease(absf(normalized.y), 1) * signf(normalized.y) + bone_rot.x += ( + ( + mouth_rot_y_curve + . sample( + absf(corner_angle_value), + ) + ) + * mouth_corner_rot_x + ) + var rot_y := ( + ( + mouth_rot_y_curve + . sample( + absf(corner_angle_value), + ) + ) + * signf(normalized.y) + * mouth_corner_rot_y + ) + bone_rot = ( + ( + Quaternion( + Vector3.FORWARD, + mouth_corner_rot_z * normalized.y, + ) + * Quaternion( + Vector3.UP, + rot_y, + ) + * Quaternion.from_euler(bone_rot) + ) + . get_euler() + ) + + skeleton.set_bone_pose_rotation(_mouth_bone, Quaternion.from_euler(bone_rot)) + + var bone_scale := Vector3.ONE + var scale_x_front := ( + mouth_front_pitch_curve + . sample( + inverse_lerp(-1, 1, normalized.x), + ) + ) + bone_scale.x = lerpf( + 1, + scale_x_front, + mouth_front_yaw_curve.sample(absf(normalized.y)), + ) + if _angle.y > mirror_y_angle: + bone_scale.x *= -1 + if absf(_angle.y) > mouth_hide_rot_y: + bone_scale = Vector3.ZERO + skeleton.set_bone_pose_scale(_mouth_bone, bone_scale) + + +func _handle_position(bone_to_flatten: BoneToFlatten, bone: int) -> void: + if not bone_to_flatten.do_position: + return + + var bone_pos := skeleton.get_bone_rest(bone).origin + bone_pos.x += ( + bone_to_flatten.get_amount(_angle) * bone_to_flatten.position_x_amount + ) + skeleton.set_bone_pose_position(bone, bone_pos) + + +func _handle_rotation(bone_to_flatten: BoneToFlatten, bone: int) -> void: + if not bone_to_flatten.do_rotation: + return + + var bone_transform := skeleton.get_bone_rest(bone) + var bone_rot := bone_transform.basis.get_euler() + var bone_pos := bone_transform.origin + var amount := bone_to_flatten.get_amount(_angle) + var normalized := bone_to_flatten.get_angle_normalized(_angle) + + bone_rot.x += amount * (PI / 2) * bone_to_flatten.rotation_x_amount + if bone_to_flatten.mirror_rot_x and bone_pos.x > 0: + bone_rot.x *= -1 + if bone_to_flatten.rotation_x_curve != null: + bone_rot.x *= (bone_to_flatten.rotation_x_curve.sample(absf(normalized.y))) + if bone_to_flatten.consider_side_rot_x: + bone_rot.x *= -signf(normalized.y) + + bone_rot.y += amount * (PI / 2) * bone_to_flatten.rotation_y_amount + if bone_to_flatten.mirror_rot_y and bone_pos.x > 0: + bone_rot.y *= -1 + if bone_to_flatten.rotation_y_curve != null: + bone_rot.y *= (bone_to_flatten.rotation_y_curve.sample(absf(normalized.y))) + if bone_to_flatten.consider_side_rot_y: + bone_rot.y *= -signf(normalized.y) + + bone_rot.z += amount * (PI / 2) * bone_to_flatten.rotation_z_amount + if bone_to_flatten.mirror_rot_z and bone_pos.x > 0: + bone_rot.z *= -1 + if bone_to_flatten.rotation_z_curve != null: + bone_rot.z *= (bone_to_flatten.rotation_z_curve.sample(absf(normalized.y))) + if bone_to_flatten.consider_side_rot_z: + bone_rot.z *= -signf(normalized.y) + + skeleton.set_bone_pose_rotation(bone, Quaternion.from_euler(bone_rot)) + + +func _handle_scale(bone_to_flatten: BoneToFlatten, _bone: int) -> void: + if not bone_to_flatten.do_scale: + return diff --git a/scripts/effects/bone_to_flatten.gd b/scripts/effects/bone_to_flatten.gd new file mode 100644 index 0000000..28d73ff --- /dev/null +++ b/scripts/effects/bone_to_flatten.gd @@ -0,0 +1,50 @@ +@tool +class_name BoneToFlatten +extends Resource + +@export var bone_names: PackedStringArray = [] +@export var amount_by_pitch_curve: Curve = Curve.new() +@export var amount_by_yaw_curve: Curve = Curve.new() +@export var consider_side: bool = false +@export var yaw_fraction: float = 1 + +@export_group("Position") +@export var do_position: bool = false +@export var position_x_amount: float + +@export_group("Rotation") +@export var do_rotation: bool = false +@export var rotation_x_amount: float +@export var rotation_x_curve: Curve +@export var mirror_rot_x: bool = false +@export var consider_side_rot_x: bool = false +@export var rotation_y_amount: float +@export var rotation_y_curve: Curve +@export var mirror_rot_y: bool = false +@export var consider_side_rot_y: bool = false +@export var rotation_z_amount: float +@export var rotation_z_curve: Curve +@export var mirror_rot_z: bool = false +@export var consider_side_rot_z: bool = false + +@export_group("Scale") +@export var do_scale: bool = false + + +func get_angle_normalized(angle: Vector3) -> Vector3: + var normalized := Vector3.ZERO + normalized.y = angle.y / (PI / yaw_fraction) + normalized.x = angle.x / (PI / 2) + return normalized + + +func get_amount(angle: Vector3) -> float: + if amount_by_pitch_curve == null or amount_by_yaw_curve == null: + return 0 + + var normalized := get_angle_normalized(angle) + var amount_by_yaw := amount_by_yaw_curve.sample(absf(normalized.y)) + var amount := amount_by_pitch_curve.sample(absf(normalized.x)) * amount_by_yaw + if consider_side: + amount *= -signf(normalized.y) + return amount diff --git a/scripts/effects/discrete_animation_player.gd b/scripts/effects/discrete_animation_player.gd new file mode 100644 index 0000000..76cf813 --- /dev/null +++ b/scripts/effects/discrete_animation_player.gd @@ -0,0 +1,17 @@ +## https://forum.godotengine.org/t/how-to-set-all-3d-animation-tracks-to-nearest-interpolation/22056/4 +@tool +extends AnimationPlayer + + +func _ready() -> void: + interpolation_change() + + +func interpolation_change() -> void: + for animation in get_animation_list(): + var anim_track_1: Animation = get_animation(animation) + var count: int = anim_track_1.get_track_count() + for i in count: + anim_track_1.track_set_interpolation_type( + i, Animation.INTERPOLATION_NEAREST + )