From 31747d8ff1169ca0e9e2f4bf0730d9396029a687 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 21 Mar 2021 21:43:49 -0400 Subject: [PATCH] airship movement bits --- assets/server/manifests/ship_manifest.ron | 11 +++++--- assets/server/voxel/Human_Airship.vox | 4 +-- assets/server/voxel/propeller-l.vox | 4 +-- assets/server/voxel/propeller-r.vox | 4 +-- assets/server/voxel/rudder.vox | 3 +++ common/src/comp/body/ship.rs | 1 + voxygen/anim/src/character/run.rs | 1 - voxygen/anim/src/ship/idle.rs | 31 ++++++++++++++++++++--- voxygen/anim/src/ship/mod.rs | 14 +++++++--- voxygen/src/scene/figure/load.rs | 2 +- voxygen/src/scene/figure/mod.rs | 18 +++++++++++-- 11 files changed, 74 insertions(+), 19 deletions(-) create mode 100644 assets/server/voxel/rudder.vox diff --git a/assets/server/manifests/ship_manifest.ron b/assets/server/manifests/ship_manifest.ron index 817d579120..07151cabda 100644 --- a/assets/server/manifests/ship_manifest.ron +++ b/assets/server/manifests/ship_manifest.ron @@ -4,20 +4,25 @@ //offset: (3.0, 7.0, 1.0), //offset: (-20.75, -34.75, 1.25), //offset: (0.0, 0.0, 0.0), - offset: (-17.5, -35.0, 1.0), + offset: (-17.5, -39.0, 1.0), //phys_offset: (0.25, 0.25, 0.25), phys_offset: (0.0, 0.0, 0.0), central: ("Human_Airship"), ), bone1: ( - offset: (0.0, 40.0, -8.0), + offset: (-8.5, -2.0, -8.5), phys_offset: (0.0, 0.0, 0.0), central: ("propeller-l"), ), bone2: ( - offset: (0.0, 0.0, -4.0), + offset: (-8.5, -2.0, -8.5), phys_offset: (0.0, 0.0, 0.0), central: ("propeller-r"), ), + bone3: ( + offset: (-1.5, -11.0, -5.5), + phys_offset: (0.0, 0.0, 0.0), + central: ("rudder"), + ), ), }) diff --git a/assets/server/voxel/Human_Airship.vox b/assets/server/voxel/Human_Airship.vox index 36e3758d03..b4fa16fd1c 100644 --- a/assets/server/voxel/Human_Airship.vox +++ b/assets/server/voxel/Human_Airship.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ba02746d73ebf853c0511b673510c09bd47e3ab0fff13d936feb181a8378ebd9 -size 78024 +oid sha256:6704005c60327e0b288bff92cca7630b2b48e5167280a4f36a2072854d7204f1 +size 77892 diff --git a/assets/server/voxel/propeller-l.vox b/assets/server/voxel/propeller-l.vox index a193fa89ee..0ae34b39ea 100644 --- a/assets/server/voxel/propeller-l.vox +++ b/assets/server/voxel/propeller-l.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:09ef4bad2557abcc5a2b938f21053babc7770ebe2333039aef9b98ba930b7ec7 -size 1584 +oid sha256:6be0747c183055aa031359afa8e58cc9331f23c9179989da995b725a09597fa4 +size 1944 diff --git a/assets/server/voxel/propeller-r.vox b/assets/server/voxel/propeller-r.vox index 5b940751e6..d712cea283 100644 --- a/assets/server/voxel/propeller-r.vox +++ b/assets/server/voxel/propeller-r.vox @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4947977524b88bc5adfa934d9061a3499e94b960abb3bcf0a3e2aca482096dc -size 1584 +oid sha256:aba271548b067b3125148e0959fba8cecf9f41c50c0b5f1e4488e3536068bf97 +size 1944 diff --git a/assets/server/voxel/rudder.vox b/assets/server/voxel/rudder.vox new file mode 100644 index 0000000000..079abfce7a --- /dev/null +++ b/assets/server/voxel/rudder.vox @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f169e8c80a44d488b3ea404319b327c000480b68af4a1d52a098bedd68fb4f3 +size 1576 diff --git a/common/src/comp/body/ship.rs b/common/src/comp/body/ship.rs index a4a465ccf8..68532b677b 100644 --- a/common/src/comp/body/ship.rs +++ b/common/src/comp/body/ship.rs @@ -58,6 +58,7 @@ pub mod figuredata { pub bone0: ShipCentralSubSpec, pub bone1: ShipCentralSubSpec, pub bone2: ShipCentralSubSpec, + pub bone3: ShipCentralSubSpec, } #[derive(Deserialize)] diff --git a/voxygen/anim/src/character/run.rs b/voxygen/anim/src/character/run.rs index 3a4e350db2..42970f8f98 100644 --- a/voxygen/anim/src/character/run.rs +++ b/voxygen/anim/src/character/run.rs @@ -102,7 +102,6 @@ impl Animation for RunAnimation { } else { 0.0 } * 1.3; - //println!("speednorm {} ",side); let head_look = Vec2::new( (global_time + anim_time / 18.0).floor().mul(7331.0).sin() * 0.2, diff --git a/voxygen/anim/src/ship/idle.rs b/voxygen/anim/src/ship/idle.rs index a8e59d5c56..dc819c8988 100644 --- a/voxygen/anim/src/ship/idle.rs +++ b/voxygen/anim/src/ship/idle.rs @@ -7,7 +7,14 @@ use common::comp::item::ToolKind; pub struct IdleAnimation; impl Animation for IdleAnimation { - type Dependency = (Option, Option, f32); + type Dependency = ( + Option, + Option, + f32, + f32, + Vec3, + Vec3, + ); type Skeleton = ShipSkeleton; #[cfg(feature = "use-dyn-lib")] @@ -17,17 +24,35 @@ impl Animation for IdleAnimation { #[allow(clippy::approx_constant)] // TODO: Pending review in #587 fn update_skeleton_inner( skeleton: &Self::Skeleton, - (_active_tool_kind, _second_tool_kind, _global_time): Self::Dependency, + (_active_tool_kind, _second_tool_kind, _global_time, acc_vel, orientation, last_ori): Self::Dependency, _anim_time: f32, _rate: &mut f32, s_a: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - + let ori: Vec2 = Vec2::from(orientation); + let last_ori = Vec2::from(last_ori); + let tilt = if ::vek::Vec2::new(ori, last_ori) + .map(|o| o.magnitude_squared()) + .map(|m| m > 0.001 && m.is_finite()) + .reduce_and() + && ori.angle_between(last_ori).is_finite() + { + ori.angle_between(last_ori).min(0.2) + * last_ori.determine_side(Vec2::zero(), ori).signum() + } else { + 0.0 + } * 1.3; next.bone0.position = Vec3::new(s_a.bone0.0, s_a.bone0.1, s_a.bone0.2) / 11.0; next.bone1.position = Vec3::new(s_a.bone1.0, s_a.bone1.1, s_a.bone1.2) / 11.0; + next.bone1.orientation = Quaternion::rotation_y(acc_vel * 0.8); + next.bone2.position = Vec3::new(s_a.bone2.0, s_a.bone2.1, s_a.bone2.2) / 11.0; + next.bone2.orientation = Quaternion::rotation_y(-acc_vel * 0.8); + + next.bone3.position = Vec3::new(s_a.bone3.0, s_a.bone3.1, s_a.bone3.2) / 11.0; + next.bone3.orientation = Quaternion::rotation_z(tilt * 25.0); next } } diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index 14316d2ab3..f9c86cf033 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -12,13 +12,15 @@ pub type Body = comp::ship::Body; skeleton_impls!(struct ShipSkeleton { + bone0, + bone1, + + bone2, + + bone3, }); impl Skeleton for ShipSkeleton { type Attr = SkeletonAttr; type Body = Body; - const BONE_COUNT: usize = 2; + const BONE_COUNT: usize = 4; #[cfg(feature = "use-dyn-lib")] const COMPUTE_FN: &'static [u8] = b"ship_compute_mats\0"; @@ -32,7 +34,9 @@ impl Skeleton for ShipSkeleton { *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ make_bone(bone0_mat * Mat4::scaling_3d(1.0 / 11.0)), - make_bone(Mat4::::from(self.bone1) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ + make_bone(bone0_mat * Mat4::::from(self.bone1) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ + make_bone(bone0_mat * Mat4::::from(self.bone2) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ + make_bone(bone0_mat * Mat4::::from(self.bone3) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ ]; Vec3::unit_z() * 0.5 } @@ -41,6 +45,8 @@ impl Skeleton for ShipSkeleton { pub struct SkeletonAttr { bone0: (f32, f32, f32), bone1: (f32, f32, f32), + bone2: (f32, f32, f32), + bone3: (f32, f32, f32), } impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { @@ -58,7 +64,9 @@ impl Default for SkeletonAttr { fn default() -> Self { Self { bone0: (0.0, 0.0, 0.0), - bone1: (0.0, 0.0, 0.0), + bone1: (-13.0, -25.0, 10.0), + bone2: (13.0, -25.0, 10.0), + bone3: (0.0, -27.5, 8.5), } } } diff --git a/voxygen/src/scene/figure/load.rs b/voxygen/src/scene/figure/load.rs index a04e9c5d16..ae677b6127 100644 --- a/voxygen/src/scene/figure/load.rs +++ b/voxygen/src/scene/figure/load.rs @@ -4215,7 +4215,7 @@ impl BodySpec for ship::Body { Some(mesh_ship_bone(map, body, |spec| &spec.bone0)), Some(mesh_ship_bone(map, body, |spec| &spec.bone1)), Some(mesh_ship_bone(map, body, |spec| &spec.bone2)), - None, + Some(mesh_ship_bone(map, body, |spec| &spec.bone3)), None, None, None, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 0771ec4a1e..8a6b14ce4e 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -4226,14 +4226,28 @@ impl FigureMgr { // Standing (true, false, false) => anim::ship::IdleAnimation::update_skeleton( &ShipSkeleton::default(), - (active_tool_kind, second_tool_kind, time), + ( + active_tool_kind, + second_tool_kind, + time, + state.acc_vel, + ori * anim::vek::Vec3::::unit_y(), + state.last_ori * anim::vek::Vec3::::unit_y(), + ), state.state_time, &mut state_animation_rate, skeleton_attr, ), _ => anim::ship::IdleAnimation::update_skeleton( &ShipSkeleton::default(), - (active_tool_kind, second_tool_kind, time), + ( + active_tool_kind, + second_tool_kind, + time, + state.acc_vel, + ori * anim::vek::Vec3::::unit_y(), + state.last_ori * anim::vek::Vec3::::unit_y(), + ), state.state_time, &mut state_animation_rate, skeleton_attr,