veloren_voxygen_anim/biped_large/
spritesummon.rs1use super::{
2 super::{Animation, vek::*},
3 BipedLargeSkeleton, SkeletonAttr,
4};
5use common::{
6 comp::item::{AbilitySpec, ToolKind},
7 states::utils::StageSection,
8};
9use std::f32::consts::PI;
10
11pub struct SpriteSummonAnimation;
12
13type SpriteSummonAnimationDependency<'a> = (
14 Option<ToolKind>,
15 (Option<ToolKind>, Option<&'a AbilitySpec>),
16 f32,
17 f32,
18 Option<StageSection>,
19 Option<&'a str>,
20);
21impl Animation for SpriteSummonAnimation {
22 type Dependency<'a> = SpriteSummonAnimationDependency<'a>;
23 type Skeleton = BipedLargeSkeleton;
24
25 #[cfg(feature = "use-dyn-lib")]
26 const UPDATE_FN: &'static [u8] = b"biped_large_sprite_summon\0";
27
28 #[cfg_attr(
29 feature = "be-dyn-lib",
30 unsafe(export_name = "biped_large_sprite_summon")
31 )]
32 fn update_skeleton_inner(
33 skeleton: &Self::Skeleton,
34 (
35 active_tool_kind,
36 _second_tool_kind,
37 _global_time,
38 velocity,
39 stage_section,
40 ability_id,
41 ): Self::Dependency<'_>,
42 anim_time: f32,
43 rate: &mut f32,
44 s_a: &SkeletonAttr,
45 ) -> Self::Skeleton {
46 *rate = 1.0;
47 let mut next = (*skeleton).clone();
48
49 next.main.position = Vec3::new(0.0, 0.0, 0.0);
50 next.main.orientation = Quaternion::rotation_x(0.0);
51
52 next.hand_l.position = Vec3::new(0.0, 0.0, s_a.grip.0);
53 next.hand_r.position = Vec3::new(0.0, 0.0, s_a.grip.0);
54
55 next.hand_l.orientation = Quaternion::rotation_x(0.0);
56 next.hand_r.orientation = Quaternion::rotation_x(0.0);
57
58 match active_tool_kind {
59 Some(ToolKind::Axe | ToolKind::Hammer | ToolKind::Sceptre) => {
60 let (move1base, move2, move3) = match stage_section {
61 Some(StageSection::Buildup) => ((anim_time.powf(0.25)), 0.0, 0.0),
62 Some(StageSection::Action) => (1.0, (anim_time), 0.0),
63 Some(StageSection::Recover) => (1.0, 1.0, anim_time),
64 _ => (0.0, 0.0, 0.0),
65 };
66 let pullback = 1.0 - move3;
67 let move1 = move1base * pullback;
68 let move2 = move2 * pullback;
69 let move2cyc = (move2 * 10.0).sin() * pullback;
70
71 next.shoulder_r.orientation =
72 Quaternion::rotation_y(move1 * 0.5) * Quaternion::rotation_x(move1 * 0.5);
73 next.shoulder_l.orientation =
74 Quaternion::rotation_y(move1 * 0.5) * Quaternion::rotation_x(move1 * 0.5);
75 next.head.orientation = Quaternion::rotation_x(move1 * -0.2)
76 * Quaternion::rotation_z(move1 * -0.6 + move2 * 1.2);
77
78 next.main.position = Vec3::new(0.0, 0.0, 0.0);
79 next.main.orientation = Quaternion::rotation_x(0.0);
80
81 next.hand_l.position = Vec3::new(s_a.grip.1, 0.0, s_a.grip.0);
82 next.hand_r.position = Vec3::new(-s_a.grip.1, 0.0, s_a.grip.0);
83
84 next.hand_l.orientation = Quaternion::rotation_x(0.0);
85 next.hand_r.orientation = Quaternion::rotation_x(0.0);
86
87 next.main.orientation = Quaternion::rotation_x(move2 * -0.5);
88
89 next.control_l.position =
90 Vec3::new(-1.0 + move1 * 16.0, 2.0, 12.0 + move1 * 20.0 + move2 * 20.0);
91 next.control_r.position = Vec3::new(1.0, 2.0 + move1 * 3.0, -2.0);
92
93 next.control.position = Vec3::new(
94 4.0 + move1 * 5.0 + move2 * 10.0,
95 0.0 + s_a.grip.0 / 1.0 + move1 * 5.0 + move2 * -5.0,
96 -s_a.grip.0 / 0.8 + move1 * -2.0,
97 );
98
99 next.control_l.orientation =
100 Quaternion::rotation_x(PI / 2.0 + move1 * -0.2 + move2 * 0.9)
101 * Quaternion::rotation_z(move1 * -3.0 + move2cyc * 0.15);
102 next.control_r.orientation =
103 Quaternion::rotation_x(PI / 2.0 + 0.2 + move1 * -0.35 + move2 * -0.5)
104 * Quaternion::rotation_y(move1 * 0.5)
105 * Quaternion::rotation_z(0.0);
106 next.control.orientation = Quaternion::rotation_x(-1.0 + move1 * -1.8)
107 * Quaternion::rotation_y(-1.8 + move1 * -0.0)
108 * Quaternion::rotation_z(0.0 + move1 * -2.5);
109
110 next.torso.position = Vec3::new(0.0, 0.0, 0.0);
111 next.upper_torso.orientation = Quaternion::rotation_z(move1 * -0.5 + move2 * 0.5)
112 * Quaternion::rotation_y(move2 * 0.1);
113
114 next.lower_torso.orientation = Quaternion::rotation_z(move1 * 0.5 + move2 * -0.5)
115 * Quaternion::rotation_y(move2 * -0.1);
116 },
117 Some(ToolKind::Natural) => match ability_id {
118 Some(
119 "common.abilities.custom.harvester.ensnaringvines_sparse"
120 | "common.abilities.custom.harvester.ensnaringvines_dense",
121 ) => {
122 let (move1, move1pow, move2, move3) = match stage_section {
123 Some(StageSection::Buildup) => (anim_time, anim_time.powf(0.1), 0.0, 0.0),
124 Some(StageSection::Action) => {
125 (1.0, 1.0, (anim_time.powf(4.0) * 80.0).min(1.0), 0.0)
126 },
127 Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
128 _ => (0.0, 0.0, 0.0, 0.0),
129 };
130
131 let speed = Vec2::<f32>::from(velocity).magnitude();
132
133 let pullback = 1.0 - move3;
134 let move1 = move1 * pullback;
135 let move1pow = move1pow * pullback;
136 let move2 = move2 * pullback;
137
138 next.head.orientation = Quaternion::rotation_x(move1 * 0.2);
139 next.jaw.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
140 next.jaw.orientation = Quaternion::rotation_x(move2 * -0.3);
141
142 let twist = move1 * 0.8 + move3 * -0.8;
143 next.upper_torso.position = Vec3::new(
144 0.0,
145 s_a.upper_torso.0,
146 s_a.upper_torso.1 + move1 * 1.0 + move2 * -1.0,
147 );
148 next.upper_torso.orientation =
149 Quaternion::rotation_x(move1 * 0.8 + move2 * -1.1)
150 * Quaternion::rotation_z(twist * -0.2 + move1 * -0.1 + move2 * 0.3);
151
152 next.lower_torso.orientation =
153 Quaternion::rotation_x(move1 * -0.8 + move2 * 1.1)
154 * Quaternion::rotation_z(-twist + move1 * 0.4);
155
156 next.control_l.position = Vec3::new(1.0, 2.0, 8.0);
157 next.control_r.position = Vec3::new(1.0, 1.0, -2.0);
158
159 next.control.position = Vec3::new(
160 -7.0 + move1pow * 7.0,
161 0.0 + s_a.grip.0 / 1.0 + move1pow * 12.0,
162 -s_a.grip.0 / 0.8 + move1pow * 20.0 + move2 * -3.0,
163 );
164
165 next.control_l.orientation =
166 Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI);
167 next.control_r.orientation = Quaternion::rotation_x(PI / 2.0 + 0.2)
168 * Quaternion::rotation_y(-1.0)
169 * Quaternion::rotation_z(0.0);
170
171 next.control.orientation =
172 Quaternion::rotation_x(-1.4 + move1pow * 2.2 + move2 * -0.6)
173 * Quaternion::rotation_y(-PI);
174
175 next.shoulder_l.position =
176 Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
177 next.shoulder_l.orientation = Quaternion::rotation_x(-0.4 + move1pow * 1.6);
178 next.shoulder_r.orientation =
179 Quaternion::rotation_y(0.4) * Quaternion::rotation_x(0.4 + move1pow * 1.0);
180
181 if speed == 0.0 {
182 next.leg_l.orientation = Quaternion::rotation_x(move1 * 0.8 + move2 * -0.8);
183
184 next.foot_l.position = Vec3::new(
185 -s_a.foot.0,
186 s_a.foot.1,
187 s_a.foot.2 + move1 * 4.0 + move2 * -4.0,
188 );
189 next.foot_l.orientation =
190 Quaternion::rotation_x(move1 * -0.6 + move2 * 0.6);
191 }
192 },
193 Some("common.abilities.custom.minotaur.ironspike_targeted") => {
194 let (move1base, move2, move3) = match stage_section {
195 Some(StageSection::Buildup) => ((anim_time.powf(0.25)), 0.0, 0.0),
196 Some(StageSection::Action) => (1.0, (anim_time), 0.0),
197 Some(StageSection::Recover) => (1.0, 1.0, anim_time),
198 _ => (0.0, 0.0, 0.0),
199 };
200 let pullback = 1.0 - move3;
201 let move1 = move1base * pullback;
202 let move2 = move2 * pullback;
203 let move2cyc = (move2 * 10.0).sin() * pullback;
204
205 next.shoulder_r.orientation =
206 Quaternion::rotation_y(move1 * 0.5) * Quaternion::rotation_x(move1 * 0.5);
207 next.shoulder_l.orientation =
208 Quaternion::rotation_y(move1 * 0.5) * Quaternion::rotation_x(move1 * 0.5);
209 next.head.orientation = Quaternion::rotation_x(move1 * -0.2)
210 * Quaternion::rotation_z(move1 * -0.6 + move2 * 1.2);
211
212 next.main.position = Vec3::new(0.0, 0.0, 0.0);
213 next.main.orientation = Quaternion::rotation_x(0.0);
214
215 next.hand_l.position = Vec3::new(s_a.grip.1, 0.0, s_a.grip.0);
216 next.hand_r.position = Vec3::new(-s_a.grip.1, 0.0, s_a.grip.0);
217
218 next.hand_l.orientation = Quaternion::rotation_x(0.0);
219 next.hand_r.orientation = Quaternion::rotation_x(0.0);
220
221 next.main.orientation = Quaternion::rotation_x(move2 * -0.5);
222
223 next.control_l.position =
224 Vec3::new(-1.0 + move1 * 16.0, 2.0, 12.0 + move1 * 20.0 + move2 * 20.0);
225 next.control_r.position = Vec3::new(1.0, 2.0 + move1 * 3.0, -2.0);
226
227 next.control.position = Vec3::new(
228 4.0 + move1 * 5.0 + move2 * 10.0,
229 0.0 + s_a.grip.0 / 1.0 + move1 * 5.0 + move2 * -5.0,
230 -s_a.grip.0 / 0.8 + move1 * -2.0,
231 );
232
233 next.control_l.orientation =
234 Quaternion::rotation_x(PI / 2.0 + move1 * -0.2 + move2 * 0.9)
235 * Quaternion::rotation_z(move1 * -3.0 + move2cyc * 0.15);
236 next.control_r.orientation =
237 Quaternion::rotation_x(PI / 2.0 + 0.2 + move1 * -0.35 + move2 * -0.5)
238 * Quaternion::rotation_y(move1 * 0.5)
239 * Quaternion::rotation_z(0.0);
240 next.control.orientation = Quaternion::rotation_x(-1.0 + move1 * -1.8)
241 * Quaternion::rotation_y(-1.8 + move1 * -0.0)
242 * Quaternion::rotation_z(0.0 + move1 * -2.5);
243
244 next.torso.position = Vec3::new(0.0, 0.0, 0.0);
245 next.upper_torso.orientation =
246 Quaternion::rotation_z(move1 * -0.5 + move2 * 0.5)
247 * Quaternion::rotation_y(move2 * 0.1);
248
249 next.lower_torso.orientation =
250 Quaternion::rotation_z(move1 * 0.5 + move2 * -0.5)
251 * Quaternion::rotation_y(move2 * -0.1);
252 },
253 _ => {},
254 },
255 _ => {},
256 }
257 next
258 }
259}