mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
swivel, quadsmall/quadlow offsets
This commit is contained in:
parent
3b7ea72a9c
commit
41ed0f284f
@ -149,7 +149,7 @@ impl Animation for MountAnimation {
|
|||||||
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
|
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
|
||||||
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
|
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
|
||||||
|
|
||||||
next.torso.position = Vec3::new(0.0, 0.0, stop * -1.76);
|
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
|
||||||
|
|
||||||
if skeleton.holding_lantern {
|
if skeleton.holding_lantern {
|
||||||
next.hand_r.position = Vec3::new(
|
next.hand_r.position = Vec3::new(
|
||||||
|
@ -64,7 +64,9 @@ impl Animation for ShootAnimation {
|
|||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
} * 1.3;
|
} * 1.3;
|
||||||
|
let ori_angle = orientation.y.atan2(orientation.x);
|
||||||
|
let lookdir_angle = look_dir.y.atan2(look_dir.x);
|
||||||
|
let swivel = lookdir_angle - ori_angle;
|
||||||
match ability_info.and_then(|a| a.tool) {
|
match ability_info.and_then(|a| a.tool) {
|
||||||
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
|
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
|
||||||
let (move1, move2, move3) = match stage_section {
|
let (move1, move2, move3) = match stage_section {
|
||||||
@ -96,14 +98,14 @@ impl Animation for ShootAnimation {
|
|||||||
* Quaternion::rotation_z(
|
* Quaternion::rotation_z(
|
||||||
s_a.stc.5 - (0.2 + move1 * -0.5 + move2 * 0.8) * (1.0 - move3),
|
s_a.stc.5 - (0.2 + move1 * -0.5 + move2 * 0.8) * (1.0 - move3),
|
||||||
);
|
);
|
||||||
next.chest.orientation =
|
|
||||||
Quaternion::rotation_z((move1 * 0.3 + move2 * 0.2) * (1.0 - move3));
|
|
||||||
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
|
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
|
||||||
next.head.orientation = Quaternion::rotation_x(look_dir.z * 0.7)
|
next.head.orientation = Quaternion::rotation_x(look_dir.z * 0.7)
|
||||||
* Quaternion::rotation_z(
|
* Quaternion::rotation_z(
|
||||||
tilt * -2.5 + (move1 * -0.2 + move2 * -0.4) * (1.0 - move3),
|
tilt * -2.5 + (move1 * -0.2 + move2 * -0.4) * (1.0 - move3),
|
||||||
);
|
);
|
||||||
|
next.chest.orientation = Quaternion::rotation_z(swivel * 0.8);
|
||||||
|
next.torso.orientation = Quaternion::rotation_z(swivel * 0.2);
|
||||||
if speed < 0.5 {
|
if speed < 0.5 {
|
||||||
next.belt.orientation =
|
next.belt.orientation =
|
||||||
Quaternion::rotation_x(0.07) * Quaternion::rotation_z(0.0);
|
Quaternion::rotation_x(0.07) * Quaternion::rotation_z(0.0);
|
||||||
@ -148,17 +150,17 @@ impl Animation for ShootAnimation {
|
|||||||
s_a.bc.1 + 2.0 + (look_dir.z * -5.0).min(-2.0) + move2 * -1.0,
|
s_a.bc.1 + 2.0 + (look_dir.z * -5.0).min(-2.0) + move2 * -1.0,
|
||||||
s_a.bc.2 + 8.0 + (look_dir.z * 15.0).max(-8.0),
|
s_a.bc.2 + 8.0 + (look_dir.z * 15.0).max(-8.0),
|
||||||
);
|
);
|
||||||
next.control.orientation = Quaternion::rotation_x(look_dir.z + move2 * -0.0)
|
next.control.orientation = Quaternion::rotation_x(look_dir.z)
|
||||||
* Quaternion::rotation_y(-look_dir.z + s_a.bc.4 - 1.25 + move2 * -0.0)
|
* Quaternion::rotation_y(-look_dir.z + s_a.bc.4 - 1.25)
|
||||||
* Quaternion::rotation_z(s_a.bc.5 - 0.2 + move2 * -0.1);
|
* Quaternion::rotation_z(0.0 - 0.0 + move2 * -0.0); //.2,.1
|
||||||
next.chest.orientation = Quaternion::rotation_z(0.8 + move2 * 0.5);
|
|
||||||
next.head.position = Vec3::new(0.0 - 2.0, s_a.head.0, s_a.head.1);
|
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
|
||||||
|
|
||||||
|
next.head.orientation =
|
||||||
|
Quaternion::rotation_x(look_dir.z * 0.7) * Quaternion::rotation_z(tilt * -0.0);
|
||||||
|
next.chest.orientation = Quaternion::rotation_z(swivel * 0.8);
|
||||||
|
next.torso.orientation = Quaternion::rotation_z(swivel * 0.2);
|
||||||
|
|
||||||
next.head.orientation = Quaternion::rotation_x(look_dir.z * 0.7)
|
|
||||||
* Quaternion::rotation_z(tilt * -2.5 - 0.5 + (move2 * -0.2).sin());
|
|
||||||
next.chest.orientation = Quaternion::rotation_z(0.8 + move2 * 0.2);
|
|
||||||
next.belt.orientation = Quaternion::rotation_z(move2 * 0.3);
|
|
||||||
next.shorts.orientation = Quaternion::rotation_z(move2 * 0.5);
|
|
||||||
next.shoulder_l.orientation = Quaternion::rotation_x(move2 * 0.5);
|
next.shoulder_l.orientation = Quaternion::rotation_x(move2 * 0.5);
|
||||||
|
|
||||||
if speed < 0.5 {
|
if speed < 0.5 {
|
||||||
|
@ -33,6 +33,7 @@ skeleton_impls!(struct QuadrupedLowSkeleton {
|
|||||||
+ foot_fr,
|
+ foot_fr,
|
||||||
+ foot_bl,
|
+ foot_bl,
|
||||||
+ foot_br,
|
+ foot_br,
|
||||||
|
mount,
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Skeleton for QuadrupedLowSkeleton {
|
impl Skeleton for QuadrupedLowSkeleton {
|
||||||
@ -69,15 +70,32 @@ impl Skeleton for QuadrupedLowSkeleton {
|
|||||||
make_bone(chest_mat * Mat4::<f32>::from(self.foot_bl)),
|
make_bone(chest_mat * Mat4::<f32>::from(self.foot_bl)),
|
||||||
make_bone(chest_mat * Mat4::<f32>::from(self.foot_br)),
|
make_bone(chest_mat * Mat4::<f32>::from(self.foot_br)),
|
||||||
];
|
];
|
||||||
|
//let (mount_bone_mat, mount_bone_ori) = (chest_mat, self.chest.orientation);
|
||||||
|
// Offset from the mounted bone's origin.
|
||||||
|
// Note: This could be its own bone if we need to animate it independently.
|
||||||
|
|
||||||
|
// NOTE: We apply the ori from base_mat externally so we don't need to worry
|
||||||
|
// about it here for now.
|
||||||
|
|
||||||
|
use comp::quadruped_low::Species::*;
|
||||||
|
let (mount_bone_mat, mount_bone_ori) = match (body.species, body.body_type) {
|
||||||
|
(Maneater, _) => (
|
||||||
|
head_upper_mat,
|
||||||
|
self.chest.orientation * self.head_lower.orientation * self.head_upper.orientation,
|
||||||
|
),
|
||||||
|
_ => (chest_mat, self.chest.orientation),
|
||||||
|
};
|
||||||
|
let mount_position = (mount_bone_mat * Vec4::from_point(mount_point(&body)))
|
||||||
|
.homogenized()
|
||||||
|
.xyz();
|
||||||
|
let mount_orientation = mount_bone_ori;
|
||||||
|
|
||||||
Offsets {
|
Offsets {
|
||||||
lantern: None,
|
lantern: None,
|
||||||
// TODO: see quadruped_medium for how to animate this
|
|
||||||
mount_bone: Transform {
|
mount_bone: Transform {
|
||||||
position: common::comp::Body::QuadrupedLow(body)
|
position: mount_position,
|
||||||
.mount_offset()
|
orientation: mount_orientation,
|
||||||
.into_tuple()
|
scale: Vec3::one(),
|
||||||
.into(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -311,3 +329,25 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn mount_point(body: &Body) -> Vec3<f32> {
|
||||||
|
use comp::quadruped_low::{BodyType::*, Species::*};
|
||||||
|
match (body.species, body.body_type) {
|
||||||
|
(Crocodile, _) => (0.0, 4.5, 0.0),
|
||||||
|
(Alligator, _) => (0.0, 4.25, 0.0),
|
||||||
|
(Salamander, Male) => (0.0, 5.0, 1.0),
|
||||||
|
(Salamander, Female) => (0.0, 5.0, 1.0),
|
||||||
|
(Monitor, _) => (0.0, 2.0, 0.0),
|
||||||
|
(Asp, _) => (0.0, 2.0, 2.0),
|
||||||
|
(Tortoise, _) => (0.0, -7.0, 1.0),
|
||||||
|
(Rocksnapper, _) => (0.0, -7.0, 6.5),
|
||||||
|
(Pangolin, _) => (0.0, -6.5, 0.0),
|
||||||
|
(Maneater, _) => (0.0, 4.0, -9.5),
|
||||||
|
(Sandshark, _) => (0.0, -4.0, 0.0),
|
||||||
|
(Hakulaq, _) => (0.0, 4.0, -2.5),
|
||||||
|
(Lavadrake, _) => (0.0, 2.0, 0.5),
|
||||||
|
(Icedrake, _) => (0.0, -8.0, 4.5),
|
||||||
|
(Basilisk, _) => (0.0, -2.0, 4.0),
|
||||||
|
(Deadwood, _) => (0.0, -2.0, -1.0),
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
@ -25,6 +25,7 @@ skeleton_impls!(struct QuadrupedSmallSkeleton {
|
|||||||
+ leg_bl,
|
+ leg_bl,
|
||||||
+ leg_br,
|
+ leg_br,
|
||||||
+ tail,
|
+ tail,
|
||||||
|
mount,
|
||||||
});
|
});
|
||||||
|
|
||||||
impl Skeleton for QuadrupedSmallSkeleton {
|
impl Skeleton for QuadrupedSmallSkeleton {
|
||||||
@ -45,9 +46,10 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
|||||||
let chest_mat = base_mat
|
let chest_mat = base_mat
|
||||||
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0)
|
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0)
|
||||||
* Mat4::<f32>::from(self.chest);
|
* Mat4::<f32>::from(self.chest);
|
||||||
|
let head_mat = chest_mat * Mat4::<f32>::from(self.head);
|
||||||
|
|
||||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||||
make_bone(chest_mat * Mat4::<f32>::from(self.head)),
|
make_bone(head_mat),
|
||||||
make_bone(chest_mat),
|
make_bone(chest_mat),
|
||||||
make_bone(chest_mat * Mat4::<f32>::from(self.leg_fl)),
|
make_bone(chest_mat * Mat4::<f32>::from(self.leg_fl)),
|
||||||
make_bone(chest_mat * Mat4::<f32>::from(self.leg_fr)),
|
make_bone(chest_mat * Mat4::<f32>::from(self.leg_fr)),
|
||||||
@ -55,15 +57,22 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
|||||||
make_bone(chest_mat * Mat4::<f32>::from(self.leg_br)),
|
make_bone(chest_mat * Mat4::<f32>::from(self.leg_br)),
|
||||||
make_bone(chest_mat * Mat4::<f32>::from(self.tail)),
|
make_bone(chest_mat * Mat4::<f32>::from(self.tail)),
|
||||||
];
|
];
|
||||||
|
use comp::quadruped_small::Species::*;
|
||||||
|
let (mount_bone_mat, mount_bone_ori) = match (body.species, body.body_type) {
|
||||||
|
(Dodarock, _) => (head_mat, self.chest.orientation * self.head.orientation),
|
||||||
|
_ => (chest_mat, self.chest.orientation),
|
||||||
|
};
|
||||||
|
let mount_position = (mount_bone_mat * Vec4::from_point(mount_point(&body)))
|
||||||
|
.homogenized()
|
||||||
|
.xyz();
|
||||||
|
let mount_orientation = mount_bone_ori;
|
||||||
|
|
||||||
Offsets {
|
Offsets {
|
||||||
lantern: None,
|
lantern: None,
|
||||||
// TODO: see quadruped_medium for how to animate this
|
|
||||||
mount_bone: Transform {
|
mount_bone: Transform {
|
||||||
position: common::comp::Body::QuadrupedSmall(body)
|
position: mount_position,
|
||||||
.mount_offset()
|
orientation: mount_orientation,
|
||||||
.into_tuple()
|
scale: Vec3::one(),
|
||||||
.into(),
|
|
||||||
..Default::default()
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,3 +401,37 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn mount_point(body: &Body) -> Vec3<f32> {
|
||||||
|
use comp::quadruped_small::{BodyType::*, Species::*};
|
||||||
|
match (body.species, body.body_type) {
|
||||||
|
(Pig, _) => (0.0, -2.0, -2.5),
|
||||||
|
(Fox, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Sheep, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Boar, _) => (0.0, -2.0, -3.5),
|
||||||
|
(Jackalope, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Skunk, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Cat, _) => (0.0, -5.0, -4.0),
|
||||||
|
(Batfox, _) => (0.0, -4.0, -3.0),
|
||||||
|
(Raccoon, _) => (0.0, -4.0, -2.5),
|
||||||
|
(Quokka, _) => (0.0, -3.0, -3.5),
|
||||||
|
(Dodarock, _) => (0.0, 0.0, 2.5),
|
||||||
|
(Holladon, _) => (0.0, -2.0, -2.5),
|
||||||
|
(Hyena, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Rabbit, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Truffler, _) => (0.0, -6.0, 6.5),
|
||||||
|
(Frog, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Rat, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Axolotl, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Gecko, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Turtle, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Squirrel, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Fungome, _) => (0.0, -4.0, -4.5),
|
||||||
|
(Porcupine, _) => (0.0, -4.0, -3.5),
|
||||||
|
(Beaver, _) => (0.0, -2.0, -3.5),
|
||||||
|
(Hare, Male) => (0.0, -4.0, -4.5),
|
||||||
|
(Hare, Female) => (0.0, -4.0, -4.5),
|
||||||
|
(Dog, _) => (0.0, -4.0, -2.5),
|
||||||
|
(Goat, _) => (0.0, -4.0, -3.5),
|
||||||
|
}
|
||||||
|
.into()
|
||||||
|
}
|
||||||
|
@ -2299,9 +2299,17 @@ impl FigureMgr {
|
|||||||
skeleton_attr,
|
skeleton_attr,
|
||||||
),
|
),
|
||||||
// In air
|
// In air
|
||||||
(false, _, false) => anim::quadruped_low::JumpAnimation::update_skeleton(
|
(false, _, false) => anim::quadruped_low::RunAnimation::update_skeleton(
|
||||||
&QuadrupedLowSkeleton::default(),
|
&QuadrupedLowSkeleton::default(),
|
||||||
(rel_vel.magnitude(), time),
|
(
|
||||||
|
rel_vel.magnitude(),
|
||||||
|
// TODO: Update to use the quaternion.
|
||||||
|
ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||||
|
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||||
|
time,
|
||||||
|
rel_avg_vel,
|
||||||
|
state.acc_vel,
|
||||||
|
),
|
||||||
state.state_time,
|
state.state_time,
|
||||||
&mut state_animation_rate,
|
&mut state_animation_rate,
|
||||||
skeleton_attr,
|
skeleton_attr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user