mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Anims export a transform for mounts
This commit is contained in:
parent
026ba616ff
commit
486fbf940e
@ -682,7 +682,7 @@ impl Body {
|
||||
(quadruped_medium::Species::Zebra, _) => Vec3::from([0.5, 0.5, 0.0]),
|
||||
(quadruped_medium::Species::Antelope, _) => Vec3::from([0.3, 0.3, 0.0]),
|
||||
(quadruped_medium::Species::Kelpie, _) => Vec3::from([0.5, 0.5, 0.0]),
|
||||
(quadruped_medium::Species::Horse, _) => Vec3::from([0.1, 0.1, 0.0]),
|
||||
(quadruped_medium::Species::Horse, _) => Vec3::from([0.0, 0.0, 0.0]),
|
||||
(quadruped_medium::Species::Barghest, _) => Vec3::from([0.5, 0.5, 0.0]),
|
||||
(quadruped_medium::Species::Cattle, quadruped_medium::BodyType::Male) => {
|
||||
Vec3::from([0.5, 0.5, 0.0])
|
||||
|
@ -76,8 +76,9 @@ impl Skeleton for BipedLargeSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let upper_torso = Mat4::<f32>::from(self.upper_torso);
|
||||
|
||||
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
@ -124,7 +125,7 @@ impl Skeleton for BipedLargeSkeleton {
|
||||
// FIXME: Should this be control_l_mat?
|
||||
make_bone(upper_torso_mat * control_mat * hand_l_mat * Mat4::<f32>::from(self.hold)),
|
||||
];
|
||||
[Vec3::default(), Vec3::default()]
|
||||
[Transform::default(), Transform::default()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,9 @@ impl Skeleton for BipedSmallSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
let pants_mat = chest_mat * Mat4::<f32>::from(self.pants);
|
||||
let control_mat = chest_mat * Mat4::<f32>::from(self.control);
|
||||
@ -64,7 +65,7 @@ impl Skeleton for BipedSmallSkeleton {
|
||||
make_bone(base_mat * Mat4::<f32>::from(self.foot_l)),
|
||||
make_bone(base_mat * Mat4::<f32>::from(self.foot_r)),
|
||||
];
|
||||
[Vec3::default(), Vec3::default()]
|
||||
[Transform::default(), Transform::default()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,9 @@ impl Skeleton for BirdLargeSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
let neck_mat = chest_mat * Mat4::<f32>::from(self.neck);
|
||||
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
|
||||
@ -91,7 +92,7 @@ impl Skeleton for BirdLargeSkeleton {
|
||||
make_bone(foot_l_mat),
|
||||
make_bone(foot_r_mat),
|
||||
];
|
||||
[Vec3::default(), (chest_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.chest]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,9 @@ impl Skeleton for BirdMediumSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -48,7 +49,7 @@ impl Skeleton for BirdMediumSkeleton {
|
||||
make_bone(base_mat * Mat4::<f32>::from(self.leg_l)),
|
||||
make_bone(base_mat * Mat4::<f32>::from(self.leg_r)),
|
||||
];
|
||||
[Vec3::default(), (torso_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.torso]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,12 +72,14 @@ skeleton_impls!(struct CharacterSkeleton {
|
||||
control_r,
|
||||
:: // Begin non-bone fields
|
||||
holding_lantern: bool,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
});
|
||||
|
||||
impl CharacterSkeleton {
|
||||
pub fn new(holding_lantern: bool) -> Self {
|
||||
pub fn new(holding_lantern: bool, offsets: Option<Transform<f32, f32, f32>>) -> Self {
|
||||
Self {
|
||||
holding_lantern,
|
||||
offsets,
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
@ -96,9 +98,16 @@ impl Skeleton for CharacterSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
dbg!(self.torso);
|
||||
let mut torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
if let Some(offset) = self.offsets {
|
||||
dbg!(offset);
|
||||
torso_mat = base_mat * Mat4::<f32>::from(Transform{position: offset.position, orientation: offset.orientation, scale: Vec3::<f32>::one()})
|
||||
* Mat4::<f32>::from(self.torso);
|
||||
}
|
||||
let chest_mat = torso_mat * Mat4::<f32>::from(self.chest);
|
||||
let head_mat = chest_mat * Mat4::<f32>::from(self.head);
|
||||
let shorts_mat = chest_mat * Mat4::<f32>::from(self.shorts);
|
||||
@ -134,8 +143,9 @@ impl Skeleton for CharacterSkeleton {
|
||||
make_bone(control_mat * hand_l_mat * Mat4::<f32>::from(self.hold)),
|
||||
];
|
||||
[
|
||||
(lantern_mat * Vec4::new(0.0, 0.0, -4.0, 1.0)).xyz(),
|
||||
(chest_mat * Vec4::zero()).xyz(),
|
||||
//(lantern_mat * Vec4::new(0.0, 0.0, -4.0, 1.0)).xyz(),
|
||||
Transform::default(),
|
||||
self.chest
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ impl Animation for MountAnimation {
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Transform<f32, f32, f32>,
|
||||
);
|
||||
type Skeleton = CharacterSkeleton;
|
||||
|
||||
@ -81,10 +81,8 @@ impl Animation for MountAnimation {
|
||||
next.head.orientation = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1)
|
||||
* Quaternion::rotation_x((0.4 + slowa * -0.1 + slow * 0.1 + head_look.y).abs());
|
||||
|
||||
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + mount_offset.z * 14.0);
|
||||
next.chest.orientation =
|
||||
Quaternion::rotation_x(-0.6 + stop * 0.15 + x_tilt * (canceler * 6.0).min(2.0))
|
||||
* Quaternion::rotation_y(tilt * 3.1);
|
||||
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
|
||||
next.chest.orientation = Quaternion::rotation_x(-0.6 + stop * 0.15);
|
||||
|
||||
next.belt.position = Vec3::new(0.0, s_a.belt.0 + stop * 1.2, s_a.belt.1);
|
||||
next.belt.orientation = Quaternion::rotation_x(stop * 0.3);
|
||||
@ -110,19 +108,11 @@ impl Animation for MountAnimation {
|
||||
next.hand_r.orientation =
|
||||
Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI / 2.0);
|
||||
|
||||
next.foot_l.position = Vec3::new(
|
||||
-s_a.foot.0 - 2.0,
|
||||
4.0 + s_a.foot.1,
|
||||
s_a.foot.2 + mount_offset.z * 14.0,
|
||||
);
|
||||
next.foot_l.position = Vec3::new(-s_a.foot.0 - 2.0, 4.0 + s_a.foot.1, s_a.foot.2);
|
||||
next.foot_l.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 0.4 + slow * 0.1)
|
||||
* Quaternion::rotation_y(0.5);
|
||||
|
||||
next.foot_r.position = Vec3::new(
|
||||
s_a.foot.0 + 2.0,
|
||||
4.0 + s_a.foot.1,
|
||||
s_a.foot.2 + mount_offset.z * 14.0,
|
||||
);
|
||||
next.foot_r.position = Vec3::new(s_a.foot.0 + 2.0, 4.0 + s_a.foot.1, s_a.foot.2);
|
||||
next.foot_r.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 0.4 + slowa * 0.1)
|
||||
* Quaternion::rotation_y(-0.5);
|
||||
|
||||
|
@ -42,8 +42,9 @@ impl Skeleton for DragonSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
|
||||
let chest_rear_mat = chest_front_mat * Mat4::<f32>::from(self.chest_rear);
|
||||
let head_lower_mat = chest_front_mat * Mat4::<f32>::from(self.head_lower);
|
||||
@ -69,7 +70,7 @@ impl Skeleton for DragonSkeleton {
|
||||
make_bone(chest_rear_mat * Mat4::<f32>::from(self.foot_bl)),
|
||||
make_bone(chest_rear_mat * Mat4::<f32>::from(self.foot_br)),
|
||||
];
|
||||
[Vec3::default(), (chest_front_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.chest_front]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,9 @@ impl Skeleton for FishMediumSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
|
||||
let chest_back_mat = Mat4::<f32>::from(self.chest_back);
|
||||
let head_mat = Mat4::<f32>::from(self.head);
|
||||
@ -47,7 +48,7 @@ impl Skeleton for FishMediumSkeleton {
|
||||
make_bone(chest_front_mat * Mat4::<f32>::from(self.fin_l)),
|
||||
make_bone(chest_front_mat * Mat4::<f32>::from(self.fin_r)),
|
||||
];
|
||||
[Vec3::default(), Vec3::default()]
|
||||
[Transform::default(), Transform::default()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,9 @@ impl Skeleton for FishSmallSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -39,7 +40,7 @@ impl Skeleton for FishSmallSkeleton {
|
||||
make_bone(chest_mat * Mat4::<f32>::from(self.fin_l)),
|
||||
make_bone(chest_mat * Mat4::<f32>::from(self.fin_r)),
|
||||
];
|
||||
[Vec3::default(), Vec3::default()]
|
||||
[Transform::default(), Transform::default()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,11 @@ impl Skeleton for FixtureSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
buf[0] = make_bone(base_mat);
|
||||
[Vec3::default(), Vec3::default()]
|
||||
[Transform::default(), Transform::default()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,9 @@ impl Skeleton for GolemSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
let upper_torso_mat = torso_mat * Mat4::<f32>::from(self.upper_torso);
|
||||
let lower_torso_mat = upper_torso_mat * Mat4::<f32>::from(self.lower_torso);
|
||||
@ -70,7 +71,7 @@ impl Skeleton for GolemSkeleton {
|
||||
make_bone(leg_l_mat * Mat4::<f32>::from(self.foot_l)),
|
||||
make_bone(leg_r_mat * Mat4::<f32>::from(self.foot_r)),
|
||||
];
|
||||
[Vec3::default(), (torso_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.torso]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,18 +101,20 @@ pub trait Skeleton: Send + Sync + 'static {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2];
|
||||
) -> [Transform<f32, f32, f32>; 2];
|
||||
}
|
||||
|
||||
pub fn compute_matrices<S: Skeleton>(
|
||||
skeleton: &S,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
#[cfg(not(feature = "use-dyn-lib"))]
|
||||
{
|
||||
S::compute_matrices_inner(skeleton, base_mat, buf)
|
||||
S::compute_matrices_inner(skeleton, base_mat, offsets, buf)
|
||||
}
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
{
|
||||
@ -120,7 +122,7 @@ pub fn compute_matrices<S: Skeleton>(
|
||||
let lib = &lock.as_ref().unwrap().lib;
|
||||
|
||||
let compute_fn: libloading::Symbol<
|
||||
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> [Vec3<f32>; 2],
|
||||
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> [Transform<f32, f32, f32>; 2],
|
||||
> = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"Trying to use: {} but had error: {:?}",
|
||||
|
@ -28,15 +28,19 @@ impl Skeleton for ObjectSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);
|
||||
|
||||
*(<&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::<f32>::from(self.bone1) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */
|
||||
];
|
||||
[Vec3::unit_z() * 0.5, Vec3::default()]
|
||||
[
|
||||
Transform::default(),
|
||||
Transform::default(),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,9 @@ impl Skeleton for QuadrupedLowSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
let tail_front = chest_mat * Mat4::<f32>::from(self.tail_front);
|
||||
let head_lower_mat = chest_mat * Mat4::<f32>::from(self.head_lower);
|
||||
@ -66,7 +67,7 @@ impl Skeleton for QuadrupedLowSkeleton {
|
||||
make_bone(chest_mat * Mat4::<f32>::from(self.foot_bl)),
|
||||
make_bone(chest_mat * Mat4::<f32>::from(self.foot_br)),
|
||||
];
|
||||
[Vec3::default(), (chest_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.chest]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,10 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
dbg!(self.torso_back);
|
||||
let torso_front_mat = base_mat * Mat4::<f32>::from(self.torso_front);
|
||||
let torso_back_mat = torso_front_mat * Mat4::<f32>::from(self.torso_back);
|
||||
let neck_mat = torso_front_mat * Mat4::<f32>::from(self.neck);
|
||||
@ -80,7 +82,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
||||
make_bone(leg_bl_mat * Mat4::<f32>::from(self.foot_bl)),
|
||||
make_bone(leg_br_mat * Mat4::<f32>::from(self.foot_br)),
|
||||
];
|
||||
[Vec3::default(), (torso_front_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.torso_front]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,9 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -52,7 +53,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
||||
make_bone(chest_mat * Mat4::<f32>::from(self.leg_br)),
|
||||
make_bone(chest_mat * Mat4::<f32>::from(self.tail)),
|
||||
];
|
||||
[Vec3::default(), (chest_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.chest]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,9 @@ impl Skeleton for ShipSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -38,7 +39,10 @@ impl Skeleton for ShipSkeleton {
|
||||
make_bone(bone0_mat * Mat4::<f32>::from(self.bone2) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */
|
||||
make_bone(bone0_mat * Mat4::<f32>::from(self.bone3) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */
|
||||
];
|
||||
[Vec3::unit_z() * 0.5, (bone0_mat * Vec4::one()).xyz()]
|
||||
[
|
||||
Transform::default(),
|
||||
self.bone0,
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,10 @@ impl Skeleton for TheropodSkeleton {
|
||||
fn compute_matrices_inner(
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> [Vec3<f32>; 2] {
|
||||
) -> [Transform<f32, f32, f32>; 2] {
|
||||
dbg!(self.chest_front);
|
||||
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
|
||||
let neck_mat = chest_front_mat * Mat4::<f32>::from(self.neck);
|
||||
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
|
||||
@ -71,7 +73,7 @@ impl Skeleton for TheropodSkeleton {
|
||||
make_bone(leg_l_mat * Mat4::<f32>::from(self.foot_l)),
|
||||
make_bone(leg_r_mat * Mat4::<f32>::from(self.foot_r)),
|
||||
];
|
||||
[Vec3::default(), (chest_front_mat * Vec4::one()).xyz()]
|
||||
[Transform::default(), self.chest_front]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +449,8 @@ impl FigureMgr {
|
||||
(vek::Rgb::zero(), 0.0, 0.0, true)
|
||||
};
|
||||
if let Some(state) = body.and_then(|body| self.states.get_mut(body, &entity)) {
|
||||
light_anim.offset = vek::Vec3::from(state.lantern_offset[0]);
|
||||
light_anim.offset =
|
||||
(vek::Mat4::from_col_array(anim::vek::Mat4::<f32>::from(state.lantern_offset[0]).into_col_array()) * Vec4::one()).xyz();
|
||||
}
|
||||
if !light_anim.strength.is_normal() {
|
||||
light_anim.strength = 0.0;
|
||||
@ -751,18 +752,16 @@ impl FigureMgr {
|
||||
|
||||
//let mut state_mountee = self.states.get_mut(entity.get(body), &entity);
|
||||
|
||||
let mut mountee_offsets = vek::Vec3::new(0.0, 0.0, 0.0);
|
||||
let mut mountee_offsets = anim::vek::Transform::default(); //vek::Mat4::from_col_array(state.lantern_offset[0].into_col_array()
|
||||
if let Some(Mounting(entity)) = mountings {
|
||||
let mountee_entity = ecs
|
||||
.read_resource::<UidAllocator>()
|
||||
.retrieve_entity_internal((*entity).into());
|
||||
dbg!(mountee_entity);
|
||||
if let Some(entity) = mountee_entity {
|
||||
if let Some(body) = ecs.read_storage::<Body>().get(entity) {
|
||||
let mountee_state = self.states.get_mut(body, &entity);
|
||||
if let Some(meta) = mountee_state {
|
||||
mountee_offsets = vek::Vec3::from(meta.lantern_offset[1]);
|
||||
dbg!(mountee_offsets);
|
||||
mountee_offsets = meta.lantern_offset[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -795,7 +794,11 @@ impl FigureMgr {
|
||||
.character_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, CharacterSkeleton::new(holding_lantern))
|
||||
FigureState::new(
|
||||
renderer,
|
||||
CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -817,7 +820,7 @@ impl FigureMgr {
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::character::StandAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
|
||||
(active_tool_kind, second_tool_kind, hands, time, rel_avg_vel),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
@ -825,7 +828,7 @@ impl FigureMgr {
|
||||
),
|
||||
// Running
|
||||
(true, true, false) => anim::character::RunAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
@ -844,7 +847,7 @@ impl FigureMgr {
|
||||
),
|
||||
// In air
|
||||
(false, _, false) => anim::character::JumpAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
@ -861,7 +864,7 @@ impl FigureMgr {
|
||||
),
|
||||
// Swim
|
||||
(_, _, true) => anim::character::SwimAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
@ -1539,7 +1542,7 @@ impl FigureMgr {
|
||||
// TODO: Update to use the quaternion.
|
||||
ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
mountee_offsets.into(),
|
||||
mountee_offsets,
|
||||
),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
@ -1604,7 +1607,11 @@ impl FigureMgr {
|
||||
.quadruped_small_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, QuadrupedSmallSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
QuadrupedSmallSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -1806,7 +1813,11 @@ impl FigureMgr {
|
||||
.quadruped_medium_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, QuadrupedMediumSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
QuadrupedMediumSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -2133,7 +2144,11 @@ impl FigureMgr {
|
||||
.quadruped_low_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, QuadrupedLowSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
QuadrupedLowSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -2492,7 +2507,11 @@ impl FigureMgr {
|
||||
.bird_medium_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, BirdMediumSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
BirdMediumSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -2602,7 +2621,11 @@ impl FigureMgr {
|
||||
.fish_medium_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, FishMediumSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
FishMediumSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -2691,7 +2714,11 @@ impl FigureMgr {
|
||||
.biped_small_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, BipedSmallSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
BipedSmallSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -3034,10 +3061,9 @@ impl FigureMgr {
|
||||
&slow_jobs,
|
||||
);
|
||||
|
||||
let state =
|
||||
self.states.dragon_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, DragonSkeleton::default())
|
||||
});
|
||||
let state = self.states.dragon_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, DragonSkeleton::default(), Some(mountee_offsets))
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
let rel_avg_vel = state.avg_vel - physics.ground_vel;
|
||||
@ -3132,7 +3158,13 @@ impl FigureMgr {
|
||||
.states
|
||||
.theropod_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| FigureState::new(renderer, TheropodSkeleton::default()));
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(
|
||||
renderer,
|
||||
TheropodSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
let rel_avg_vel = state.avg_vel - physics.ground_vel;
|
||||
@ -3320,7 +3352,11 @@ impl FigureMgr {
|
||||
.bird_large_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, BirdLargeSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
BirdLargeSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
let (character, last_character) = match (character, last_character) {
|
||||
@ -3581,7 +3617,11 @@ impl FigureMgr {
|
||||
.fish_small_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, FishSmallSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
FishSmallSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -3670,7 +3710,11 @@ impl FigureMgr {
|
||||
.biped_large_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, BipedLargeSkeleton::default())
|
||||
FigureState::new(
|
||||
renderer,
|
||||
BipedLargeSkeleton::default(),
|
||||
Some(mountee_offsets),
|
||||
)
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -4266,10 +4310,9 @@ impl FigureMgr {
|
||||
&slow_jobs,
|
||||
);
|
||||
|
||||
let state =
|
||||
self.states.golem_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, GolemSkeleton::default())
|
||||
});
|
||||
let state = self.states.golem_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, GolemSkeleton::default(), Some(mountee_offsets))
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
|
||||
@ -4518,10 +4561,9 @@ impl FigureMgr {
|
||||
&slow_jobs,
|
||||
);
|
||||
|
||||
let state =
|
||||
self.states.object_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, ObjectSkeleton::default())
|
||||
});
|
||||
let state = self.states.object_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, ObjectSkeleton::default(), Some(mountee_offsets))
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
|
||||
@ -4646,11 +4688,9 @@ impl FigureMgr {
|
||||
&slow_jobs,
|
||||
);
|
||||
|
||||
let state = self
|
||||
.states
|
||||
.ship_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| FigureState::new(renderer, ShipSkeleton::default()));
|
||||
let state = self.states.ship_states.entry(entity).or_insert_with(|| {
|
||||
FigureState::new(renderer, ShipSkeleton::default(), Some(mountee_offsets))
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
|
||||
@ -5344,7 +5384,7 @@ impl FigureColLights {
|
||||
pub struct FigureStateMeta {
|
||||
bone_consts: Consts<FigureBoneData>,
|
||||
locals: Consts<FigureLocals>,
|
||||
lantern_offset: [anim::vek::Vec3<f32>; 2],
|
||||
lantern_offset: [anim::vek::Transform<f32, f32, f32>; 2],
|
||||
state_time: f32,
|
||||
last_ori: anim::vek::Quaternion<f32>,
|
||||
lpindex: u8,
|
||||
@ -5382,10 +5422,10 @@ impl<S> DerefMut for FigureState<S> {
|
||||
}
|
||||
|
||||
impl<S: Skeleton> FigureState<S> {
|
||||
pub fn new(renderer: &mut Renderer, skeleton: S) -> Self {
|
||||
pub fn new(renderer: &mut Renderer, skeleton: S, offsets: Option<anim::vek::Transform::<f32, f32, f32>>) -> Self {
|
||||
let mut buf = [Default::default(); anim::MAX_BONE_COUNT];
|
||||
let lantern_offset =
|
||||
anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), &mut buf);
|
||||
anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), None, &mut buf);
|
||||
let bone_consts = figure_bone_data_from_anim(&buf);
|
||||
Self {
|
||||
meta: FigureStateMeta {
|
||||
@ -5515,7 +5555,7 @@ impl<S: Skeleton> FigureState<S> {
|
||||
);
|
||||
renderer.update_consts(&mut self.locals, &[locals]).unwrap();
|
||||
|
||||
let lantern_offset = anim::compute_matrices(&self.skeleton, mat, buf);
|
||||
let lantern_offset = anim::compute_matrices(&self.skeleton, mat, None, buf);
|
||||
|
||||
let new_bone_consts = figure_bone_data_from_anim(buf);
|
||||
|
||||
|
@ -163,10 +163,10 @@ impl Scene {
|
||||
map_bounds,
|
||||
|
||||
figure_model_cache: FigureModelCache::new(),
|
||||
figure_state: FigureState::new(renderer, CharacterSkeleton::default()),
|
||||
figure_state: FigureState::new(renderer, CharacterSkeleton::default(), None),
|
||||
|
||||
backdrop: backdrop.map(|specifier| {
|
||||
let mut state = FigureState::new(renderer, FixtureSkeleton::default());
|
||||
let mut state = FigureState::new(renderer, FixtureSkeleton::default(), None);
|
||||
let mut greedy = FigureModel::make_greedy();
|
||||
let mut opaque_mesh = Mesh::new();
|
||||
let (segment, offset) = load_mesh(specifier, Vec3::new(-55.0, -49.5, -2.0));
|
||||
|
Loading…
Reference in New Issue
Block a user