veloren_voxygen_anim/biped_large/
leapshockwave.rs

1use 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(feature = "be-dyn-lib", export_name = "biped_large_leapshockwave")]
24    fn update_skeleton_inner(
25        skeleton: &Self::Skeleton,
26        (_active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section): Self::Dependency<'_>,
27        anim_time: f32,
28        rate: &mut f32,
29        s_a: &SkeletonAttr,
30    ) -> Self::Skeleton {
31        *rate = 1.0;
32        let mut next = (*skeleton).clone();
33
34        let (movement1, movement2, movement3, movement4) = match stage_section {
35            Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
36            Some(StageSection::Movement) => (1.0, anim_time.powf(0.25), 0.0, 0.0),
37            Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.25), 0.0),
38            Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
39            _ => (0.0, 0.0, 0.0, 0.0),
40        };
41
42        if true {
43            next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
44            next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
45            next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
46            next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
47            next.main.position = Vec3::new(0.0, 0.0, 0.0);
48            next.main.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
49
50            next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
51
52            next.control.position = Vec3::new(
53                s_a.hc.0 + movement2 * -10.0 + movement3 * 6.0,
54                s_a.hc.1 + movement2 * 5.0 + movement3 * 7.0,
55                s_a.hc.2 + movement2 * 5.0 + movement3 * -10.0,
56            );
57            next.control.orientation =
58                Quaternion::rotation_x(s_a.hc.3 + movement2 * PI / 2.0 + movement3 * -2.3)
59                    * Quaternion::rotation_y(s_a.hc.4 + movement2 * 1.3)
60                    * Quaternion::rotation_z(s_a.hc.5 + movement2 * -1.0 + movement3 * 0.5);
61            next.upper_torso.orientation =
62                Quaternion::rotation_x(
63                    movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
64                ) * Quaternion::rotation_z(movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7);
65
66            next.head.orientation = Quaternion::rotation_x(movement3 * 0.2)
67                * Quaternion::rotation_y(0.0 + movement2 * -0.1)
68                * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6);
69
70            //next.hand_l.position = Vec3::new(-12.0 + movement3 * 10.0, 0.0, 0.0);
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
87        next
88    }
89}