veloren_voxygen_anim/character/
equip.rs1use super::{
2 super::{Animation, vek::*},
3 CharacterSkeleton, SkeletonAttr,
4};
5use common::comp::item::ToolKind;
6use core::f32::consts::PI;
7
8pub struct EquipAnimation;
9
10impl Animation for EquipAnimation {
11 type Dependency<'a> = (Option<ToolKind>, Option<ToolKind>, f32, f32);
12 type Skeleton = CharacterSkeleton;
13
14 #[cfg(feature = "use-dyn-lib")]
15 const UPDATE_FN: &'static [u8] = b"character_equip\0";
16
17 #[cfg_attr(feature = "be-dyn-lib", export_name = "character_equip")]
18 fn update_skeleton_inner(
19 skeleton: &Self::Skeleton,
20 (active_tool_kind, _second_tool_kind, _velocity, _global_time): Self::Dependency<'_>,
21 anim_time: f32,
22 rate: &mut f32,
23 _s_a: &SkeletonAttr,
24 ) -> Self::Skeleton {
25 *rate = 1.0;
26 let mut next = (*skeleton).clone();
27 let equip_slow = 1.0 + (anim_time * 12.0 + PI).cos();
28 let equip_slowa = 1.0 + (anim_time * 12.0 + PI / 4.0).cos();
29 next.hand_l.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(PI / 2.0);
30 next.hand_r.orientation = Quaternion::rotation_y(-2.3) * Quaternion::rotation_z(PI / 2.0);
31 next.control.position = Vec3::new(equip_slowa * -1.5, 0.0, equip_slow * 1.5);
32
33 match active_tool_kind {
34 Some(ToolKind::Sword) => {
35 next.hand_l.position = Vec3::new(-8.0, -5.0, 17.0);
36 next.hand_r.position = Vec3::new(-6.0, -4.5, 14.0);
37 },
38 Some(ToolKind::Axe) => {
39 next.hand_l.position = Vec3::new(-7.0, -5.0, 17.0);
40 next.hand_r.position = Vec3::new(-5.0, -4.5, 14.0);
41 },
42 Some(ToolKind::Hammer | ToolKind::Pick | ToolKind::Shovel) => {
43 next.hand_l.position = Vec3::new(-5.0, -5.0, 13.0);
44 next.hand_r.position = Vec3::new(-3.0, -4.5, 10.0);
45 },
46 Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
47 next.hand_l.position = Vec3::new(-3.0, -5.0, 8.0);
48 next.hand_r.position = Vec3::new(-1.75, -4.5, 5.0);
49 },
50 Some(ToolKind::Bow) => {
51 next.hand_l.position = Vec3::new(-3.0, -5.0, 9.0);
52 next.hand_r.position = Vec3::new(-1.75, -4.5, 7.0);
53 },
54 Some(ToolKind::Instrument) => {
55 next.hand_l.position = Vec3::new(-5.0, -5.0, 8.0);
56 },
57 _ => {},
58 }
59
60 next
61 }
62}