veloren_voxygen_anim/biped_small/
dash.rs1use super::{
2 super::{Animation, vek::*},
3 BipedSmallSkeleton, SkeletonAttr,
4};
5use common::states::utils::StageSection;
6use std::f32::consts::PI;
7
8pub struct DashAnimation;
9
10type DashAnimationDependency<'a> = (
11 Option<&'a str>,
12 Vec3<f32>,
13 Vec3<f32>,
14 Vec3<f32>,
15 f32,
16 Vec3<f32>,
17 f32,
18 Option<StageSection>,
19 f32,
20);
21
22impl Animation for DashAnimation {
23 type Dependency<'a> = DashAnimationDependency<'a>;
24 type Skeleton = BipedSmallSkeleton;
25
26 #[cfg(feature = "use-dyn-lib")]
27 const UPDATE_FN: &'static [u8] = b"biped_small_dash\0";
28
29 #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_small_dash")]
30
31 fn update_skeleton_inner(
32 skeleton: &Self::Skeleton,
33 (
34 ability_id,
35 velocity,
36 _orientation,
37 _last_ori,
38 _global_time,
39 _avg_vel,
40 _acc_vel,
41 stage_section,
42 _timer,
43 ): Self::Dependency<'_>,
44 anim_time: f32,
45 _rate: &mut f32,
46 s_a: &SkeletonAttr,
47 ) -> Self::Skeleton {
48 let mut next = (*skeleton).clone();
49 let speed = Vec2::<f32>::from(velocity).magnitude();
50
51 let fast = (anim_time * 10.0).sin();
52 let fastalt = (anim_time * 10.0 + PI / 2.0).sin();
53
54 let speednorm = speed / 9.4;
55 let speednormcancel = 1.0 - speednorm;
56
57 let (move1base, move2base, move3, move4) = match stage_section {
58 Some(StageSection::Buildup) => (anim_time.sqrt(), 0.0, 0.0, 0.0),
59 Some(StageSection::Charge) => (1.0, anim_time.powi(4), 0.0, 0.0),
60 Some(StageSection::Action) => (1.0, 1.0, anim_time.powi(4), 0.0),
61 Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
62 _ => (0.0, 0.0, 0.0, 0.0),
63 };
64 let pullback = 1.0 - move4;
65 let move1abs = move1base * pullback;
66 let move2abs = move2base * pullback;
67
68 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
69 next.head.orientation = Quaternion::rotation_x(move1abs * 0.6)
70 * Quaternion::rotation_z(move1abs * -0.0)
71 * Quaternion::rotation_y(move1abs * 0.3);
72 next.chest.orientation = Quaternion::rotation_x(move1abs * -0.8);
73
74 next.pants.orientation = Quaternion::rotation_x(move1abs * -0.2);
75 match ability_id {
76 Some("common.abilities.vampire.bloodmoon_heiress.dash") => {
77 next.main.position = Vec3::new(0.0, 4.0, -4.0);
78 next.main.orientation = Quaternion::rotation_x(0.0);
79 next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
80 next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
81 next.hand_l.orientation = Quaternion::rotation_x(0.0);
82 next.hand_r.orientation = Quaternion::rotation_x(0.0);
83
84 next.control_l.position = Vec3::new(1.0, 2.0, -2.0);
85 next.control_r.position = Vec3::new(3.0, 2.0, -2.0);
86 next.control.position = Vec3::new(
87 -3.0,
88 s_a.grip.2 + move1abs * -5.0,
89 s_a.grip.2 / 5.0 + move1abs * 4.0,
90 );
91 next.control_l.orientation = Quaternion::rotation_x(PI / 1.5 + move1abs * -0.7)
92 * Quaternion::rotation_y(-0.3);
93 next.control_r.orientation =
94 Quaternion::rotation_x(PI / 1.5 + s_a.grip.0 * 0.2 + move1abs * -0.7)
95 * Quaternion::rotation_y(0.5 + s_a.grip.0 * 0.2);
96 },
97 Some("common.abilities.custom.ochre_legoom.dash") => {
98 next.main.position = Vec3::new(0.0, 3.0, 0.0);
99 next.main.orientation = Quaternion::rotation_x(0.0);
100
101 next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
102 next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
103
104 next.hand_l.orientation = Quaternion::rotation_x(0.0);
105 next.hand_r.orientation = Quaternion::rotation_x(0.0);
106
107 next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0);
108 next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0);
109 next.control.position = Vec3::new(
110 -3.0,
111 s_a.grip.2 + move1abs * -5.0,
112 -s_a.grip.2 / 2.5 + s_a.grip.0 * -2.0 + move1abs * 4.0,
113 );
114 next.control_l.orientation =
115 Quaternion::rotation_x(PI / 1.5 + move1abs * -0.7 + move3 * 0.7)
116 * Quaternion::rotation_y(-0.3);
117 next.control_r.orientation = Quaternion::rotation_x(
118 PI / 1.5 + s_a.grip.0 * 0.2 + move1abs * -0.7 + move3 * 0.7,
119 ) * Quaternion::rotation_y(0.5 + s_a.grip.0 * 0.2);
120 },
121 Some("common.abilities.custom.cactid.dash") => {
122 next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
123 next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
124 next.main.position = Vec3::new(0.0, 0.0, 0.0);
125 next.main.orientation = Quaternion::rotation_x(0.0);
126 next.hand_l.orientation = Quaternion::rotation_x(0.0);
127 next.hand_r.orientation = Quaternion::rotation_x(0.0);
128 next.head.orientation = Quaternion::rotation_z(move3 * 1.0);
129 next.chest.orientation = Quaternion::rotation_x(move2abs * -1.0)
130 * Quaternion::rotation_z(move1abs * -1.2 + move2abs * 2.4);
131 next.hand_l.position = Vec3::new(-s_a.hand.0, s_a.hand.1, s_a.hand.2);
132 next.hand_l.orientation = Quaternion::rotation_x(1.2);
133 next.hand_r.position = Vec3::new(s_a.hand.0, s_a.hand.1, s_a.hand.2);
134 next.hand_r.orientation = Quaternion::rotation_x(1.2);
135 },
136 _ => {
137 next.main.position = Vec3::new(0.0, 0.0, 0.0);
138 next.main.orientation = Quaternion::rotation_x(0.0);
139
140 next.hand_l.position = Vec3::new(s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
141 next.hand_r.position = Vec3::new(-s_a.grip.0 * 4.0, 0.0, s_a.grip.2);
142
143 next.hand_l.orientation = Quaternion::rotation_x(0.0);
144 next.hand_r.orientation = Quaternion::rotation_x(0.0);
145
146 next.control_l.position = Vec3::new(1.0 - s_a.grip.0 * 2.0, 2.0, -2.0);
147 next.control_r.position = Vec3::new(-1.0 + s_a.grip.0 * 2.0, 2.0, 2.0);
148 next.control.position = Vec3::new(
149 -3.0,
150 s_a.grip.2 + move1abs * -5.0,
151 -s_a.grip.2 / 2.5 + s_a.grip.0 * -2.0 + move1abs * 4.0,
152 );
153 next.control_l.orientation =
154 Quaternion::rotation_x(PI / 1.5 + move1abs * -0.7 + move3 * 0.7)
155 * Quaternion::rotation_y(-0.3);
156 next.control_r.orientation = Quaternion::rotation_x(
157 PI / 1.5 + s_a.grip.0 * 0.2 + move1abs * -0.7 + move3 * 0.7,
158 ) * Quaternion::rotation_y(0.5 + s_a.grip.0 * 0.2);
159 },
160 }
161
162 next.control.orientation = Quaternion::rotation_x(-1.35 + move1abs * 0.6)
163 * Quaternion::rotation_z(move1abs * 0.2)
164 * Quaternion::rotation_y(move2abs * 0.0);
165
166 next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);
167 next.tail.orientation = Quaternion::rotation_x(0.05 * fastalt * speednormcancel)
168 * Quaternion::rotation_z(fast * 0.15 * speednormcancel);
169
170 next
171 }
172}