veloren/voxygen/src/anim/character/wield.rs

155 lines
6.5 KiB
Rust
Raw Normal View History

2019-06-30 02:13:34 +00:00
use super::{
super::{Animation, SkeletonAttr},
CharacterSkeleton,
};
2019-07-29 13:44:16 +00:00
use common::comp::item::Tool;
2019-06-30 02:13:34 +00:00
use vek::*;
pub struct WieldAnimation;
2019-06-30 02:13:34 +00:00
impl Animation for WieldAnimation {
2019-06-30 02:13:34 +00:00
type Skeleton = CharacterSkeleton;
type Dependency = (f32, f64);
2019-06-30 02:13:34 +00:00
fn update_skeleton(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
2019-06-30 02:13:34 +00:00
anim_time: f64,
_rate: &mut f32,
2019-06-30 02:13:34 +00:00
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
2019-07-04 14:58:59 +00:00
let wave = (anim_time as f32 * 12.0).sin();
2019-06-30 02:13:34 +00:00
2019-07-29 13:44:16 +00:00
match Tool::Hammer {
//TODO: Inventory
2019-07-29 13:44:16 +00:00
Tool::Sword => {
next.l_hand.offset = Vec3::new(-6.0, 3.75, 0.25);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.0 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
2019-07-29 13:44:16 +00:00
Tool::Axe => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
2019-07-29 13:44:16 +00:00
Tool::Hammer => {
2019-10-02 10:05:17 +00:00
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
2019-10-02 10:05:17 +00:00
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
5.0 + skeleton_attr.weapon_x,
8.75 + skeleton_attr.weapon_y,
-2.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
2019-10-02 10:05:17 +00:00
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave * -0.25);
next.weapon.scale = Vec3::one();
}
2019-07-29 13:44:16 +00:00
Tool::Staff => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
2019-07-29 13:44:16 +00:00
Tool::SwordShield => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
2019-07-29 13:44:16 +00:00
Tool::Bow => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
2019-07-29 13:44:16 +00:00
Tool::Daggers => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.weapon.offset = Vec3::new(
-6.0 + skeleton_attr.weapon_x,
4.5 + skeleton_attr.weapon_y,
0.0,
);
next.weapon.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.weapon.scale = Vec3::one();
}
2019-07-07 22:06:29 +00:00
}
2019-06-30 02:13:34 +00:00
next
}
}