mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Glider trails
This commit is contained in:
parent
eacd43be16
commit
48c97cd829
@ -113,8 +113,8 @@ impl Skeleton for ArthropodSkeleton {
|
|||||||
orientation: mount_orientation,
|
orientation: mount_orientation,
|
||||||
scale: Vec3::one(),
|
scale: Vec3::one(),
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,8 @@ impl Skeleton for BipedLargeSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ impl Skeleton for BipedSmallSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,8 @@ impl Skeleton for BirdLargeSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ impl Skeleton for BirdMediumSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ impl Animation for GlidingAnimation {
|
|||||||
) -> Self::Skeleton {
|
) -> Self::Skeleton {
|
||||||
let mut next = (*skeleton).clone();
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
next.glider_trails = true;
|
||||||
|
|
||||||
let speednorm = velocity.magnitude().min(50.0) / 50.0;
|
let speednorm = velocity.magnitude().min(50.0) / 50.0;
|
||||||
let slow = (acc_vel * 0.5).sin();
|
let slow = (acc_vel * 0.5).sin();
|
||||||
|
|
||||||
|
@ -80,6 +80,8 @@ skeleton_impls!(struct CharacterSkeleton {
|
|||||||
holding_lantern: bool,
|
holding_lantern: bool,
|
||||||
main_weapon_trail: bool,
|
main_weapon_trail: bool,
|
||||||
off_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 {
|
impl CharacterSkeleton {
|
||||||
@ -129,6 +131,7 @@ impl Skeleton for CharacterSkeleton {
|
|||||||
} * Mat4::<f32>::from(self.lantern);
|
} * Mat4::<f32>::from(self.lantern);
|
||||||
let main_mat = control_l_mat * Mat4::<f32>::from(self.main);
|
let main_mat = control_l_mat * Mat4::<f32>::from(self.main);
|
||||||
let second_mat = control_r_mat * Mat4::<f32>::from(self.second);
|
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()) = [
|
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||||
make_bone(head_mat),
|
make_bone(head_mat),
|
||||||
@ -142,7 +145,7 @@ impl Skeleton for CharacterSkeleton {
|
|||||||
make_bone(torso_mat * Mat4::<f32>::from(self.foot_r)),
|
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_l)),
|
||||||
make_bone(chest_mat * Mat4::<f32>::from(self.shoulder_r)),
|
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(main_mat),
|
||||||
make_bone(second_mat),
|
make_bone(second_mat),
|
||||||
make_bone(lantern_mat),
|
make_bone(lantern_mat),
|
||||||
@ -163,6 +166,24 @@ impl Skeleton for CharacterSkeleton {
|
|||||||
Vec4::new(0.0, 0.0, lengths.1, 1.0),
|
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 {
|
Offsets {
|
||||||
lantern: Some((lantern_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz()),
|
lantern: Some((lantern_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz()),
|
||||||
// TODO: see quadruped_medium for how to animate this
|
// TODO: see quadruped_medium for how to animate this
|
||||||
@ -173,10 +194,17 @@ impl Skeleton for CharacterSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: self.main_weapon_trail.then_some((main_mat, weapon_offsets)),
|
primary_trail_mat: if weapon_trails {
|
||||||
off_weapon_trail_mat: self
|
self.main_weapon_trail.then_some((main_mat, weapon_offsets))
|
||||||
.off_weapon_trail
|
} else {
|
||||||
.then_some((second_mat, weapon_offsets)),
|
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))
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,8 @@ impl Skeleton for DragonSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,8 @@ impl Skeleton for FishMediumSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ impl Skeleton for FishSmallSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ impl Skeleton for FixtureSkeleton {
|
|||||||
Offsets {
|
Offsets {
|
||||||
lantern: None,
|
lantern: None,
|
||||||
mount_bone: Transform::default(),
|
mount_bone: Transform::default(),
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,8 @@ impl Skeleton for GolemSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@ impl Skeleton for ItemDropSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,8 +104,8 @@ pub fn init() { lazy_static::initialize(&LIB); }
|
|||||||
pub struct Offsets {
|
pub struct Offsets {
|
||||||
pub lantern: Option<Vec3<f32>>,
|
pub lantern: Option<Vec3<f32>>,
|
||||||
pub mount_bone: Transform<f32, f32, f32>,
|
pub mount_bone: Transform<f32, f32, f32>,
|
||||||
pub main_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 off_weapon_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 {
|
pub trait Skeleton: Send + Sync + 'static {
|
||||||
|
@ -49,8 +49,8 @@ impl Skeleton for ObjectSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,8 +97,8 @@ impl Skeleton for QuadrupedLowSkeleton {
|
|||||||
orientation: mount_orientation,
|
orientation: mount_orientation,
|
||||||
scale: Vec3::one(),
|
scale: Vec3::one(),
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
|||||||
orientation: mount_orientation,
|
orientation: mount_orientation,
|
||||||
scale: Vec3::one(),
|
scale: Vec3::one(),
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,8 +74,8 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
|||||||
orientation: mount_orientation,
|
orientation: mount_orientation,
|
||||||
scale: Vec3::one(),
|
scale: Vec3::one(),
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ impl Skeleton for ShipSkeleton {
|
|||||||
),
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,8 +84,8 @@ impl Skeleton for TheropodSkeleton {
|
|||||||
.into(),
|
.into(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6474,7 +6474,7 @@ impl<S: Skeleton> FigureState<S> {
|
|||||||
if let (Some(trail_mgr), Some(entity)) = (trail_mgr, entity) {
|
if let (Some(trail_mgr), Some(entity)) = (trail_mgr, entity) {
|
||||||
handle_weapon_trails(
|
handle_weapon_trails(
|
||||||
trail_mgr,
|
trail_mgr,
|
||||||
offsets.main_weapon_trail_mat,
|
offsets.primary_trail_mat,
|
||||||
&mut self.main_abs_trail_points,
|
&mut self.main_abs_trail_points,
|
||||||
*entity,
|
*entity,
|
||||||
true,
|
true,
|
||||||
@ -6483,7 +6483,7 @@ impl<S: Skeleton> FigureState<S> {
|
|||||||
);
|
);
|
||||||
handle_weapon_trails(
|
handle_weapon_trails(
|
||||||
trail_mgr,
|
trail_mgr,
|
||||||
offsets.off_weapon_trail_mat,
|
offsets.secondary_trail_mat,
|
||||||
&mut self.off_abs_trail_points,
|
&mut self.off_abs_trail_points,
|
||||||
*entity,
|
*entity,
|
||||||
false,
|
false,
|
||||||
|
@ -49,8 +49,8 @@ impl anim::Skeleton for VolumeKey {
|
|||||||
anim::Offsets {
|
anim::Offsets {
|
||||||
lantern: None,
|
lantern: None,
|
||||||
mount_bone: anim::vek::Transform::default(),
|
mount_bone: anim::vek::Transform::default(),
|
||||||
main_weapon_trail_mat: None,
|
primary_trail_mat: None,
|
||||||
off_weapon_trail_mat: None,
|
secondary_trail_mat: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user