mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Setup animation mount points for quadruped medium, update offsets in
common for new quadruped mediums, properly transform the offset in the mount system using ori, fix issue with composing in the base ori with the mounting bone ori in voxygen.
This commit is contained in:
parent
32915f89a8
commit
3e6fd0ee1d
@ -804,11 +804,10 @@ impl Body {
|
||||
(quadruped_medium::Species::Dreadhorn, _) => [0.2, 0.2, 3.5],
|
||||
(quadruped_medium::Species::Moose, _) => [-0.6, -0.6, 2.1],
|
||||
(quadruped_medium::Species::Snowleopard, _) => [-0.5, -0.5, 1.4],
|
||||
// TODO: Fill in these values
|
||||
(quadruped_medium::Species::Mammoth, _) => [0.0, 0.0, 0.0],
|
||||
(quadruped_medium::Species::Ngoubou, _) => [0.0, 0.0, 0.0],
|
||||
(quadruped_medium::Species::Llama, _) => [0.0, 0.0, 0.0],
|
||||
(quadruped_medium::Species::Alpaca, _) => [0.0, 0.0, 0.0],
|
||||
(quadruped_medium::Species::Mammoth, _) => [0.0, 4.9, 7.2],
|
||||
(quadruped_medium::Species::Ngoubou, _) => [0.0, 0.3, 2.0],
|
||||
(quadruped_medium::Species::Llama, _) => [0.0, 0.1, 1.5],
|
||||
(quadruped_medium::Species::Alpaca, _) => [0.0, -0.1, 1.0],
|
||||
}
|
||||
},
|
||||
Body::Ship(ship) => match ship {
|
||||
|
@ -69,14 +69,8 @@ impl<'a> System<'a> for Sys {
|
||||
let mounter_body = bodies.get(mounter);
|
||||
let mounting_offset = body.map_or(Vec3::unit_z(), Body::mountee_offset)
|
||||
+ mounter_body.map_or(Vec3::zero(), Body::mounter_offset);
|
||||
let _ = positions.insert(
|
||||
mounter,
|
||||
Pos(Vec3 {
|
||||
x: pos.0.x + ori.look_dir().x * mounting_offset.x,
|
||||
y: pos.0.y + ori.look_dir().y * mounting_offset.y,
|
||||
z: pos.0.z + mounting_offset.z,
|
||||
}),
|
||||
);
|
||||
let _ = positions
|
||||
.insert(mounter, Pos(pos.0 + ori.to_quat() * mounting_offset));
|
||||
let _ = orientations.insert(mounter, ori);
|
||||
let _ = velocities.insert(mounter, vel);
|
||||
}
|
||||
|
@ -85,15 +85,22 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
||||
make_bone(leg_br_mat * Mat4::<f32>::from(self.foot_br)),
|
||||
];
|
||||
|
||||
use comp::quadruped_medium::Species::*;
|
||||
let (mount_bone_mat, mount_bone_ori) = match (body.species, body.body_type) {
|
||||
(Mammoth, _) => (
|
||||
head_mat,
|
||||
self.torso_front.orientation * self.neck.orientation * self.head.orientation,
|
||||
),
|
||||
_ => (torso_front_mat, self.torso_front.orientation),
|
||||
};
|
||||
// Offset from the mounted bone's origin.
|
||||
// Note: This could be its own bone if we need to animate it.
|
||||
let mount_point = Vec3::new(0.0, -7.0, 3.0);
|
||||
let mount_position = (torso_front_mat * Vec4::from_point(mount_point))
|
||||
// Note: This could be its own bone if we need to animate it independently.
|
||||
let mount_position = (mount_bone_mat * Vec4::from_point(mount_point(&body)))
|
||||
.homogenized()
|
||||
.xyz();
|
||||
// NOTE: We apply the ori from base_mat externally so we don't need to worry
|
||||
// about it here for now.
|
||||
let mount_orientation = self.torso_front.orientation;
|
||||
let mount_orientation = mount_bone_ori;
|
||||
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
@ -677,3 +684,45 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn mount_point(body: &Body) -> Vec3<f32> {
|
||||
use comp::quadruped_medium::{BodyType::*, Species::*};
|
||||
match (body.species, body.body_type) {
|
||||
(Grolgar, _) => (0.0, -6.0, 6.0),
|
||||
(Saber, _) => (0.0, -12.0, 4.0),
|
||||
(Tuskram, _) => (0.0, -17.0, 2.0),
|
||||
(Lion, _) => (0.0, -8.0, 4.0),
|
||||
(Tarasque, _) => (0.0, -6.0, 4.0),
|
||||
(Tiger, _) => (0.0, -8.0, 4.0),
|
||||
(Wolf, _) => (0.0, -7.0, 3.0),
|
||||
(Frostfang, _) => (0.0, -3.0, 4.0),
|
||||
(Mouflon, _) => (0.0, -8.0, 2.0),
|
||||
(Catoblepas, _) => (0.0, -8.0, 2.0),
|
||||
(Bonerattler, _) => (0.0, -1.0, 4.0),
|
||||
(Deer, _) => (0.0, -9.0, 3.0),
|
||||
(Hirdrasil, _) => (0.0, -11.0, 3.0),
|
||||
(Roshwalr, _) => (0.0, -1.0, 7.0),
|
||||
(Donkey, _) => (0.0, -5.0, 2.0),
|
||||
(Camel, _) => (0.0, -13.0, 5.0),
|
||||
(Zebra, _) => (0.0, -6.0, 3.0),
|
||||
(Antelope, _) => (0.0, -8.0, 3.0),
|
||||
(Kelpie, _) => (0.0, -6.0, 3.0),
|
||||
(Horse, _) => (0.0, -8.0, 3.0),
|
||||
(Barghest, _) => (0.0, -8.0, 5.0),
|
||||
(Cattle, Male) => (0.0, -3.0, 8.0),
|
||||
(Cattle, Female) => (0.0, -2.0, 6.0),
|
||||
(Darkhound, _) => (0.0, -2.0, 3.0),
|
||||
(Highland, _) => (0.0, -3.0, 8.0),
|
||||
(Yak, _) => (0.0, -8.0, 9.0),
|
||||
(Panda, _) => (0.0, -10.0, 5.0),
|
||||
(Bear, _) => (0.0, -11.0, 6.0),
|
||||
(Dreadhorn, _) => (0.0, 0.0, 10.0),
|
||||
(Moose, _) => (0.0, -9.0, 6.0),
|
||||
(Snowleopard, _) => (0.0, -9.0, 4.0),
|
||||
(Mammoth, _) => (0.0, 5.0, 8.0),
|
||||
(Ngoubou, _) => (0.0, -7.0, 6.0),
|
||||
(Llama, _) => (0.0, -6.0, 5.0),
|
||||
(Alpaca, _) => (0.0, -9.0, 3.0),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
@ -5408,11 +5408,7 @@ impl<S: Skeleton> FigureState<S> {
|
||||
self.state_time += dt * state_animation_rate;
|
||||
|
||||
let mat = {
|
||||
let ori_scale = anim::vek::Mat4::from(*ori)
|
||||
* anim::vek::Mat4::scaling_3d(anim::vek::Vec3::from(*scale));
|
||||
// NOTE: It is kind of a hack to use this entity's ori here if it is
|
||||
// mounted on another but this happens to match the ori of the
|
||||
// mountee so it works, change this if it causes jankiness in the future.
|
||||
let scale_mat = anim::vek::Mat4::scaling_3d(anim::vek::Vec3::from(*scale));
|
||||
if let Some((transform, _)) = *mount_transform_pos {
|
||||
// Note: if we had a way to compute a "default" transform of the bones then in
|
||||
// the animations we could make use of the mountee_offset from common by
|
||||
@ -5423,13 +5419,21 @@ impl<S: Skeleton> FigureState<S> {
|
||||
// animations and keep it in sync.
|
||||
//
|
||||
// Component of mounting offset specific to the mounter.
|
||||
let mounter_offset = anim::vek::Mat4::translation_3d(
|
||||
let mounter_offset = anim::vek::Mat4::<f32>::translation_3d(
|
||||
body.map_or_else(Vec3::zero, |b| b.mounter_offset()),
|
||||
);
|
||||
|
||||
anim::vek::Mat4::from(transform) * ori_scale * mounter_offset
|
||||
// NOTE: It is kind of a hack to use this entity's ori here if it is
|
||||
// mounted on another but this happens to match the ori of the
|
||||
// mountee so it works, change this if it causes jankiness in the future.
|
||||
let transform = anim::vek::Transform {
|
||||
orientation: *ori * transform.orientation,
|
||||
..transform
|
||||
};
|
||||
anim::vek::Mat4::from(transform) * mounter_offset * scale_mat
|
||||
} else {
|
||||
ori_scale
|
||||
let ori_mat = anim::vek::Mat4::from(*ori);
|
||||
ori_mat * scale_mat
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user