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 if true {
46 next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
47 next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
48 next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
49 next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
50 next.main.position = Vec3::new(0.0, 0.0, 0.0);
51 next.main.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
52
53 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
54
55 next.control.position = Vec3::new(
56 s_a.hc.0 + movement2 * -10.0 + movement3 * 6.0,
57 s_a.hc.1 + movement2 * 5.0 + movement3 * 7.0,
58 s_a.hc.2 + movement2 * 5.0 + movement3 * -10.0,
59 );
60 next.control.orientation =
61 Quaternion::rotation_x(s_a.hc.3 + movement2 * PI / 2.0 + movement3 * -2.3)
62 * Quaternion::rotation_y(s_a.hc.4 + movement2 * 1.3)
63 * Quaternion::rotation_z(s_a.hc.5 + movement2 * -1.0 + movement3 * 0.5);
64 next.upper_torso.orientation =
65 Quaternion::rotation_x(
66 movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
67 ) * Quaternion::rotation_z(movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7);
68
69 next.head.orientation = Quaternion::rotation_x(movement3 * 0.2)
70 * Quaternion::rotation_y(0.0 + movement2 * -0.1)
71 * Quaternion::rotation_z(movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6);
72
73 next.foot_l.position = Vec3::new(
76 -s_a.foot.0,
77 s_a.foot.1 + movement3 * 13.0,
78 s_a.foot.2 + movement3 * -2.0,
79 );
80 next.foot_l.orientation = Quaternion::rotation_x(-0.8 + movement3 * 1.7);
81
82 next.foot_r.position = Vec3::new(
83 s_a.foot.0,
84 s_a.foot.1 + 8.0 + movement3 * -13.0,
85 s_a.foot.2 + 5.0 + movement3 * -5.0,
86 );
87 next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7);
88 }
89
90 next
91 }
92}