veloren_voxygen_anim/biped_large/
leapshockwave.rs1use super::{
2 super::{Animation, vek::*},
3 BipedLargeSkeleton, SkeletonAttr,
4};
5use common::{comp::item::ToolKind, states::utils::StageSection};
6use core::f32::consts::PI;
7
8pub struct LeapShockAnimation;
9
10impl Animation for LeapShockAnimation {
11 type Dependency<'a> = (
12 Option<ToolKind>,
13 Option<ToolKind>,
14 Vec3<f32>,
15 f32,
16 Option<StageSection>,
17 );
18 type Skeleton = BipedLargeSkeleton;
19
20 #[cfg(feature = "use-dyn-lib")]
21 const UPDATE_FN: &'static [u8] = b"biped_large_leapshockwave\0";
22
23 #[cfg_attr(
24 feature = "be-dyn-lib",
25 unsafe(export_name = "biped_large_leapshockwave")
26 )]
27 fn update_skeleton_inner(
28 skeleton: &Self::Skeleton,
29 (_active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency<'_>,
30 anim_time: f32,
31 rate: &mut f32,
32 s_a: &SkeletonAttr,
33 ) -> Self::Skeleton {
34 *rate = 1.0;
35 let mut next = (*skeleton).clone();
36
37 let (movement1, movement2, movement3, movement4) = match stage_section {
38 Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
39 Some(StageSection::Movement) => (1.0, anim_time.powf(0.25), 0.0, 0.0),
40 Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.25), 0.0),
41 Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
42 _ => (0.0, 0.0, 0.0, 0.0),
43 };
44
45 next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
46 next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
47 next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
48 next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
49 next.main.position = Vec3::new(0.0, 0.0, 0.0);
50 next.main.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
51
52 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
53
54 next.control.position = Vec3::new(
55 s_a.hc.0 + movement2 * -10.0 + movement3 * 6.0,
56 s_a.hc.1 + movement2 * 5.0 + movement3 * 7.0,
57 s_a.hc.2 + movement2 * 5.0 + movement3 * -10.0,
58 );
59 next.control.orientation =
60 Quaternion::rotation_x(s_a.hc.3 + movement2 * PI / 2.0 + movement3 * -2.3)
61 * Quaternion::rotation_y(s_a.hc.4 + movement2 * 1.3)
62 * Quaternion::rotation_z(s_a.hc.5 + movement2 * -1.0 + movement3 * 0.5);
63 next.upper_torso.orientation =
64 Quaternion::rotation_x(
65 movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
66 ) * Quaternion::rotation_z(movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7);
67
68 next.head.orientation = Quaternion::rotation_x(movement3 * 0.2)
69 * Quaternion::rotation_y(0.0 + movement2 * -0.1)
70 * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6);
71
72 next.foot_l.position = Vec3::new(
73 -s_a.foot.0,
74 s_a.foot.1 + movement3 * 13.0,
75 s_a.foot.2 + movement3 * -2.0,
76 );
77 next.foot_l.orientation = Quaternion::rotation_x(-0.8 + movement3 * 1.7);
78
79 next.foot_r.position = Vec3::new(
80 s_a.foot.0,
81 s_a.foot.1 + 8.0 + movement3 * -13.0,
82 s_a.foot.2 + 5.0 + movement3 * -5.0,
83 );
84 next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7);
85
86 next
87 }
88}