Ensured that Client is Send

Former-commit-id: abadfc7d1d86110ed442cdb5a2e639c163c96e04
This commit is contained in:
Joshua Barretto 2019-04-12 23:19:19 +01:00
parent a444826f0b
commit 51f7d85508
2 changed files with 12 additions and 9 deletions

View File

@ -24,27 +24,28 @@ impl Animation for RunAnimation {
let wave_slow = (time as f32 * 6.0 + PI).sin(); let wave_slow = (time as f32 * 6.0 + PI).sin();
let wave_dip = (wave_slow.abs() - 0.5).abs(); let wave_dip = (wave_slow.abs() - 0.5).abs();
skeleton.head.offset = Vec3::unit_z() * 13.0; skeleton.head.offset = Vec3::unit_z() * 13.0 / 11.0;
skeleton.head.ori = Quaternion::rotation_z(wave * 0.3); skeleton.head.ori = Quaternion::rotation_z(wave * 0.3);
skeleton.chest.offset = Vec3::unit_z() * 9.0; skeleton.chest.offset = Vec3::unit_z() * 9.0 / 11.0;
skeleton.chest.ori = Quaternion::rotation_z(wave * 0.3); skeleton.chest.ori = Quaternion::rotation_z(wave * 0.3);
skeleton.belt.offset = Vec3::unit_z() * 7.0; skeleton.belt.offset = Vec3::unit_z() * 7.0 / 11.0;
skeleton.belt.ori = Quaternion::rotation_z(wave * 0.2); skeleton.belt.ori = Quaternion::rotation_z(wave * 0.2);
skeleton.shorts.offset = Vec3::unit_z() * 4.0; skeleton.shorts.offset = Vec3::unit_z() * 4.0 / 11.0;
skeleton.shorts.ori = Quaternion::rotation_z(wave * 0.1); skeleton.shorts.ori = Quaternion::rotation_z(wave * 0.1);
skeleton.l_hand.offset = Vec3::new(-6.0 - wave_dip * 6.0, wave * 5.0, 11.0 - wave_dip * 6.0); skeleton.l_hand.offset = Vec3::new(-6.0 - wave_dip * 6.0, wave * 5.0, 11.0 - wave_dip * 6.0) / 11.0;
skeleton.r_hand.offset = Vec3::new(6.0 + wave_dip * 6.0, -wave * 5.0, 11.0 - wave_dip * 6.0); skeleton.r_hand.offset = Vec3::new(6.0 + wave_dip * 6.0, -wave * 5.0, 11.0 - wave_dip * 6.0) / 11.0;
skeleton.l_foot.offset = Vec3::new(-3.5, 1.0 - wave * 8.0, 3.5 - wave_dip * 4.0); skeleton.l_foot.offset = Vec3::new(-3.5, 1.0 - wave * 8.0, 3.5 - wave_dip * 4.0) / 11.0;
skeleton.l_foot.ori = Quaternion::rotation_x(-wave + 1.0); skeleton.l_foot.ori = Quaternion::rotation_x(-wave + 1.0);
skeleton.r_foot.offset = Vec3::new(3.5, 1.0 + wave * 8.0, 3.5 - wave_dip * 4.0); skeleton.r_foot.offset = Vec3::new(3.5, 1.0 + wave * 8.0, 3.5 - wave_dip * 4.0) / 11.0;
skeleton.r_foot.ori = Quaternion::rotation_x(wave + 1.0); skeleton.r_foot.ori = Quaternion::rotation_x(wave + 1.0);
skeleton.back.offset = Vec3::new(-9.0, 5.0, 18.0); skeleton.back.offset = Vec3::new(-9.0, 5.0, 18.0);
skeleton.back.ori = Quaternion::rotation_y(2.5); skeleton.back.ori = Quaternion::rotation_y(2.5);
skeleton.back.scale = Vec3::one();
} }
} }

View File

@ -10,6 +10,7 @@ use crate::render::FigureBoneData;
pub struct Bone { pub struct Bone {
pub offset: Vec3<f32>, pub offset: Vec3<f32>,
pub ori: Quaternion<f32>, pub ori: Quaternion<f32>,
pub scale: Vec3<f32>,
} }
impl Bone { impl Bone {
@ -17,11 +18,12 @@ impl Bone {
Self { Self {
offset: Vec3::zero(), offset: Vec3::zero(),
ori: Quaternion::identity(), ori: Quaternion::identity(),
scale: Vec3::broadcast(1.0 / 11.0),
} }
} }
pub fn compute_base_matrix(&self) -> Mat4<f32> { pub fn compute_base_matrix(&self) -> Mat4<f32> {
Mat4::<f32>::translation_3d(self.offset) * Mat4::from(self.ori) Mat4::<f32>::translation_3d(self.offset) * Mat4::scaling_3d(self.scale) * Mat4::from(self.ori)
} }
} }