veloren_voxygen_anim/biped_large/
leapmelee.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 LeapAnimation;
9
10impl Animation for LeapAnimation {
11 type Dependency<'a> = (
12 Option<ToolKind>,
13 Option<ToolKind>,
14 Vec3<f32>,
15 f32,
16 Option<StageSection>,
17 Option<&'a str>,
18 );
19 type Skeleton = BipedLargeSkeleton;
20
21 #[cfg(feature = "use-dyn-lib")]
22 const UPDATE_FN: &'static [u8] = b"biped_large_leapmelee\0";
23
24 #[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_leapmelee")]
25 fn update_skeleton_inner(
26 skeleton: &Self::Skeleton,
27 (active_tool_kind, _second_tool_kind, _velocity, _global_time, stage_section, ability_id): Self::Dependency<'_>,
28 anim_time: f32,
29 rate: &mut f32,
30 s_a: &SkeletonAttr,
31 ) -> Self::Skeleton {
32 *rate = 1.0;
33 let mut next = (*skeleton).clone();
34
35 let (movement1, movement2, movement3, movement4) = match stage_section {
36 Some(StageSection::Buildup) => (anim_time, 0.0, 0.0, 0.0),
37 Some(StageSection::Movement) => (1.0, anim_time.powf(0.25), 0.0, 0.0),
38 Some(StageSection::Action) => (1.0, 1.0, anim_time.powf(0.25), 0.0),
39 Some(StageSection::Recover) => (1.0, 1.0, 1.0, anim_time),
40 _ => (0.0, 0.0, 0.0, 0.0),
41 };
42
43 match active_tool_kind {
44 Some(ToolKind::Hammer) => {
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 = Quaternion::rotation_x(
64 movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
65 ) * Quaternion::rotation_z(
66 movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7,
67 );
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 Some(ToolKind::Natural) => match ability_id {
90 Some("common.abilities.custom.tursus.tusk_bash_leap") => {
91 next.head.position = Vec3::new(
92 0.0,
93 s_a.head.0 + movement3 * 12.0,
94 s_a.head.1 + movement3 * 8.0,
95 );
96 next.upper_torso.position =
97 Vec3::new(0.0, s_a.upper_torso.0, s_a.upper_torso.1 + movement1 * -4.0);
98 next.upper_torso.orientation = Quaternion::rotation_x(
99 movement1 * -0.3 + movement2 * -0.3 + movement3 * 0.2,
100 ) * Quaternion::rotation_z(
101 movement1 * 0.1 + movement2 * 0.2 + movement3 * -0.3,
102 );
103
104 next.head.orientation = Quaternion::rotation_x(
105 movement1 * -0.1 + movement2 * -0.1 + movement3 * 1.4,
106 );
107 next.foot_l.position = Vec3::new(
108 -s_a.foot.0,
109 s_a.foot.1 + movement3 * 1.0,
110 s_a.foot.2 + movement1 * -0.3 + movement3 * -2.0,
111 );
112 next.foot_l.orientation = Quaternion::rotation_x(
113 movement1 * -0.1 + movement2 * -0.2 + movement3 * 0.7,
114 );
115
116 next.foot_r.position = Vec3::new(
117 s_a.foot.0,
118 s_a.foot.1 + 1.0 + movement3 * -1.0,
119 s_a.foot.2 - 1.0 + movement1 * -0.3 + movement3 * -2.0,
120 );
121 next.foot_r.orientation = Quaternion::rotation_x(
122 movement1 * -0.1 + movement2 * -0.2 + movement3 * -0.7,
123 );
124 next.shoulder_l.orientation = Quaternion::rotation_x(
125 movement1 * 0.5 + movement2 * 0.1 + movement3 * -1.5,
126 );
127 next.shoulder_r.orientation = Quaternion::rotation_x(
128 movement1 * 0.9 + movement2 * 0.1 + movement3 * -1.5,
129 );
130 next.hand_l.orientation = Quaternion::rotation_x(
131 movement1 * 0.5 + movement2 * 0.1 + movement3 * -1.5,
132 );
133 next.hand_r.orientation = Quaternion::rotation_x(
134 movement1 * 0.9 + movement2 * 0.1 + movement3 * -1.5,
135 );
136 },
137 _ => {},
138 },
139 Some(ToolKind::Sword) => match ability_id {
140 Some("common.abilities.adlet.elder.leap") => {
141 next.hand_l.position = Vec3::new(s_a.hhl.0 * 1.5, -s_a.hhl.1, 5.0);
142 next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
143 next.hand_r.position = Vec3::new(s_a.hhr.0 / 2.0, 12.0, 5.0);
144 next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
145 next.main.position = Vec3::new(-6.0, 18.0, 4.0);
146 next.main.orientation =
147 Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
148 next.second.position = Vec3::new(-2.0, 20.0, 4.0);
149 next.second.orientation =
150 Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
151 next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
152 next.control.orientation =
153 Quaternion::rotation_x(movement2 * PI / 2.5 + movement3 * -2.3);
154 next.upper_torso.orientation = Quaternion::rotation_x(
155 movement1 * 0.3 + movement2 * 0.3 + movement3 * -0.9 + movement4 * 0.3,
156 ) * Quaternion::rotation_z(
157 movement1 * 0.5 + movement2 * 0.2 + movement3 * -0.7,
158 );
159
160 next.head.orientation = Quaternion::rotation_x(movement3 * 0.2)
161 * Quaternion::rotation_y(0.0 + movement2 * -0.1)
162 * Quaternion::rotation_z(
163 movement1 * -0.4 + movement2 * -0.2 + movement3 * 0.6,
164 );
165
166 next.foot_l.position = Vec3::new(
167 -s_a.foot.0,
168 s_a.foot.1 + movement3 * 13.0,
169 s_a.foot.2 + movement3 * -2.0,
170 );
171 next.foot_l.orientation = Quaternion::rotation_x(-0.8 + movement3 * 1.7);
172
173 next.foot_r.position = Vec3::new(
174 s_a.foot.0,
175 s_a.foot.1 + 8.0 + movement3 * -13.0,
176 s_a.foot.2 + 5.0 + movement3 * -5.0,
177 );
178 next.foot_r.orientation = Quaternion::rotation_x(0.9 + movement3 * -1.7);
179 },
180 _ => {},
181 },
182 _ => {},
183 }
184
185 next
186 }
187}