Glider trails

This commit is contained in:
Sam 2022-02-21 11:23:36 -05:00
parent eacd43be16
commit 48c97cd829
22 changed files with 75 additions and 45 deletions

View File

@ -113,8 +113,8 @@ impl Skeleton for ArthropodSkeleton {
orientation: mount_orientation,
scale: Vec3::one(),
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -137,8 +137,8 @@ impl Skeleton for BipedLargeSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -83,8 +83,8 @@ impl Skeleton for BipedSmallSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -106,8 +106,8 @@ impl Skeleton for BirdLargeSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -60,8 +60,8 @@ impl Skeleton for BirdMediumSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -26,6 +26,8 @@ impl Animation for GlidingAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.glider_trails = true;
let speednorm = velocity.magnitude().min(50.0) / 50.0;
let slow = (acc_vel * 0.5).sin();

View File

@ -80,6 +80,8 @@ skeleton_impls!(struct CharacterSkeleton {
holding_lantern: bool,
main_weapon_trail: bool,
off_weapon_trail: bool,
// Cannot exist at same time as weapon trails. Since gliding and attacking are mutually exclusive, should never be a concern.
glider_trails: bool,
});
impl CharacterSkeleton {
@ -129,6 +131,7 @@ impl Skeleton for CharacterSkeleton {
} * Mat4::<f32>::from(self.lantern);
let main_mat = control_l_mat * Mat4::<f32>::from(self.main);
let second_mat = control_r_mat * Mat4::<f32>::from(self.second);
let glider_mat = chest_mat * Mat4::<f32>::from(self.glider);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_mat),
@ -142,7 +145,7 @@ impl Skeleton for CharacterSkeleton {
make_bone(torso_mat * Mat4::<f32>::from(self.foot_r)),
make_bone(chest_mat * Mat4::<f32>::from(self.shoulder_l)),
make_bone(chest_mat * Mat4::<f32>::from(self.shoulder_r)),
make_bone(chest_mat * Mat4::<f32>::from(self.glider)),
make_bone(glider_mat),
make_bone(main_mat),
make_bone(second_mat),
make_bone(lantern_mat),
@ -163,6 +166,24 @@ impl Skeleton for CharacterSkeleton {
Vec4::new(0.0, 0.0, lengths.1, 1.0),
)
};
// Offsets
const GLIDER_VERT: f32 = 5.0;
const GLIDER_HORIZ: f32 = 15.0;
// Trail width
const GLIDER_WIDTH: f32 = 1.0;
let glider_offsets_0 = |_| {
(
Vec4::new(GLIDER_HORIZ, 0.0, GLIDER_VERT, 1.0),
Vec4::new(GLIDER_HORIZ + GLIDER_WIDTH, 0.0, GLIDER_VERT, 1.0),
)
};
let glider_offsets_1 = |_| {
(
Vec4::new(-GLIDER_HORIZ, 0.0, GLIDER_VERT, 1.0),
Vec4::new(-(GLIDER_HORIZ + GLIDER_WIDTH), 0.0, GLIDER_VERT, 1.0),
)
};
let weapon_trails = self.main_weapon_trail || self.off_weapon_trail;
Offsets {
lantern: Some((lantern_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz()),
// TODO: see quadruped_medium for how to animate this
@ -173,10 +194,17 @@ impl Skeleton for CharacterSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: self.main_weapon_trail.then_some((main_mat, weapon_offsets)),
off_weapon_trail_mat: self
.off_weapon_trail
.then_some((second_mat, weapon_offsets)),
primary_trail_mat: if weapon_trails {
self.main_weapon_trail.then_some((main_mat, weapon_offsets))
} else {
self.glider_trails.then_some((glider_mat, glider_offsets_0))
},
secondary_trail_mat: if weapon_trails {
self.off_weapon_trail
.then_some((second_mat, weapon_offsets))
} else {
self.glider_trails.then_some((glider_mat, glider_offsets_1))
},
}
}
}

View File

@ -81,8 +81,8 @@ impl Skeleton for DragonSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -60,8 +60,8 @@ impl Skeleton for FishMediumSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -51,8 +51,8 @@ impl Skeleton for FishSmallSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -37,8 +37,8 @@ impl Skeleton for FixtureSkeleton {
Offsets {
lantern: None,
mount_bone: Transform::default(),
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -83,8 +83,8 @@ impl Skeleton for GolemSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -43,8 +43,8 @@ impl Skeleton for ItemDropSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -104,8 +104,8 @@ pub fn init() { lazy_static::initialize(&LIB); }
pub struct Offsets {
pub lantern: Option<Vec3<f32>>,
pub mount_bone: Transform<f32, f32, f32>,
pub main_weapon_trail_mat: Option<(Mat4<f32>, fn(Option<ToolKind>) -> (Vec4<f32>, Vec4<f32>))>,
pub off_weapon_trail_mat: Option<(Mat4<f32>, fn(Option<ToolKind>) -> (Vec4<f32>, Vec4<f32>))>,
pub primary_trail_mat: Option<(Mat4<f32>, fn(Option<ToolKind>) -> (Vec4<f32>, Vec4<f32>))>,
pub secondary_trail_mat: Option<(Mat4<f32>, fn(Option<ToolKind>) -> (Vec4<f32>, Vec4<f32>))>,
}
pub trait Skeleton: Send + Sync + 'static {

View File

@ -49,8 +49,8 @@ impl Skeleton for ObjectSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -97,8 +97,8 @@ impl Skeleton for QuadrupedLowSkeleton {
orientation: mount_orientation,
scale: Vec3::one(),
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -109,8 +109,8 @@ impl Skeleton for QuadrupedMediumSkeleton {
orientation: mount_orientation,
scale: Vec3::one(),
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -74,8 +74,8 @@ impl Skeleton for QuadrupedSmallSkeleton {
orientation: mount_orientation,
scale: Vec3::one(),
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -53,8 +53,8 @@ impl Skeleton for ShipSkeleton {
),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -84,8 +84,8 @@ impl Skeleton for TheropodSkeleton {
.into(),
..Default::default()
},
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}
}

View File

@ -6474,7 +6474,7 @@ impl<S: Skeleton> FigureState<S> {
if let (Some(trail_mgr), Some(entity)) = (trail_mgr, entity) {
handle_weapon_trails(
trail_mgr,
offsets.main_weapon_trail_mat,
offsets.primary_trail_mat,
&mut self.main_abs_trail_points,
*entity,
true,
@ -6483,7 +6483,7 @@ impl<S: Skeleton> FigureState<S> {
);
handle_weapon_trails(
trail_mgr,
offsets.off_weapon_trail_mat,
offsets.secondary_trail_mat,
&mut self.off_abs_trail_points,
*entity,
false,

View File

@ -49,8 +49,8 @@ impl anim::Skeleton for VolumeKey {
anim::Offsets {
lantern: None,
mount_bone: anim::vek::Transform::default(),
main_weapon_trail_mat: None,
off_weapon_trail_mat: None,
primary_trail_mat: None,
secondary_trail_mat: None,
}
}