gliders as items. anim improvements

This commit is contained in:
jshipsey 2020-08-23 21:31:05 -04:00
parent 7525479a4c
commit ecae71c016
16 changed files with 286 additions and 251 deletions

View File

@ -0,0 +1,9 @@
Item(
name: "Swift Glider",
description: "Thank goodness for big pockets",
kind: Glider(
(
kind: Blue,
)
),
)

View File

@ -192,6 +192,7 @@ pub struct Loadout {
pub second_item: Option<ItemConfig>,
pub lantern: Option<Item>,
pub glider: Option<Item>,
#[in_array(get_armor)]
pub shoulder: Option<Item>,

View File

@ -58,12 +58,18 @@ impl Lantern {
pub fn color(&self) -> Rgb<f32> { self.color.map(|c| c as f32 / 255.0) }
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Glider {
pub kind: String,
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum ItemKind {
/// Something wieldable
Tool(tool::Tool),
Lantern(Lantern),
Armor(armor::Armor),
Glider(Glider),
Consumable {
kind: String,
effect: Effect,
@ -317,6 +323,7 @@ impl Item {
(ItemKind::Tool(a), ItemKind::Tool(b)) => a.superficially_eq(b),
// TODO: Differentiate between lantern colors?
(ItemKind::Lantern(_), ItemKind::Lantern(_)) => true,
(ItemKind::Glider(_), ItemKind::Glider(_)) => true,
(ItemKind::Armor(a), ItemKind::Armor(b)) => a.superficially_eq(b),
(ItemKind::Consumable { kind: a, .. }, ItemKind::Consumable { kind: b, .. }) => a == b,
(ItemKind::Throwable { kind: a, .. }, ItemKind::Throwable { kind: b, .. }) => a == b,

View File

@ -18,6 +18,7 @@ pub enum EquipSlot {
Mainhand,
Offhand,
Lantern,
Glider,
}
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
@ -57,6 +58,7 @@ impl EquipSlot {
(Self::Mainhand, ItemKind::Tool(_)) => true,
(Self::Offhand, ItemKind::Tool(_)) => true,
(Self::Lantern, ItemKind::Lantern(_)) => true,
(Self::Glider, ItemKind::Glider(_)) => true,
_ => false,
}
}
@ -103,6 +105,7 @@ fn loadout_replace(
EquipSlot::Armor(ArmorSlot::Feet) => replace(&mut loadout.foot, item),
EquipSlot::Armor(ArmorSlot::Tabard) => replace(&mut loadout.tabard, item),
EquipSlot::Lantern => replace(&mut loadout.lantern, item),
EquipSlot::Glider => replace(&mut loadout.glider, item),
EquipSlot::Mainhand => {
replace(&mut loadout.active_item, item.map(ItemConfig::from)).map(|i| i.item)
},
@ -278,6 +281,7 @@ pub fn equip(slot: usize, inventory: &mut Inventory, loadout: &mut Loadout) {
ArmorKind::Tabard(_) => ArmorSlot::Tabard,
})),
ItemKind::Lantern(_) => Some(EquipSlot::Lantern),
ItemKind::Glider(_) => Some(EquipSlot::Glider),
_ => None,
});

View File

@ -34,6 +34,7 @@ impl LoadoutBuilder {
ring: None,
neck: None,
lantern: None,
glider: None,
head: None,
tabard: None,
})
@ -54,6 +55,9 @@ impl LoadoutBuilder {
.lantern(Some(Item::new_from_asset_expect(
"common.items.armor.starter.lantern",
)))
.glider(Some(assets::load_expect_cloned(
"common.items.armor.starter.glider",
)))
}
/// Default animal configuration
@ -85,6 +89,7 @@ impl LoadoutBuilder {
ring: None,
neck: None,
lantern: None,
glider: None,
head: None,
tabard: None,
})
@ -170,6 +175,11 @@ impl LoadoutBuilder {
self
}
pub fn glider(mut self, item: Option<Item>) -> Self {
self.0.glider = item;
self
}
pub fn head(mut self, item: Option<Item>) -> Self {
self.0.head = item;
self

View File

@ -91,7 +91,7 @@ fn basic_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
pub fn handle_orientation(data: &JoinData, update: &mut StateUpdate, rate: f32) {
// Set direction based on move direction
let ori_dir = if update.character.is_block() {
let ori_dir = if update.character.is_attack() | update.character.is_block() {
data.inputs.look_dir.xy()
} else if !data.inputs.move_dir.is_approx_zero() {
data.inputs.move_dir
@ -176,6 +176,11 @@ pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) {
if data.inputs.climb.is_some()
&& data.physics.on_wall.is_some()
&& !data.physics.on_ground
&& !data
.physics
.in_fluid
.map(|depth| depth > 1.0)
.unwrap_or(false)
//&& update.vel.0.z < 0.0
&& data.body.is_humanoid()
&& update.energy.current() > 100

View File

@ -193,6 +193,7 @@ impl<'a> System<'a> for Sys {
ring: None,
neck: None,
lantern: None,
glider: None,
head: None,
tabard: None,
},
@ -225,6 +226,7 @@ impl<'a> System<'a> for Sys {
lantern: Some(comp::Item::new_from_asset_expect(
"common.items.lantern.black_0",
)),
glider: None,
head: None,
tabard: None,
},
@ -306,6 +308,7 @@ impl<'a> System<'a> for Sys {
ring: None,
neck: None,
lantern: None,
glider: None,
head: None,
tabard: None,
};

View File

@ -52,6 +52,10 @@ impl Animation for AlphaAnimation {
/ (0.05 + 0.95 * ((anim_time as f32 * lab as f32 * 8.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 8.0).sin());
let staff = (((1.0)
/ (0.05 + 0.95 * ((anim_time as f32 * lab as f32 * 10.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 10.0).sin());
let slower = (((1.0)
/ (0.0001 + 0.999 * ((anim_time as f32 * lab as f32 * 4.0).sin()).powf(2.0 as f32)))
.sqrt())
@ -346,10 +350,6 @@ impl Animation for AlphaAnimation {
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
//next.control.position = Vec3::new(-4.0, 3.0 + slower * 2.0, 5.0 + slower *
// 5.0); next.control.orientation = Quaternion::rotation_x()
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(1.4);
next.control.scale = Vec3::one();
next.control.position = Vec3::new(-8.0, 7.0, 1.0);
next.control.orientation = Quaternion::rotation_x(-1.5 + slower * 1.5)
@ -362,44 +362,29 @@ impl Animation for AlphaAnimation {
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Staff(_)) => {
next.head.position = Vec3::new(
0.0,
0.0 + skeleton_attr.head.0, /* + decel * 0.8 */
// Had some clipping issues
skeleton_attr.head.1,
);
next.head.orientation = Quaternion::rotation_z(decel * 0.25)
* Quaternion::rotation_x(0.0 + decel * 0.1)
* Quaternion::rotation_y(decel * -0.1);
next.chest.orientation = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.belt.orientation = Quaternion::rotation_z(decel * -0.1)
* Quaternion::rotation_x(0.0 + decel * -0.1)
* Quaternion::rotation_y(decel * 0.1);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(decel * -0.08)
* Quaternion::rotation_x(0.0 + decel * -0.08)
* Quaternion::rotation_y(decel * 0.08);
next.l_hand.position = Vec3::new(0.0, 1.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.head.orientation =
Quaternion::rotation_x(staff * 0.2) * Quaternion::rotation_z(staff * 0.2);
next.l_hand.position = Vec3::new(11.0, 5.0, -4.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(0.0, 0.0, 10.0);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(12.0, 5.5, 2.0);
next.r_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 6.0, -4.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.position = Vec3::new(12.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.chest.orientation = Quaternion::rotation_z(staff * 0.3);
next.belt.orientation = Quaternion::rotation_z(staff * 0.2);
next.shorts.orientation = Quaternion::rotation_z(staff * 0.4);
next.control.position = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.2)
* Quaternion::rotation_y(slow * 1.5)
* Quaternion::rotation_z(1.4 + slow * 0.5);
next.control.position = Vec3::new(-20.0, 5.0 + staff * 3.0, 1.0);
next.control.orientation = Quaternion::rotation_x(staff * 1.2)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Shield(_)) => {
next.head.position = Vec3::new(
@ -454,38 +439,15 @@ impl Animation for AlphaAnimation {
next.second.orientation = Quaternion::rotation_x(0.0);
},
Some(ToolKind::Debug(_)) => {
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0 + decel * 0.8,
skeleton_attr.head.1,
);
next.head.orientation = Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.position = Vec3::new(0.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.l_hand.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(accel_med * -0.8)
* Quaternion::rotation_y(accel_med * -0.4);
next.l_hand.position = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0);
next.r_hand.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(accel_med * -0.8)
* Quaternion::rotation_y(accel_med * -0.4);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.main.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
next.main.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(PI)
* Quaternion::rotation_y(0.0);
next.main.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);

View File

@ -98,19 +98,17 @@ impl Animation for ChargeAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Staff(_)) => {
next.l_hand.position = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.position = Vec3::new(11.0, 5.0, -4.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(9.0, 1.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.position = Vec3::new(12.0, 5.5, 2.0);
next.r_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(9.2, 8.4, 13.2);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.main.position = Vec3::new(12.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(
-7.0 + quick * 3.5 * (1.0 / (stopa + 0.1)),

View File

@ -66,19 +66,18 @@ impl Animation for ShootAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Staff(_)) => {
next.l_hand.position = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.position = Vec3::new(11.0, 5.0, -4.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.position = Vec3::new(12.0, 5.5, 2.0);
next.r_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(9.2, 8.4, 13.2);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.main.position = Vec3::new(12.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0);
next.control.orientation = Quaternion::rotation_x(exp * 1.3)

View File

@ -120,13 +120,10 @@ impl Animation for WieldAnimation {
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(0.0, 0.0, -3.0);
next.main.orientation = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.orientation = Quaternion::rotation_x(-0.1);
next.control.position = Vec3::new(-7.0, 6.0, 6.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.15)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one();
},
@ -136,10 +133,6 @@ impl Animation for WieldAnimation {
let hand_scale = 1.12;
next.control.position = Vec3::new(0.0, 0.0, 0.0);
//next.control.orientation = Quaternion::rotation_x(slow * 1.0);
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
@ -153,10 +146,6 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0 * PI);
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
@ -171,10 +160,6 @@ impl Animation for WieldAnimation {
next.second.scale = Vec3::one();
next.r_control.position = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.orientation = Quaternion::rotation_x(0.0 * PI)
// * Quaternion::rotation_y(0.0 * PI)
// * Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
if velocity < 0.5 {
@ -234,9 +219,8 @@ impl Animation for WieldAnimation {
next.r_hand.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.57);
next.main.orientation =
Quaternion::rotation_y(-1.57) * Quaternion::rotation_z(1.57);
next.control.position = Vec3::new(6.0, 7.0, 1.0);
next.control.orientation = Quaternion::rotation_x(0.3 + u_slow * 0.15)
@ -245,24 +229,21 @@ impl Animation for WieldAnimation {
next.control.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.position = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.position = Vec3::new(11.0, 5.0, -4.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
Quaternion::rotation_x(1.27) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.position = Vec3::new(12.0, 5.5, 2.0);
next.r_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.2);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(12.0, 8.4, 13.2);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.main.position = Vec3::new(12.0, 8.5, 13.2);
next.main.orientation = Quaternion::rotation_y(3.14);
next.control.position = Vec3::new(-14.0, 1.8, 3.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.2)
* Quaternion::rotation_y(-0.2)
* Quaternion::rotation_z(u_slowalt * 0.1);
next.control.position = Vec3::new(-18.0, 1.0, 6.0);
next.control.orientation = Quaternion::rotation_x(-0.3 + u_slow * 0.1)
* Quaternion::rotation_y(0.15)
* Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one();
},
Some(ToolKind::Shield(_)) => {
@ -271,27 +252,15 @@ impl Animation for WieldAnimation {
let hand_scale = 1.12;
next.control.position = Vec3::new(0.0, 0.0, 0.0);
// next.control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI);
next.l_hand.scale = Vec3::one() * hand_scale;
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.main.orientation = Quaternion::rotation_x(0.0 * PI);
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
@ -300,16 +269,10 @@ impl Animation for WieldAnimation {
next.r_hand.scale = Vec3::one() * hand_scale;
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.second.orientation = Quaternion::rotation_x(0.0 * PI);
next.second.scale = Vec3::one();
next.r_control.position = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.orientation = Quaternion::rotation_x(0.0 * PI)
// * Quaternion::rotation_y(0.0 * PI)
// * Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.position = Vec3::new(2.0, 1.5, 0.0);
@ -344,20 +307,14 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.position = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.orientation = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.position = Vec3::new(5.0, 8.75, -2.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(0.0);
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
next.main.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(PI)
* Quaternion::rotation_y(0.0);
next.main.scale = Vec3::one();
next.control.position = Vec3::new(0.0, 6.0, 6.0);
next.control.orientation =
Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one();
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Farming(_)) => {
if velocity < 0.5 {
@ -370,14 +327,10 @@ impl Animation for WieldAnimation {
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.position = Vec3::new(9.0, 1.0, 11.0);
next.r_hand.orientation = Quaternion::rotation_x(1.57)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.r_hand.orientation = Quaternion::rotation_x(1.57);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.position = Vec3::new(7.5, 7.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.main.orientation = Quaternion::rotation_y(3.14);
next.control.position = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)

View File

@ -17,7 +17,7 @@ impl Animation for AlphaAnimation {
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
(_velocity, global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -35,62 +35,129 @@ impl Animation for AlphaAnimation {
+ 1.0;
let twist = (anim_time as f32 * lab as f32 * 4.0).sin() + 0.5;
let slowersmooth = (anim_time as f32 * lab as f32 * 8.0).sin();
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.2);
next.head.scale = Vec3::one() * 1.02;
let random = ((((2.0
* (((global_time as f32 - anim_time as f32) * 10.0)
- (((global_time as f32 - anim_time as f32) * 10.0).round())))
.abs())
* 10.0)
.round())
/ 10.0;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1,
) / 8.0;
next.upper_torso.orientation =
Quaternion::rotation_z(twist * 1.5) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
let switch = if random > 0.5 { 1.0 } else { -1.0 };
println!("{:?}", random);
if switch > 0.0 {
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.2);
next.head.scale = Vec3::one() * 1.02;
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation =
Quaternion::rotation_z(twist * -1.5) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one();
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1,
) / 8.0;
next.upper_torso.orientation =
Quaternion::rotation_z(twist * 1.1) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation =
Quaternion::rotation_z(twist * -1.1) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(slower * 0.9);
next.shoulder_r.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.02;
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(slower * 0.4);
next.shoulder_r.scale = Vec3::one();
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(slower * 1.5);
next.hand_r.scale = Vec3::one() * 1.02;
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(slower * 0.35);
next.hand_r.scale = Vec3::one() * 1.02;
} else {
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.2);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1,
) / 8.0;
next.upper_torso.orientation =
Quaternion::rotation_z(twist * -1.1) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation =
Quaternion::rotation_z(twist * 1.1) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(slower * 0.4);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(slower * 0.35);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.02;
};
/*
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,

View File

@ -7,7 +7,7 @@ use std::f32::consts::PI;
pub struct RunAnimation;
impl Animation for RunAnimation {
type Dependency = (f32, f64);
type Dependency = (f32, Vec3<f32>, Vec3<f32>, f64);
type Skeleton = GolemSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -17,7 +17,7 @@ impl Animation for RunAnimation {
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
(_velocity, orientation, last_ori, _global_time): Self::Dependency,
anim_time: f64,
_rate: &mut f32,
skeleton_attr: &SkeletonAttr,
@ -56,7 +56,19 @@ impl Animation for RunAnimation {
let short = (anim_time as f32 * lab as f32 * 16.0).sin();
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(short * -0.3) * Quaternion::rotation_x(-0.2);
next.head.scale = Vec3::one() * 1.02;
@ -67,7 +79,7 @@ impl Animation for RunAnimation {
skeleton_attr.upper_torso.1 + short * 1.0,
) / 8.0;
next.upper_torso.orientation =
Quaternion::rotation_z(short * 0.40) * Quaternion::rotation_x(0.0);
Quaternion::rotation_z(tilt * -4.0 + short * 0.40) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.lower_torso.position = Vec3::new(
@ -75,7 +87,7 @@ impl Animation for RunAnimation {
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.orientation = Quaternion::rotation_z(shortalt * 0.60);
next.lower_torso.orientation = Quaternion::rotation_z(tilt * 4.0 + shortalt * 0.2);
next.lower_torso.scale = Vec3::one();
next.shoulder_l.position = Vec3::new(
@ -83,9 +95,9 @@ impl Animation for RunAnimation {
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.orientation = Quaternion::rotation_z(footrotl * 0.5)
next.shoulder_l.orientation = Quaternion::rotation_z(footrotl * 0.07)
* Quaternion::rotation_y(0.15)
* Quaternion::rotation_x(footrotl * -0.95);
* Quaternion::rotation_x(footrotl * -0.25);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.position = Vec3::new(
@ -93,9 +105,9 @@ impl Animation for RunAnimation {
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.orientation = Quaternion::rotation_z(footrotr * -0.5)
next.shoulder_r.orientation = Quaternion::rotation_z(footrotr * -0.07)
* Quaternion::rotation_y(-0.15)
* Quaternion::rotation_x(footrotr * -0.95);
* Quaternion::rotation_x(footrotr * -0.25);
next.shoulder_r.scale = Vec3::one();
next.hand_l.position = Vec3::new(
@ -103,9 +115,9 @@ impl Animation for RunAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -1.1)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.35 + footrotl * -1.0);
next.hand_l.orientation = Quaternion::rotation_x(0.3 + footrotl * -0.06)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(-0.35 + footrotl * -0.1);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.position = Vec3::new(
@ -113,9 +125,9 @@ impl Animation for RunAnimation {
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -1.1)
* Quaternion::rotation_y(-0.5)
* Quaternion::rotation_z(0.35 + footrotr * 1.0);
next.hand_r.orientation = Quaternion::rotation_x(0.3 + footrotr * -0.06)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(0.35 + footrotr * 0.1);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.position = Vec3::new(
@ -123,9 +135,9 @@ impl Animation for RunAnimation {
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_l.orientation = Quaternion::rotation_x(footrotl * 1.5)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(footrotl * -0.5);
next.leg_l.orientation = Quaternion::rotation_x(footrotl * 0.3)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * -0.2);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.position = Vec3::new(
@ -134,29 +146,31 @@ impl Animation for RunAnimation {
skeleton_attr.leg.2,
) * 1.02;
next.leg_r.orientation = Quaternion::rotation_x(footrotr * 1.5)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(footrotr * 0.5);
next.leg_r.orientation = Quaternion::rotation_x(footrotr * 0.3)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * 0.2);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothoril * 13.0,
skeleton_attr.foot.2 - 3.0 + (footvertl * 15.0).max(-2.0),
skeleton_attr.foot.1 + foothoril * 2.0,
skeleton_attr.foot.2 + (footvertl * 3.0).max(0.0),
);
next.foot_l.orientation = Quaternion::rotation_x(footrotl * 1.8);
next.foot_l.orientation =
Quaternion::rotation_x(footrotl * 0.2) * Quaternion::rotation_y(-0.08);
next.foot_l.scale = Vec3::one() * 0.98;
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothorir * 13.0,
skeleton_attr.foot.2 - 3.0 + (footvertr * 15.0).max(-2.0),
skeleton_attr.foot.1 + foothorir * 2.0,
skeleton_attr.foot.2 + (footvertr * 3.0).max(0.0),
);
next.foot_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(footrotr * 1.8);
next.foot_r.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(footrotr * 0.2)
* Quaternion::rotation_y(0.08);
next.foot_r.scale = Vec3::one() * 0.98;
next.torso.position = Vec3::new(0.0, 0.0, short * 0.15);
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one();
next

View File

@ -4,7 +4,7 @@ use common::{
comp::item::{
armor::{Armor, ArmorKind},
tool::{Tool, ToolKind},
Item, ItemKind, Lantern, Throwable, Utility,
Glider, Item, ItemKind, Lantern, Throwable, Utility,
},
figure::Segment,
};
@ -21,6 +21,7 @@ use vek::*;
pub enum ItemKey {
Tool(ToolKind),
Lantern(String),
Glider(String),
Armor(ArmorKind),
Utility(Utility),
Consumable(String),
@ -33,6 +34,7 @@ impl From<&Item> for ItemKey {
match &item.kind() {
ItemKind::Tool(Tool { kind, .. }) => ItemKey::Tool(kind.clone()),
ItemKind::Lantern(Lantern { kind, .. }) => ItemKey::Lantern(kind.clone()),
ItemKind::Glider(Glider { kind, .. }) => ItemKey::Glider(kind.clone()),
ItemKind::Armor(Armor { kind, .. }) => ItemKey::Armor(kind.clone()),
ItemKind::Utility { kind, .. } => ItemKey::Utility(*kind),
ItemKind::Consumable { kind, .. } => ItemKey::Consumable(kind.clone()),

View File

@ -66,6 +66,7 @@ impl SlotKey<Loadout, ItemImgs> for EquipSlot {
EquipSlot::Mainhand => source.active_item.as_ref().map(|i| &i.item),
EquipSlot::Offhand => source.second_item.as_ref().map(|i| &i.item),
EquipSlot::Lantern => source.lantern.as_ref(),
EquipSlot::Glider => source.glider.as_ref(),
};
item.map(|i| (i.into(), None))

View File

@ -1537,7 +1537,7 @@ impl FigureMgr {
),
};
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt);
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt_lerp);
state.update(
renderer,
pos.0,
@ -1619,7 +1619,7 @@ impl FigureMgr {
),
};
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt);
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt_lerp);
state.update(
renderer,
pos.0,
@ -1702,7 +1702,7 @@ impl FigureMgr {
),
};
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt);
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt_lerp);
state.update(
renderer,
pos.0,
@ -1788,7 +1788,7 @@ impl FigureMgr {
),
};
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt);
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt_lerp);
state.update(
renderer,
pos.0,
@ -1874,7 +1874,7 @@ impl FigureMgr {
),
};
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt);
state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt_lerp);
state.update(
renderer,
pos.0,
@ -2039,7 +2039,7 @@ impl FigureMgr {
// Running
(true, true, false) => anim::golem::RunAnimation::update_skeleton(
&GolemSkeleton::default(),
(vel.0.magnitude(), time),
(vel.0.magnitude(), ori, state.last_ori, time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,