orientation animation

This commit is contained in:
Justin Shipsey 2020-05-27 06:41:55 +00:00
parent 6789a95557
commit ea07d744a7
37 changed files with 736 additions and 344 deletions

View File

@ -11,11 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added context-sensitive crosshair - Added context-sensitive crosshair
- Announce alias changes to all clients. - Announce alias changes to all clients.
- Dance animation
### Changed ### Changed
- Improved camera aiming - Improved camera aiming
- Made civsim, sites, etc. deterministic from the same seed. - Made civsim, sites, etc. deterministic from the same seed.
- Improved animations by adding orientation variation
### Removed ### Removed

View File

@ -1,47 +1,47 @@
(( ((
default: ( default: (
vox_spec: ("armor.foot.foot_none", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.foot_none", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
map: { map: {
Dark: ( Dark: (
vox_spec: ("armor.foot.dark-0", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.dark-0", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
Assassin: ( Assassin: (
vox_spec: ("armor.foot.assa", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.assa", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
Jester: ( Jester: (
vox_spec: ("armor.foot.dark_jester-elf_shoe", (-2.5, -3.0, -9.0)), vox_spec: ("armor.foot.dark_jester-elf_shoe", (-2.5, -3.0, -2.0)),
color: None color: None
), ),
Plate0: ( Plate0: (
vox_spec: ("armor.foot.plate-0", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.plate-0", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
Leather0: ( Leather0: (
vox_spec: ("armor.foot.leather-0", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.leather-0", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
ClothPurple0:( ClothPurple0:(
vox_spec: ("armor.foot.cloth_purple-0", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.cloth_purple-0", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
ClothBlue0:( ClothBlue0:(
vox_spec: ("armor.foot.cloth_blue-0", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.cloth_blue-0", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
ClothGreen0:( ClothGreen0:(
vox_spec: ("armor.foot.cloth_green-0", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.cloth_green-0", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
Sandal0:( Sandal0:(
vox_spec: ("armor.foot.cloth_sandals", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.cloth_sandals", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
Cultist: ( Cultist: (
vox_spec: ("armor.foot.cultist", (-2.5, -3.5, -9.0)), vox_spec: ("armor.foot.cultist", (-2.5, -3.5, -2.0)),
color: None color: None
), ),
Steel0:( Steel0:(

View File

@ -1,122 +1,122 @@
(( ((
default: ( default: (
left: ( left: (
vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.hand_right_none", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
map: { map: {
Assassin: ( Assassin: (
left: ( left: (
vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.assa_right", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
Cloth: ( Cloth: (
left: ( left: (
vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_basic_right", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
Plate0: ( Plate0: (
left: ( left: (
vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.plate_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
Leather0: ( Leather0: (
left: ( left: (
vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.leather_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
ClothPurple0: ( ClothPurple0: (
left: ( left: (
vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_purple_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
ClothBlue0: ( ClothBlue0: (
left: ( left: (
vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_blue_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
ClothGreen0: ( ClothGreen0: (
left: ( left: (
vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.cloth_green_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
CultistPurple: ( CultistPurple: (
left: ( left: (
vox_spec: ("armor.hand.cultist_right", (-3.0, -1.5, -7.0)), vox_spec: ("armor.hand.cultist_right", (-3.0, -1.5, -2.5)),
color: Some((30, 0, 64)) color: Some((30, 0, 64))
), ),
right: ( right: (
vox_spec: ("armor.hand.cultist_right", (-2.0, -1.5, -7.0)), vox_spec: ("armor.hand.cultist_right", (-2.0, -1.5, -2.5)),
color: Some((30, 0, 64)) color: Some((30, 0, 64))
) )
), ),
CultistBlue: ( CultistBlue: (
left: ( left: (
vox_spec: ("armor.hand.cultist_right", (-3.0, -1.5, -7.0)), vox_spec: ("armor.hand.cultist_right", (-3.0, -1.5, -2.5)),
color: Some((57, 81, 132)) color: Some((57, 81, 132))
), ),
right: ( right: (
vox_spec: ("armor.hand.cultist_right", (-2.0, -1.5, -7.0)), vox_spec: ("armor.hand.cultist_right", (-2.0, -1.5, -2.5)),
color: Some((57, 81, 132)) color: Some((57, 81, 132))
) )
), ),
Steel0: ( Steel0: (
left: ( left: (
vox_spec: ("armor.hand.steel_left-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.steel_left-0", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.steel_right-0", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.steel_right-0", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),
Leather2: ( Leather2: (
left: ( left: (
vox_spec: ("armor.hand.leather_left-2", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.leather_left-2", (-1.5, -1.5, -2.5)),
color: None color: None
), ),
right: ( right: (
vox_spec: ("armor.hand.leather_right-2", (-1.5, -1.5, -7.0)), vox_spec: ("armor.hand.leather_right-2", (-1.5, -1.5, -2.5)),
color: None color: None
) )
), ),

View File

@ -398,6 +398,21 @@ impl Client {
} }
} }
pub fn toggle_dance(&mut self) {
let is_dancing = self
.state
.ecs()
.read_storage::<comp::CharacterState>()
.get(self.entity)
.map(|cs| matches!(cs, comp::CharacterState::Dance));
match is_dancing {
Some(true) => self.control_action(ControlAction::Stand),
Some(false) => self.control_action(ControlAction::Dance),
None => warn!("Can't toggle dance, client entity doesn't have a `CharacterState`"),
}
}
fn control_action(&mut self, control_action: ControlAction) { fn control_action(&mut self, control_action: ControlAction) {
if let Some(controller) = self if let Some(controller) = self
.state .state

View File

@ -39,6 +39,7 @@ pub enum CharacterState {
Idle, Idle,
Climb, Climb,
Sit, Sit,
Dance,
Glide, Glide,
/// A basic blocking state /// A basic blocking state
BasicBlock, BasicBlock,

View File

@ -31,6 +31,7 @@ pub enum ControlAction {
Wield, Wield,
Unwield, Unwield,
Sit, Sit,
Dance,
Stand, Stand,
} }

View File

@ -0,0 +1,42 @@
use super::utils::*;
use crate::{
comp::{CharacterState, StateUpdate},
sys::character_behavior::{CharacterBehavior, JoinData},
};
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct Data;
impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_primary_wield(data, &mut update);
// Try to Fall/Stand up/Move
if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 {
update.character = CharacterState::Idle;
}
update
}
fn wield(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_wield(data, &mut update);
update
}
fn sit(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_sit(data, &mut update);
update
}
fn stand(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
// Try to Fall/Stand up/Move
update.character = CharacterState::Idle;
update
}
}

View File

@ -32,6 +32,12 @@ impl CharacterBehavior for Data {
update update
} }
fn dance(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_dance(data, &mut update);
update
}
fn swap_loadout(&self, data: &JoinData) -> StateUpdate { fn swap_loadout(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
attempt_swap_loadout(data, &mut update); attempt_swap_loadout(data, &mut update);

View File

@ -3,6 +3,7 @@ pub mod basic_melee;
pub mod basic_ranged; pub mod basic_ranged;
pub mod boost; pub mod boost;
pub mod climb; pub mod climb;
pub mod dance;
pub mod dash_melee; pub mod dash_melee;
pub mod equipping; pub mod equipping;
pub mod glide; pub mod glide;

View File

@ -27,6 +27,12 @@ impl CharacterBehavior for Data {
update update
} }
fn dance(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_dance(data, &mut update);
update
}
fn stand(&self, data: &JoinData) -> StateUpdate { fn stand(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
// Try to Fall/Stand up/Move // Try to Fall/Stand up/Move

View File

@ -121,6 +121,12 @@ pub fn attempt_sit(data: &JoinData, update: &mut StateUpdate) {
} }
} }
pub fn attempt_dance(data: &JoinData, update: &mut StateUpdate) {
if data.physics.on_ground && data.body.is_humanoid() {
update.character = CharacterState::Dance;
}
}
/// Checks that player can `Climb` and updates `CharacterState` if so /// Checks that player can `Climb` and updates `CharacterState` if so
pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) {
if data.inputs.climb.is_some() if data.inputs.climb.is_some()

View File

@ -28,6 +28,12 @@ impl CharacterBehavior for Data {
update update
} }
fn dance(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data);
attempt_dance(data, &mut update);
update
}
fn unwield(&self, data: &JoinData) -> StateUpdate { fn unwield(&self, data: &JoinData) -> StateUpdate {
let mut update = StateUpdate::from(data); let mut update = StateUpdate::from(data);
update.character = CharacterState::Idle; update.character = CharacterState::Idle;

View File

@ -20,6 +20,7 @@ pub trait CharacterBehavior {
fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn wield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn unwield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn unwield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn dance(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) }
fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate { fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate {
match event { match event {
@ -27,6 +28,7 @@ pub trait CharacterBehavior {
ControlAction::Wield => self.wield(data), ControlAction::Wield => self.wield(data),
ControlAction::Unwield => self.unwield(data), ControlAction::Unwield => self.unwield(data),
ControlAction::Sit => self.sit(data), ControlAction::Sit => self.sit(data),
ControlAction::Dance => self.dance(data),
ControlAction::Stand => self.stand(data), ControlAction::Stand => self.stand(data),
} }
} }
@ -196,6 +198,9 @@ impl<'a> System<'a> for Sys {
CharacterState::Sit => { CharacterState::Sit => {
states::sit::Data::handle_event(&states::sit::Data, &j, action) states::sit::Data::handle_event(&states::sit::Data, &j, action)
}, },
CharacterState::Dance => {
states::dance::Data::handle_event(&states::dance::Data, &j, action)
},
CharacterState::BasicBlock => { CharacterState::BasicBlock => {
states::basic_block::Data.handle_event(&j, action) states::basic_block::Data.handle_event(&j, action)
}, },
@ -220,6 +225,7 @@ impl<'a> System<'a> for Sys {
CharacterState::Climb => states::climb::Data.behavior(&j), CharacterState::Climb => states::climb::Data.behavior(&j),
CharacterState::Glide => states::glide::Data.behavior(&j), CharacterState::Glide => states::glide::Data.behavior(&j),
CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j), CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j),
CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, &j),
CharacterState::BasicBlock => states::basic_block::Data.behavior(&j), CharacterState::BasicBlock => states::basic_block::Data.behavior(&j),
CharacterState::Roll(data) => data.behavior(&j), CharacterState::Roll(data) => data.behavior(&j),
CharacterState::Wielding => states::wielding::Data.behavior(&j), CharacterState::Wielding => states::wielding::Data.behavior(&j),

View File

@ -42,7 +42,7 @@ impl Default for ServerSettings {
"xMAC94x", "xMAC94x",
"Timo", "Timo",
"Songtronix", "Songtronix",
"Slipped", "slipped",
"Sharp", "Sharp",
"Acrimon", "Acrimon",
"imbris", "imbris",

View File

@ -72,10 +72,10 @@ impl Animation for AlphaAnimation {
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = next.chest.ori * -0.45; next.shorts.ori = next.chest.ori * -0.45;
next.l_hand.offset = Vec3::new(-0.25, -5.0, 1.0); next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05; next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(1.25, -5.5, -2.0); next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, 0.0); next.main.offset = Vec3::new(0.0, 0.0, 0.0);
@ -89,12 +89,20 @@ impl Animation for AlphaAnimation {
* Quaternion::rotation_z(1.4 + slow * -0.5); * Quaternion::rotation_z(1.4 + slow * -0.5);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, slow * -3.0 + quick * 3.0 - 4.0, 8.0); next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0,
slow * -3.0 + quick * 3.0 - 4.0,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(slow * 0.6) next.l_foot.ori = Quaternion::rotation_x(slow * 0.6)
* Quaternion::rotation_y((slow * -0.2).max(0.0)); * Quaternion::rotation_y((slow * -0.2).max(0.0));
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, slow * 3.0 + quick * -3.0 + 5.0, 8.0); next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0,
slow * 3.0 + quick * -3.0 + 5.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slow * -0.6) next.r_foot.ori = Quaternion::rotation_x(slow * -0.6)
* Quaternion::rotation_y((slow * 0.2).min(0.0)); * Quaternion::rotation_y((slow * 0.2).min(0.0));
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
@ -161,14 +169,16 @@ impl Animation for AlphaAnimation {
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}, },
Some(ToolKind::Hammer(_)) => { Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(0.0, 3.0, 8.0); next.l_hand.offset = Vec3::new(-7.0, 5.5, 3.5);
next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.32);
next.l_hand.scale = Vec3::one() * 1.05; next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); next.r_hand.offset = Vec3::new(8.0, 7.75, 0.0);
next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.22);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0); next.main.offset = Vec3::new(6.0, 7.0, 0.0);
next.main.ori = Quaternion::rotation_x(-0.3); next.main.ori = Quaternion::rotation_x(0.3)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(1.57);
next.head.offset = next.head.offset =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(slower * 0.05) next.head.ori = Quaternion::rotation_z(slower * 0.05)
@ -195,12 +205,14 @@ impl Animation for AlphaAnimation {
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
if velocity > 0.5 { if velocity > 0.5 {
next.l_foot.offset = Vec3::new(-3.4, foot * -2.0, 8.0); next.l_foot.offset =
Vec3::new(-skeleton_attr.foot.0, foot * -2.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4) next.l_foot.ori = Quaternion::rotation_x(foot * -0.4)
* Quaternion::rotation_z((slower * 0.6).max(0.0)); * Quaternion::rotation_z((slower * 0.6).max(0.0));
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, foot * 2.0, 8.0); next.r_foot.offset =
Vec3::new(skeleton_attr.foot.0, foot * 2.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4) next.r_foot.ori = Quaternion::rotation_x(foot * 0.4)
* Quaternion::rotation_z((slower * 0.6).max(0.0)); * Quaternion::rotation_z((slower * 0.6).max(0.0));
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
@ -208,12 +220,20 @@ impl Animation for AlphaAnimation {
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.15); next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.15);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else { } else {
next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + (slower * 2.5).max(0.0)); next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0,
-2.5,
skeleton_attr.foot.2 + (slower * 2.5).max(0.0),
);
next.l_foot.ori = Quaternion::rotation_x(slower * -0.2 - 0.2) next.l_foot.ori = Quaternion::rotation_x(slower * -0.2 - 0.2)
* Quaternion::rotation_z((slower * 1.0).max(0.0)); * Quaternion::rotation_z((slower * 1.0).max(0.0));
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 3.5 - slower * 2.0, 8.0); next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0,
3.5 - slower * 2.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slower * 0.1) next.r_foot.ori = Quaternion::rotation_x(slower * 0.1)
* Quaternion::rotation_z((slower * 0.5).max(0.0)); * Quaternion::rotation_z((slower * 0.5).max(0.0));
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
@ -222,10 +242,10 @@ impl Animation for AlphaAnimation {
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} }
next.control.offset = Vec3::new(-6.0, 3.0 + slower * 2.0, 8.0 + slower * 5.0); next.control.offset = Vec3::new(-4.0, 3.0 + slower * 2.0, 5.0 + slower * 5.0);
next.control.ori = Quaternion::rotation_x(-0.2 + slower * 1.8) next.control.ori = Quaternion::rotation_x(-0.7 + slower * 1.8)
* Quaternion::rotation_y(0.0) * Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.4 + 1.57); * Quaternion::rotation_z(1.4);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;

View File

@ -63,10 +63,10 @@ impl Animation for BetaAnimation {
* Quaternion::rotation_x(slow * 0.1) * Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05); * Quaternion::rotation_y(slow * -0.05);
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04; next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0); next.main.offset = Vec3::new(0.0, 6.0, -1.0);
@ -77,11 +77,16 @@ impl Animation for BetaAnimation {
* Quaternion::rotation_y(slow * 2.0 + 0.7) * Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6); * Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-3.4, footquick * -9.5, 8.0); next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3) next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3)
* Quaternion::rotation_y(footquick * -0.6); * Quaternion::rotation_y(footquick * -0.6);
next.r_foot.offset = Vec3::new(3.4, footquick * 9.5, 8.0); next.r_foot.offset =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3) next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3)
* Quaternion::rotation_y(footquick * 0.2); * Quaternion::rotation_y(footquick * 0.2);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;

View File

@ -6,12 +6,12 @@ use vek::*;
pub struct ChargeAnimation; pub struct ChargeAnimation;
impl Animation for ChargeAnimation { impl Animation for ChargeAnimation {
type Dependency = (Option<ToolKind>, f32, f64); type Dependency = (Option<ToolKind>, f32, Vec3<f32>, Vec3<f32>, f64);
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
fn update_skeleton( fn update_skeleton(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(active_tool_kind, velocity, _global_time): Self::Dependency, (active_tool_kind, velocity, orientation, last_ori, _global_time): Self::Dependency,
anim_time: f64, anim_time: f64,
rate: &mut f32, rate: &mut f32,
skeleton_attr: &SkeletonAttr, skeleton_attr: &SkeletonAttr,
@ -47,24 +47,37 @@ impl Animation for ChargeAnimation {
let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2); let stop = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0); let stopa = ((anim_time as f32).powf(0.9 as f32)).min(5.0);
let ori = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::from(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.offset = Vec3::new( next.head.offset = Vec3::new(
0.0 + stop * -2.0, 0.0 + stop * -2.0,
-2.0 + stop * 2.5 + skeleton_attr.head.0, -2.0 + stop * 2.5 + skeleton_attr.head.0,
skeleton_attr.head.1, skeleton_attr.head.1,
); );
next.head.ori = Quaternion::rotation_z(stop * -1.0) next.head.ori =
* Quaternion::rotation_x(0.0) Quaternion::rotation_z(stop * -1.0 + tilt * -2.0) * Quaternion::rotation_y(stop * -0.3);
* Quaternion::rotation_y(stop * -0.3);
next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1); next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_z(stop * 1.2 + stress * stop * 0.02); next.chest.ori = Quaternion::rotation_z(stop * 1.2 + stress * stop * 0.02 + tilt * -2.0);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(stop * -0.5); next.belt.ori = Quaternion::rotation_z(stop * -0.5 + tilt * 2.0);
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(stop * -0.7); next.shorts.ori = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0);
match active_tool_kind { match active_tool_kind {
//TODO: Inventory //TODO: Inventory
@ -115,32 +128,47 @@ impl Animation for ChargeAnimation {
}, },
_ => {}, _ => {},
} }
if velocity > 0.5 {
next.l_foot.offset = Vec3::new(-3.4 - foot * 1.5, foote * 2.0, 8.0); if velocity > 0.2 {
next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0 - foot * 1.5,
skeleton_attr.foot.1 + foote * 2.0,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(foote * -0.1) next.l_foot.ori = Quaternion::rotation_x(foote * -0.1)
* Quaternion::rotation_z(0.4) * Quaternion::rotation_z(0.4)
* Quaternion::rotation_y(0.15); * Quaternion::rotation_y(0.15);
next.r_foot.offset = Vec3::new(3.4 + foot * 1.5, foote * -1.5, 8.0); next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0 + foot * 1.5,
skeleton_attr.foot.1 + foote * -1.5,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(0.0) next.r_foot.ori = Quaternion::rotation_x(0.0)
* Quaternion::rotation_z(0.4) * Quaternion::rotation_z(0.4)
* Quaternion::rotation_y(0.0); * Quaternion::rotation_y(0.0);
next.torso.offset = next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
Vec3::new(0.0 + foot * 0.03, foote * 0.05, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0); next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else { } else {
next.l_foot.offset = Vec3::new(-3.4, -2.5 + stop * -1.3, 8.0); next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0,
-2.5 + stop * -1.3,
skeleton_attr.foot.2 + tilt * -4.0 * foot,
);
next.l_foot.ori = Quaternion::rotation_x(stop * -0.2 - 0.2 + stop * stress * 0.02) next.l_foot.ori = Quaternion::rotation_x(stop * -0.2 - 0.2 + stop * stress * 0.02)
* Quaternion::rotation_z(stop * 0.1) * Quaternion::rotation_z(stop * 0.1)
* Quaternion::rotation_y(stop * 0.08); * Quaternion::rotation_y(stop * 0.08);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 3.5 + stop * 1.5, 8.0); next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0,
3.5 + stop * 1.5,
skeleton_attr.foot.2 + tilt * 4.0 * foot,
);
next.r_foot.ori = next.r_foot.ori =
Quaternion::rotation_x(stop * 0.1) * Quaternion::rotation_z(stop * 0.1); Quaternion::rotation_x(stop * 0.1) * Quaternion::rotation_z(stop * 0.1);
next.r_foot.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0); next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;

View File

@ -74,7 +74,7 @@ impl Animation for ClimbAnimation {
next.l_hand.offset = Vec3::new( next.l_hand.offset = Vec3::new(
-skeleton_attr.hand.0, -skeleton_attr.hand.0,
skeleton_attr.hand.1 + quicka * 1.5, skeleton_attr.hand.1 + quicka * 1.5,
skeleton_attr.hand.2 - quick * 4.0, 5.0 + skeleton_attr.hand.2 - quick * 4.0,
); );
next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5); next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5);
next.l_hand.scale = Vec3::one(); next.l_hand.scale = Vec3::one();
@ -82,7 +82,7 @@ impl Animation for ClimbAnimation {
next.r_hand.offset = Vec3::new( next.r_hand.offset = Vec3::new(
skeleton_attr.hand.0, skeleton_attr.hand.0,
skeleton_attr.hand.1 - quicka * 1.5, skeleton_attr.hand.1 - quicka * 1.5,
skeleton_attr.hand.2 + quick * 4.0, 5.0 + skeleton_attr.hand.2 + quick * 4.0,
); );
next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5); next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5);
next.r_hand.scale = Vec3::one(); next.r_hand.scale = Vec3::one();

View File

@ -0,0 +1,161 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct DanceAnimation;
impl Animation for DanceAnimation {
type Dependency = (Option<ToolKind>, f64);
type Skeleton = CharacterSkeleton;
fn update_skeleton(
skeleton: &Self::Skeleton,
(_active_tool_kind, global_time): Self::Dependency,
anim_time: f64,
rate: &mut f32,
skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
*rate = 1.0;
let lab = 1.0;
let short = (((5.0)
/ (3.0 + 2.0 * ((anim_time as f32 * lab as f32 * 6.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 6.0).sin());
let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin();
let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin();
let shorte = (anim_time as f32 * lab as f32 * 6.0).sin();
let shortealt = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin();
let foot = (((5.0)
/ (1.0 + (4.0) * ((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 head_look = Vec2::new(
((global_time + anim_time) as f32 / 6.0)
.floor()
.mul(7331.0)
.sin()
* 0.3,
((global_time + anim_time) as f32 / 6.0)
.floor()
.mul(1337.0)
.sin()
* 0.15,
);
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(short * -0.6)
* Quaternion::rotation_x(0.2 + head_look.y.max(0.0) + shorte.abs() * -0.2);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + shortealt * 1.5,
);
next.chest.ori = Quaternion::rotation_z(short * 0.35)
* Quaternion::rotation_y(shorte * 0.08)
* Quaternion::rotation_x(foot * 0.07);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(shorte * 0.25);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(-0.25 + shorte * 0.1 + noisea * 0.1 + noiseb * 0.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(foot * 0.35);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
1.0 - skeleton_attr.hand.0,
2.0 + skeleton_attr.hand.1 + shortealt * -3.0,
skeleton_attr.hand.2 + shortealt * -0.75,
);
next.l_hand.ori = Quaternion::rotation_x(1.4 + foot * 0.15) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
-1.0 + skeleton_attr.hand.0,
2.0 + skeleton_attr.hand.1 + shortealt * 3.0,
skeleton_attr.hand.2 + shortealt * 0.75,
);
next.r_hand.ori = Quaternion::rotation_x(1.4 + foot * -0.15) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0 + foot * 0.8,
1.5 + -skeleton_attr.foot.1 + foot * -4.0,
skeleton_attr.foot.2 + 2.0,
);
next.l_foot.ori =
Quaternion::rotation_x(foot * -0.3) * Quaternion::rotation_z(short * -0.15);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0 + foot * 0.8,
1.5 + -skeleton_attr.foot.1 + foot * 4.0,
skeleton_attr.foot.2 + 2.0,
);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.3) * Quaternion::rotation_z(short * 0.15);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(shorte * 0.15);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(shorte * -0.15);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.main.offset = Vec3::new(-7.0, -6.5, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + shorte * 0.25);
next.main.scale = Vec3::one();
next.second.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
Quaternion::rotation_x(shorte * 0.7 + 0.4) * Quaternion::rotation_y(shorte * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.3, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(short * -0.2);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.scale = Vec3::one();
next.r_control.scale = Vec3::one();
next
}
}

View File

@ -54,10 +54,10 @@ impl Animation for DashAnimation {
next.shorts.offset = Vec3::new(0.0, 3.0, -3.0); next.shorts.offset = Vec3::new(0.0, 3.0, -3.0);
next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3); next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04; next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0); next.main.offset = Vec3::new(0.0, 6.0, -1.0);
@ -68,10 +68,10 @@ impl Animation for DashAnimation {
next.control.ori = next.control.ori =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2); Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, 8.0); next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8); next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, 8.0); next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8); next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8);
}, },
_ => {}, _ => {},

View File

@ -37,10 +37,10 @@ impl Animation for EquipAnimation {
match active_tool_kind { match active_tool_kind {
//TODO: Inventory //TODO: Inventory
Some(ToolKind::Sword(_)) => { Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.25, -5.0, -5.0); next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2); next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04; next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(1.25, -5.5, -8.0); next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3); next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -6.0); next.main.offset = Vec3::new(0.0, 0.0, -6.0);
@ -76,10 +76,10 @@ impl Animation for EquipAnimation {
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
Some(ToolKind::Hammer(_)) => { Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0 + 9.0, 4.6 + 1.5, 7.5 - 1.6); next.l_hand.offset = Vec3::new(-7.0, 5.5, 3.5);
next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32); next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32);
next.l_hand.scale = Vec3::one() * 1.08; next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); next.r_hand.offset = Vec3::new(8.0, 7.75, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22); next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22);
next.r_hand.scale = Vec3::one() * 1.06; next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(6.0, 7.0, 0.0); next.main.offset = Vec3::new(6.0, 7.0, 0.0);

View File

@ -42,18 +42,17 @@ impl Animation for GlidingAnimation {
let ori = Vec2::from(orientation); let ori = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori); let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori) let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::from(o).magnitude_squared()) .map(|o| Vec2::<f32>::from(o).magnitude_squared())
.map(|m| m > 0.001 && m.is_finite()) .map(|m| m > 0.0001 && m.is_finite())
.reduce_and() .reduce_and()
&& ori.angle_between(last_ori).is_finite() && ori.angle_between(last_ori).is_finite()
{ {
ori.angle_between(last_ori).min(0.15) ori.angle_between(last_ori).min(0.05)
* last_ori.determine_side(Vec2::zero(), ori).signum() * last_ori.determine_side(Vec2::zero(), ori).signum()
} else { } else {
0.0 0.0
} * 0.8; };
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_x(0.35 - slow * 0.10 + head_look.y) next.head.ori = Quaternion::rotation_x(0.35 - slow * 0.10 + head_look.y)
@ -68,15 +67,15 @@ impl Animation for GlidingAnimation {
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(slowa * 0.35); next.shorts.ori = Quaternion::rotation_z(slowa * 0.35);
next.l_hand.offset = Vec3::new(-9.5 + slowa * -1.5, -3.0 + slowa * 1.5, 8.0); next.l_hand.offset = Vec3::new(-9.5 + slowa * -1.5, -3.0 + slowa * 1.5, 10.0);
next.l_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.1); next.l_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.1);
next.r_hand.offset = Vec3::new(9.5 + slowa * -1.5, -3.0 + slowa * -1.5, 8.0); next.r_hand.offset = Vec3::new(9.5 + slowa * -1.5, -3.0 + slowa * -1.5, 10.0);
next.r_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.10); next.r_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.10);
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
2.0 + skeleton_attr.foot.1, skeleton_attr.foot.1,
-9.0 + skeleton_attr.foot.2, -9.0 + skeleton_attr.foot.2,
); );
next.l_foot.ori = Quaternion::rotation_x( next.l_foot.ori = Quaternion::rotation_x(
@ -86,7 +85,7 @@ impl Animation for GlidingAnimation {
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
2.0 + skeleton_attr.foot.1, skeleton_attr.foot.1,
-9.0 + skeleton_attr.foot.2, -9.0 + skeleton_attr.foot.2,
); );
next.r_foot.ori = Quaternion::rotation_x( next.r_foot.ori = Quaternion::rotation_x(
@ -127,7 +126,7 @@ impl Animation for GlidingAnimation {
next.torso.offset = Vec3::new(0.0, 6.0, 15.0) / 11.0 * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 6.0, 15.0) / 11.0 * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.05 * speed.max(12.0) + slow * 0.06) next.torso.ori = Quaternion::rotation_x(-0.05 * speed.max(12.0) + slow * 0.06)
* Quaternion::rotation_y(tilt * 16.0); * Quaternion::rotation_y(tilt * 32.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();

View File

@ -1,39 +1,61 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind; use common::comp::item::ToolKind;
use std::f32::consts::PI;
use vek::*; use vek::*;
pub struct JumpAnimation; pub struct JumpAnimation;
impl Animation for JumpAnimation { impl Animation for JumpAnimation {
type Dependency = (Option<ToolKind>, f64); type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, f64);
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
fn update_skeleton( fn update_skeleton(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(_active_tool_kind, _global_time): Self::Dependency, (_active_tool_kind, orientation, last_ori, global_time): Self::Dependency,
anim_time: f64, anim_time: f64,
_rate: &mut f32, _rate: &mut f32,
skeleton_attr: &SkeletonAttr, skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton { ) -> Self::Skeleton {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let quick = (anim_time as f32 * 14.0).sin();
let slow = (anim_time as f32 * 7.0).sin(); let slow = (anim_time as f32 * 7.0).sin();
let stop = (anim_time as f32 * 1.5).min(PI / 2.0).sin();
let random = ((((2.0
* ((global_time as f32 - anim_time as f32)
- ((global_time as f32 - anim_time as f32).round())))
.abs())
* 10.0)
.round())
/ 10.0;
let switch = if random > 0.5 { 1.0 } else { -1.0 };
let ori = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::from(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.offset = Vec3::new( next.head.offset = Vec3::new(
0.0, 0.0,
-3.0 + skeleton_attr.head.0, -3.0 + skeleton_attr.head.0,
-1.0 + skeleton_attr.head.1, -1.0 + skeleton_attr.head.1,
); );
next.head.ori = Quaternion::rotation_x(0.25 + stop * 0.1 + slow * 0.04); next.head.ori =
Quaternion::rotation_x(0.25 + slow * 0.04) * Quaternion::rotation_z(tilt * -2.5);
next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 + 1.0); next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 + 1.0);
next.chest.ori = Quaternion::rotation_z(0.0); next.chest.ori = Quaternion::rotation_z(tilt * -2.0);
next.chest.scale = Vec3::one() * 1.01; next.chest.scale = Vec3::one() * 1.01;
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(0.0); next.belt.ori = Quaternion::rotation_z(tilt * 2.0);
next.belt.scale = Vec3::one(); next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
@ -41,41 +63,61 @@ impl Animation for JumpAnimation {
next.back.scale = Vec3::one() * 1.02; next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(0.0); next.shorts.ori = Quaternion::rotation_z(tilt * 3.0);
next.shorts.scale = Vec3::one(); next.shorts.scale = Vec3::one();
if random > 0.5 {
next.l_hand.offset = Vec3::new( next.l_hand.offset = Vec3::new(
-skeleton_attr.hand.0 + stop * -1.8, -skeleton_attr.hand.0,
skeleton_attr.hand.1 + stop * 2.0, 1.0 + skeleton_attr.hand.1 + 4.0,
-2.0 + skeleton_attr.hand.2 + stop * 3.2 - quick * 0.4, 2.0 + skeleton_attr.hand.2 + slow * 1.5,
); );
next.l_hand.ori = next.l_hand.ori =
Quaternion::rotation_x(stop * 1.2 + slow * 0.3) * Quaternion::rotation_y(stop * 0.2); Quaternion::rotation_x(1.9 + slow * 0.4) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one(); next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new( next.r_hand.offset = Vec3::new(
skeleton_attr.hand.0 + stop * 1.8, skeleton_attr.hand.0,
skeleton_attr.hand.1 + stop * -2.0, skeleton_attr.hand.1 - 3.0,
-2.0 + skeleton_attr.hand.2 + stop * 3.2 - quick * 0.4, skeleton_attr.hand.2 + slow * 1.5,
); );
next.r_hand.ori = next.r_hand.ori =
Quaternion::rotation_x(-stop * 1.2 + slow * -0.3) * Quaternion::rotation_y(stop * -0.2); Quaternion::rotation_x(-0.5 + slow * -0.4) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one(); next.r_hand.scale = Vec3::one();
} else {
next.l_hand.offset = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 - 3.0,
skeleton_attr.hand.2 + slow * 1.5,
);
next.l_hand.ori =
Quaternion::rotation_x(-0.5 + slow * -0.4) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
skeleton_attr.hand.0,
1.0 + skeleton_attr.hand.1 + 4.0,
2.0 + skeleton_attr.hand.2 + slow * 1.5,
);
next.r_hand.ori =
Quaternion::rotation_x(1.9 + slow * 0.4) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one();
};
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
skeleton_attr.foot.1, skeleton_attr.foot.1 - 6.0 * switch,
skeleton_attr.foot.2, 1.0 + skeleton_attr.foot.2 + slow * 1.5,
); );
next.l_foot.ori = Quaternion::rotation_x(stop * -1.2 + slow * -0.3); next.l_foot.ori = Quaternion::rotation_x(-1.2 * switch + slow * -0.2 * switch);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
skeleton_attr.foot.1, skeleton_attr.foot.1 + 6.0 * switch,
skeleton_attr.foot.2, 1.0 + skeleton_attr.foot.2 + slow * 1.5,
); );
next.r_foot.ori = Quaternion::rotation_x(stop * 1.2 + slow * 0.3); next.r_foot.ori = Quaternion::rotation_x(1.2 * switch + slow * 0.2 * switch);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new( next.l_shoulder.offset = Vec3::new(
@ -83,7 +125,7 @@ impl Animation for JumpAnimation {
skeleton_attr.shoulder.1, skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2, skeleton_attr.shoulder.2,
); );
next.l_shoulder.ori = Quaternion::rotation_x(stop * 0.3); next.l_shoulder.ori = Quaternion::rotation_x(0.4 * switch);
next.l_shoulder.scale = Vec3::one() * 1.1; next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new( next.r_shoulder.offset = Vec3::new(
@ -91,7 +133,7 @@ impl Animation for JumpAnimation {
skeleton_attr.shoulder.1, skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2, skeleton_attr.shoulder.2,
); );
next.r_shoulder.ori = Quaternion::rotation_x(-stop * 0.3); next.r_shoulder.ori = Quaternion::rotation_x(-0.4 * switch);
next.r_shoulder.scale = Vec3::one() * 1.1; next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0); next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
@ -110,8 +152,8 @@ impl Animation for JumpAnimation {
skeleton_attr.lantern.1, skeleton_attr.lantern.1,
skeleton_attr.lantern.2, skeleton_attr.lantern.2,
); );
next.lantern.ori = Quaternion::rotation_x(stop * 1.2 + slow * 0.3) next.lantern.ori = Quaternion::rotation_x(1.0 * switch + slow * 0.3 * switch)
* Quaternion::rotation_y(stop * 0.4 + slow * 0.3); * Quaternion::rotation_y(0.6 * switch + slow * 0.3 * switch);
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;

View File

@ -4,6 +4,7 @@ pub mod block;
pub mod blockidle; pub mod blockidle;
pub mod charge; pub mod charge;
pub mod climb; pub mod climb;
pub mod dance;
pub mod dash; pub mod dash;
pub mod equip; pub mod equip;
pub mod gliding; pub mod gliding;
@ -22,10 +23,10 @@ pub mod wield;
pub use self::{ pub use self::{
alpha::AlphaAnimation, beta::BetaAnimation, block::BlockAnimation, alpha::AlphaAnimation, beta::BetaAnimation, block::BlockAnimation,
blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation, blockidle::BlockIdleAnimation, charge::ChargeAnimation, climb::ClimbAnimation,
dash::DashAnimation, equip::EquipAnimation, gliding::GlidingAnimation, idle::IdleAnimation, dance::DanceAnimation, dash::DashAnimation, equip::EquipAnimation, gliding::GlidingAnimation,
jump::JumpAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, idle::IdleAnimation, jump::JumpAnimation, roll::RollAnimation, run::RunAnimation,
sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation, swim::SwimAnimation, shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, stand::StandAnimation,
wield::WieldAnimation, swim::SwimAnimation, wield::WieldAnimation,
}; };
use super::{Bone, Skeleton}; use super::{Bone, Skeleton};
@ -50,6 +51,7 @@ pub struct CharacterSkeleton {
main: Bone, main: Bone,
second: Bone, second: Bone,
lantern: Bone, lantern: Bone,
hold: Bone,
torso: Bone, torso: Bone,
control: Bone, control: Bone,
l_control: Bone, l_control: Bone,
@ -104,7 +106,9 @@ impl Skeleton for CharacterSkeleton {
torso_mat * chest_mat * control_mat * r_control_mat * second_mat, torso_mat * chest_mat * control_mat * r_control_mat * second_mat,
), ),
FigureBoneData::new(lantern_final_mat), FigureBoneData::new(lantern_final_mat),
FigureBoneData::default(), FigureBoneData::new(
torso_mat * chest_mat * l_hand_mat * self.hold.compute_base_matrix(),
),
], ],
(lantern_final_mat * Vec4::new(0.0, 0.0, 0.0, 1.0)).xyz(), (lantern_final_mat * Vec4::new(0.0, 0.0, 0.0, 1.0)).xyz(),
) )
@ -126,6 +130,7 @@ impl Skeleton for CharacterSkeleton {
self.main.interpolate(&target.main, dt); self.main.interpolate(&target.main, dt);
self.second.interpolate(&target.second, dt); self.second.interpolate(&target.second, dt);
self.lantern.interpolate(&target.lantern, dt); self.lantern.interpolate(&target.lantern, dt);
self.hold.interpolate(&target.hold, dt);
self.torso.interpolate(&target.torso, dt); self.torso.interpolate(&target.torso, dt);
self.control.interpolate(&target.control, dt); self.control.interpolate(&target.control, dt);
self.l_control.interpolate(&target.l_control, dt); self.l_control.interpolate(&target.l_control, dt);
@ -216,18 +221,18 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
(Danari, Female) => 1.15, (Danari, Female) => 1.15,
}, },
head: match (body.race, body.body_type) { head: match (body.race, body.body_type) {
(Orc, Male) => (0.0, 14.0), (Orc, Male) => (0.0, 13.5),
(Orc, Female) => (0.0, 14.0), (Orc, Female) => (0.0, 13.0),
(Human, Male) => (0.3, 13.5), (Human, Male) => (0.3, 13.0),
(Human, Female) => (0.0, 13.8), (Human, Female) => (0.0, 13.5),
(Elf, Male) => (0.5, 13.5), (Elf, Male) => (0.5, 13.0),
(Elf, Female) => (1.0, 13.5), (Elf, Female) => (1.0, 13.0),
(Dwarf, Male) => (0.0, 14.5), (Dwarf, Male) => (0.0, 14.0),
(Dwarf, Female) => (0.0, 14.0), (Dwarf, Female) => (0.0, 13.5),
(Undead, Male) => (0.5, 13.6), (Undead, Male) => (0.5, 13.0),
(Undead, Female) => (0.5, 14.5), (Undead, Female) => (0.5, 14.0),
(Danari, Male) => (0.5, 14.0), (Danari, Male) => (0.5, 12.5),
(Danari, Female) => (0.5, 14.0), (Danari, Female) => (0.5, 13.5),
}, },
chest: match (body.race, body.body_type) { chest: match (body.race, body.body_type) {
(_, _) => (0.0, 7.0), (_, _) => (0.0, 7.0),
@ -242,10 +247,10 @@ impl<'a> From<&'a comp::humanoid::Body> for SkeletonAttr {
(_, _) => (0.0, -5.0), (_, _) => (0.0, -5.0),
}, },
hand: match (body.race, body.body_type) { hand: match (body.race, body.body_type) {
(_, _) => (7.0, -0.25, 5.0), (_, _) => (7.0, -0.25, 0.5),
}, },
foot: match (body.race, body.body_type) { foot: match (body.race, body.body_type) {
(_, _) => (3.4, -0.1, 8.0), (_, _) => (3.4, 0.5, 1.0),
}, },
shoulder: match (body.race, body.body_type) { shoulder: match (body.race, body.body_type) {
(_, _) => (5.0, 0.0, 5.0), (_, _) => (5.0, 0.0, 5.0),

View File

@ -1,6 +1,5 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::ToolKind; use common::comp::item::ToolKind;
use std::f32::consts::PI;
use vek::*; use vek::*;
pub struct RollAnimation; pub struct RollAnimation;
@ -19,95 +18,89 @@ impl Animation for RollAnimation {
*rate = 1.0; *rate = 1.0;
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let wave = (anim_time as f32 * 4.5).sin(); let spin = anim_time as f32;
let wave_quick = (anim_time as f32 * 7.5).sin();
let wave_quick_cos = (anim_time as f32 * 7.5).cos();
let wave_slow = (anim_time as f32 * 2.3 + PI).sin();
let wave_dub = (anim_time as f32 * 4.5).sin();
let ori = Vec2::from(orientation); let ori = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori); let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori) let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::from(o).magnitude_squared()) .map(|o| Vec2::<f32>::from(o).magnitude_squared())
.map(|m| m > 0.001 && m.is_finite()) .map(|m| m > 0.0001 && m.is_finite())
.reduce_and() .reduce_and()
&& ori.angle_between(last_ori).is_finite() && ori.angle_between(last_ori).is_finite()
{ {
ori.angle_between(last_ori).min(0.5) ori.angle_between(last_ori).min(0.05)
* last_ori.determine_side(Vec2::zero(), ori).signum() * last_ori.determine_side(Vec2::zero(), ori).signum()
} else { } else {
0.0 0.0
} * 1.3; };
next.head.offset = Vec3::new( next.head.offset = Vec3::new(
0.0, 0.0,
-2.0 + skeleton_attr.head.0 + 3.0, -2.0 + skeleton_attr.head.0 + 3.0,
skeleton_attr.head.1 - 2.0, skeleton_attr.head.1 - 1.0,
); );
next.head.ori = Quaternion::rotation_x(wave_dub * -0.8); next.head.ori = Quaternion::rotation_x(-0.75);
next.head.scale = Vec3::one(); next.head.scale = Vec3::one();
next.chest.offset = Vec3::new( next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, -9.5 + skeleton_attr.chest.1);
0.0, next.chest.ori = Quaternion::rotation_x(-0.2);
skeleton_attr.chest.0,
skeleton_attr.chest.1 + wave_dub * -5.0,
);
next.chest.ori = Quaternion::rotation_x(wave_dub * 0.4);
next.chest.scale = Vec3::one() * 1.01; next.chest.scale = Vec3::one() * 1.01;
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 2.0, skeleton_attr.belt.1 + 2.0); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1 + 1.0);
next.belt.ori = Quaternion::rotation_x(0.0 + wave_dub * 0.8); next.belt.ori = Quaternion::rotation_x(0.55);
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new( next.shorts.offset = Vec3::new(
0.0, 0.0,
skeleton_attr.shorts.0 + 2.0, skeleton_attr.shorts.0 + 4.5,
skeleton_attr.shorts.1 + 3.0, skeleton_attr.shorts.1 + 2.5,
); );
next.shorts.ori = Quaternion::rotation_x(0.0 + wave_dub * 0.8); next.shorts.ori = Quaternion::rotation_x(0.8);
next.l_hand.offset = Vec3::new( next.l_hand.offset = Vec3::new(
-skeleton_attr.chest.0 + wave * -0.5, -skeleton_attr.hand.0,
skeleton_attr.hand.1 + wave_quick_cos * -5.5, skeleton_attr.hand.1 + 1.0,
skeleton_attr.hand.2 + wave_quick * 0.5, skeleton_attr.hand.2 + 2.0,
); );
next.l_hand.ori = next.l_hand.ori = Quaternion::rotation_x(0.6);
Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(wave * 0.3);
next.l_hand.scale = Vec3::one(); next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new( next.r_hand.offset = Vec3::new(
skeleton_attr.hand.0 + wave * 0.5, -1.0 + skeleton_attr.hand.0,
skeleton_attr.hand.1 + wave_quick_cos * 2.5, skeleton_attr.hand.1 + 1.0,
skeleton_attr.hand.2 + wave_quick * 3.0, skeleton_attr.hand.2 + 2.0,
); );
next.r_hand.ori =
Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(wave * 0.3); next.r_hand.ori = Quaternion::rotation_x(0.6);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, 1.0 - skeleton_attr.foot.0,
skeleton_attr.foot.1, skeleton_attr.foot.1 + 5.5,
skeleton_attr.foot.2 + wave_dub * -1.2, skeleton_attr.foot.2 - 5.0,
); );
next.l_foot.ori = Quaternion::rotation_x(wave * 0.6); next.l_foot.ori = Quaternion::rotation_x(0.9);
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
skeleton_attr.foot.1, skeleton_attr.foot.1 + 5.5,
skeleton_attr.foot.2 + wave_dub * -1.0, skeleton_attr.foot.2 - 5.0,
); );
next.r_foot.ori = Quaternion::rotation_x(wave * -0.4); next.r_foot.ori = Quaternion::rotation_x(0.9);
next.l_shoulder.offset = Vec3::new( next.l_shoulder.offset = Vec3::new(
-skeleton_attr.shoulder.0, -skeleton_attr.shoulder.0,
skeleton_attr.shoulder.0, skeleton_attr.shoulder.1 + 2.0,
skeleton_attr.shoulder.2, skeleton_attr.shoulder.2 + 1.0,
); );
next.l_shoulder.ori = Quaternion::rotation_x(0.0); next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1; next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new( next.r_shoulder.offset = Vec3::new(
skeleton_attr.shoulder.0, skeleton_attr.shoulder.0,
skeleton_attr.shoulder.0, skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2, skeleton_attr.shoulder.2,
); );
next.r_shoulder.ori = Quaternion::rotation_x(0.0); next.r_shoulder.ori = Quaternion::rotation_x(0.0);
@ -121,7 +114,7 @@ impl Animation for RollAnimation {
next.main.scale = Vec3::one(); next.main.scale = Vec3::one();
next.second.offset = Vec3::new(0.0, 0.0, 0.0); next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.scale = Vec3::one() * 0.0; next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new( next.lantern.offset = Vec3::new(
skeleton_attr.lantern.0, skeleton_attr.lantern.0,
@ -131,9 +124,9 @@ impl Animation for RollAnimation {
next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1); next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = next.torso.offset = Vec3::new(0.0, 0.0, 8.0) / 11.0 * skeleton_attr.scaler;
Vec3::new(0.0, 0.0, 0.0 + wave_dub * 16.0) / 11.0 * skeleton_attr.scaler; next.torso.ori =
next.torso.ori = Quaternion::rotation_x(wave_slow * 6.5) * Quaternion::rotation_y(tilt); Quaternion::rotation_x(spin * -10.0) * Quaternion::rotation_z(tilt * -10.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0); next.control.offset = Vec3::new(0.0, 0.0, 0.0);

View File

@ -21,11 +21,33 @@ impl Animation for RunAnimation {
let speed = Vec2::<f32>::from(velocity).magnitude(); let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = 1.0; *rate = 1.0;
let walkintensity = if speed > 5.0 { 1.0 } else { 0.7 }; let walkintensity = if speed > 5.0 { 1.0 } else { 0.45 };
let walk = if speed > 5.0 { 1.0 } else { 0.5 }; let walk = if speed > 5.0 { 1.0 } else { 0.5 };
let lower = if speed > 5.0 { 0.0 } else { 1.0 }; let lower = if speed > 5.0 { 0.0 } else { 1.0 };
let snapfoot = if speed > 5.0 { 1.1 } else { 2.0 }; let _snapfoot = if speed > 5.0 { 1.1 } else { 2.0 };
let lab = 1.0; let lab = 1.0;
let foothoril = (anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.45).sin();
let foothorir = (anim_time as f32 * 16.0 * walk * lab as f32 + PI * (0.45)).sin();
let footvertl = (anim_time as f32 * 16.0 * walk * lab as f32).sin();
let footvertr = (anim_time as f32 * 16.0 * walk * lab as f32 + PI).sin();
let footrotl = (((5.0)
/ (2.5
+ (2.5)
* ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin());
let footrotr = (((5.0)
/ (1.0
+ (4.0)
* ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin());
let short = (((5.0) let short = (((5.0)
/ (1.5 / (1.5
+ 3.5 * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powf(2.0 as f32))) + 3.5 * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powf(2.0 as f32)))
@ -40,20 +62,8 @@ impl Animation for RunAnimation {
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()); * ((anim_time as f32 * lab as f32 * 16.0 * walk).sin());
let shortalt = (((5.0) let shortalt = (anim_time as f32 * lab as f32 * 16.0 * walk + PI / 2.0).sin();
/ (1.5 let shortalter = (anim_time as f32 * lab as f32 * 16.0 * walk + PI / -2.0).sin();
+ 3.5
* ((anim_time as f32 * lab as f32 * 16.0 * walk + PI / 2.0).sin())
.powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 16.0 * walk + PI / 2.0).sin());
let foot = (((5.0)
/ (snapfoot
+ (5.0 - snapfoot)
* ((anim_time as f32 * lab as f32 * 16.0 * walk).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * lab as f32 * 16.0 * walk).sin());
let wave_stop = (anim_time as f32 * 26.0).min(PI / 2.0 / 2.0).sin(); let wave_stop = (anim_time as f32 * 26.0).min(PI / 2.0 / 2.0).sin();
@ -78,7 +88,7 @@ impl Animation for RunAnimation {
.reduce_and() .reduce_and()
&& ori.angle_between(last_ori).is_finite() && ori.angle_between(last_ori).is_finite()
{ {
ori.angle_between(last_ori).min(0.5) ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum() * last_ori.determine_side(Vec2::zero(), ori).signum()
} else { } else {
0.0 0.0
@ -87,22 +97,25 @@ impl Animation for RunAnimation {
next.head.offset = Vec3::new( next.head.offset = Vec3::new(
0.0, 0.0,
-3.0 + skeleton_attr.head.0, -3.0 + skeleton_attr.head.0,
-1.0 + skeleton_attr.head.1 + short * 0.1, skeleton_attr.head.1 + short * 0.1,
); );
next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.1) next.head.ori = Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.1)
* Quaternion::rotation_x(head_look.y + 0.35); * Quaternion::rotation_x(head_look.y + 0.45 - lower * 0.35);
next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new( next.chest.offset = Vec3::new(
0.0, 0.0,
skeleton_attr.chest.0, skeleton_attr.chest.0,
skeleton_attr.chest.1 + 2.0 + short * 1.1 - lower, skeleton_attr.chest.1 + 2.0 + shortalt * -1.5 - lower,
); );
next.chest.ori = Quaternion::rotation_z(short * 0.15 * walkintensity); next.chest.ori = Quaternion::rotation_z(short * 0.18 * walkintensity + tilt * -0.6)
* Quaternion::rotation_y(tilt * 1.6)
* Quaternion::rotation_x(shortalter * 0.035 + wave_stop * speed * -0.07 + (tilt.abs()));
next.chest.scale = Vec3::one(); next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(short * 0.1); next.belt.ori =
Quaternion::rotation_z(short * 0.1 + tilt * -1.1) * Quaternion::rotation_y(tilt * 0.5);
next.belt.scale = Vec3::one(); next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
@ -110,41 +123,44 @@ impl Animation for RunAnimation {
next.back.scale = Vec3::one() * 1.02; next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(short * 0.2); next.shorts.ori =
Quaternion::rotation_z(short * 0.25 + tilt * -1.5) * Quaternion::rotation_y(tilt * 0.7);
next.shorts.scale = Vec3::one(); next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new( next.l_hand.offset = Vec3::new(
-skeleton_attr.hand.0 + wave_stop * 1.0 * walkintensity, -skeleton_attr.hand.0 + foothorir * -1.3,
skeleton_attr.hand.1 + short * 3.0 * walkintensity, 3.0 + skeleton_attr.hand.1 + foothorir * -7.0 * walkintensity,
1.0 + skeleton_attr.hand.2 + short * -0.75 * walkintensity, 1.5 + skeleton_attr.hand.2 - foothorir * 5.5 * walkintensity,
); );
next.l_hand.ori = Quaternion::rotation_x(0.2 + short * 1.5 * walk) next.l_hand.ori = Quaternion::rotation_x(0.6 + footrotr * -1.2 * walkintensity)
* Quaternion::rotation_y(wave_stop * -0.1); * Quaternion::rotation_y(footrotr * 0.4 * walkintensity);
next.l_hand.scale = Vec3::one(); next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new( next.r_hand.offset = Vec3::new(
skeleton_attr.hand.0 + wave_stop * -1.0 * walkintensity, skeleton_attr.hand.0 + foothoril * 1.3,
skeleton_attr.hand.1 + short * -3.0 * walkintensity, 3.0 + skeleton_attr.hand.1 + foothoril * -6.5 * walkintensity,
1.0 + skeleton_attr.hand.2 + short * 0.75 * walkintensity, 1.5 + skeleton_attr.hand.2 - foothoril * 7.0 * walkintensity,
); );
next.r_hand.ori = Quaternion::rotation_x(0.2 + short * -1.5 * walk) next.r_hand.ori = Quaternion::rotation_x(0.6 + footrotl * -1.2 * walkintensity)
* Quaternion::rotation_y(wave_stop * 0.1); * Quaternion::rotation_y(footrotl * -0.4 * walkintensity);
next.r_hand.scale = Vec3::one(); next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
-skeleton_attr.foot.1 + foot * 1.0, -1.5 + skeleton_attr.foot.1 + foothoril * -8.5 * walkintensity - lower * 1.0,
skeleton_attr.foot.2 + 1.0, 2.0 + skeleton_attr.foot.2 + ((footvertl * -2.7).max(-1.0)) * walkintensity,
); );
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2 * walkintensity); next.l_foot.ori = Quaternion::rotation_x(-0.2 + footrotl * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
-skeleton_attr.foot.1 + foot * -1.0, -1.5 + skeleton_attr.foot.1 + foothorir * -8.5 * walkintensity - lower * 1.0,
skeleton_attr.foot.2 + 1.0, 2.0 + skeleton_attr.foot.2 + ((footvertr * -2.7).max(-1.0)) * walkintensity,
); );
next.r_foot.ori = Quaternion::rotation_x(foot * 1.2 * walkintensity); next.r_foot.ori = Quaternion::rotation_x(-0.2 + footrotr * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new( next.l_shoulder.offset = Vec3::new(
@ -178,13 +194,11 @@ impl Animation for RunAnimation {
skeleton_attr.lantern.2, skeleton_attr.lantern.2,
); );
next.lantern.ori = next.lantern.ori =
Quaternion::rotation_x(shorte * -0.7 + 0.4) * Quaternion::rotation_y(shorte * 0.4); Quaternion::rotation_x(shorte * 0.7 + 0.4) * Quaternion::rotation_y(shorte * 0.4);
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.0) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, -0.3, 0.0) * skeleton_attr.scaler;
next.torso.ori = next.torso.ori = Quaternion::rotation_y(0.0);
Quaternion::rotation_x(wave_stop * speed * -0.05 + wave_stop * speed * -0.005)
* Quaternion::rotation_y(tilt);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0); next.control.offset = Vec3::new(0.0, 0.0, 0.0);

View File

@ -60,10 +60,10 @@ impl Animation for ShootAnimation {
match active_tool_kind { match active_tool_kind {
//TODO: Inventory //TODO: Inventory
Some(ToolKind::Staff(_)) => { Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); next.l_hand.offset = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05; next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); next.r_hand.offset = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.ori = Quaternion::rotation_x(1.8) next.r_hand.ori = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5) * Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27); * Quaternion::rotation_z(-0.27);
@ -104,15 +104,21 @@ impl Animation for ShootAnimation {
_ => {}, _ => {},
} }
if velocity > 0.5 { if velocity > 0.5 {
next.l_foot.offset = next.l_foot.offset = Vec3::new(
Vec3::new(-3.4 - foot * 1.0 + exp * -1.0, foote * 0.8 + exp * 1.5, 8.0); -skeleton_attr.foot.0 - foot * 1.0 + exp * -1.0,
foote * 0.8 + exp * 1.5,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(exp * 0.5) next.l_foot.ori = Quaternion::rotation_x(exp * 0.5)
* Quaternion::rotation_z(exp * 0.4) * Quaternion::rotation_z(exp * 0.4)
* Quaternion::rotation_y(0.15); * Quaternion::rotation_y(0.15);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = next.r_foot.offset = Vec3::new(
Vec3::new(3.4 + foot * 1.0 + exp * 1.0, foote * -0.8 + exp * -1.0, 8.0); skeleton_attr.foot.0 + foot * 1.0 + exp * 1.0,
foote * -0.8 + exp * -1.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(exp * -0.5) next.r_foot.ori = Quaternion::rotation_x(exp * -0.5)
* Quaternion::rotation_z(exp * 0.4) * Quaternion::rotation_z(exp * 0.4)
* Quaternion::rotation_y(0.0); * Quaternion::rotation_y(0.0);
@ -121,11 +127,16 @@ impl Animation for ShootAnimation {
next.torso.ori = Quaternion::rotation_x(-0.15); next.torso.ori = Quaternion::rotation_x(-0.15);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else { } else {
next.l_foot.offset = Vec3::new(-3.4, -2.5, 8.0 + exp * 2.5); next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0,
-2.5,
skeleton_attr.foot.2 + exp * 2.5,
);
next.l_foot.ori = next.l_foot.ori =
Quaternion::rotation_x(exp * -0.2 - 0.2) * Quaternion::rotation_z(exp * 1.0); Quaternion::rotation_x(exp * -0.2 - 0.2) * Quaternion::rotation_z(exp * 1.0);
next.r_foot.offset = Vec3::new(3.4, 3.5 - exp * 2.0, 8.0); next.r_foot.offset =
Vec3::new(skeleton_attr.foot.0, 3.5 - exp * 2.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(exp * 0.1) * Quaternion::rotation_z(exp * 0.5); next.r_foot.ori = Quaternion::rotation_x(exp * 0.1) * Quaternion::rotation_z(exp * 0.5);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0); next.torso.ori = Quaternion::rotation_z(0.0);

View File

@ -85,16 +85,16 @@ impl Animation for SitAnimation {
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
skeleton_attr.foot.1, 4.0 + skeleton_attr.foot.1,
skeleton_attr.foot.2, 3.0 + skeleton_attr.foot.2,
); );
next.l_foot.ori = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1); next.l_foot.ori = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
skeleton_attr.foot.1, 4.0 + skeleton_attr.foot.1,
skeleton_attr.foot.2, 3.0 + skeleton_attr.foot.2,
); );
next.r_foot.ori = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1); next.r_foot.ori = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();

View File

@ -38,10 +38,10 @@ impl Animation for SpinAnimation {
//TODO: Inventory //TODO: Inventory
Some(ToolKind::Axe(_)) | Some(ToolKind::Hammer(_)) | Some(ToolKind::Sword(_)) => { Some(ToolKind::Axe(_)) | Some(ToolKind::Hammer(_)) | Some(ToolKind::Sword(_)) => {
//INTENTION: SWORD //INTENTION: SWORD
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0); next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27); next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04; next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.0, 0.0, -3.0); next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27); next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0); next.main.offset = Vec3::new(0.0, 6.0, -1.0);
@ -85,11 +85,11 @@ impl Animation for SpinAnimation {
_ => {}, _ => {},
} }
next.l_foot.offset = Vec3::new(-3.4, foot * 1.0, 8.0); next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2); next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, foot * -1.0, 8.0); next.r_foot.offset = Vec3::new(skeleton_attr.foot.0, foot * -1.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 1.2); next.r_foot.ori = Quaternion::rotation_x(foot * 1.2);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();

View File

@ -6,12 +6,12 @@ use vek::*;
pub struct SwimAnimation; pub struct SwimAnimation;
impl Animation for SwimAnimation { impl Animation for SwimAnimation {
type Dependency = (Option<ToolKind>, Vec3<f32>, f32, f64); type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
type Skeleton = CharacterSkeleton; type Skeleton = CharacterSkeleton;
fn update_skeleton( fn update_skeleton(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
(_active_tool_kind, velocity, _orientation, global_time): Self::Dependency, (_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
anim_time: f64, anim_time: f64,
rate: &mut f32, rate: &mut f32,
skeleton_attr: &SkeletonAttr, skeleton_attr: &SkeletonAttr,
@ -43,7 +43,19 @@ impl Animation for SwimAnimation {
.sin() .sin()
* 0.1, * 0.1,
); );
let ori = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
.map(|o| Vec2::<f32>::from(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.offset = Vec3::new( next.head.offset = Vec3::new(
0.0, 0.0,
-3.0 + skeleton_attr.head.0, -3.0 + skeleton_attr.head.0,
@ -75,34 +87,34 @@ impl Animation for SwimAnimation {
next.l_hand.offset = Vec3::new( next.l_hand.offset = Vec3::new(
-skeleton_attr.hand.0, -skeleton_attr.hand.0,
skeleton_attr.hand.1 - foot * 1.2, 1.5 + skeleton_attr.hand.1 - foot * 1.2,
skeleton_attr.hand.2 + foot * -3.0, 2.0 + skeleton_attr.hand.2 + foot * -3.0,
); );
next.l_hand.ori = Quaternion::rotation_x(0.8 + foot * -0.6) * Quaternion::rotation_y(0.2); next.l_hand.ori = Quaternion::rotation_x(0.8 + foot * -0.6) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one(); next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new( next.r_hand.offset = Vec3::new(
skeleton_attr.hand.0, skeleton_attr.hand.0,
skeleton_attr.hand.1 + foot * 1.2, 1.5 + skeleton_attr.hand.1 + foot * 1.2,
skeleton_attr.hand.2 + foot * 3.0, 2.0 + skeleton_attr.hand.2 + foot * 3.0,
); );
next.r_hand.ori = Quaternion::rotation_x(0.8 + foot * 0.6) * Quaternion::rotation_y(-0.2); next.r_hand.ori = Quaternion::rotation_x(0.8 + foot * 0.6) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one(); next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new( next.l_foot.offset = Vec3::new(
-skeleton_attr.foot.0, -skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foot * 1.2, skeleton_attr.foot.1 + foot * 1.2,
-5.0 + skeleton_attr.foot.2 + foot * 6.5, -3.0 + skeleton_attr.foot.2 + foot * 3.5,
); );
next.l_foot.ori = Quaternion::rotation_x(-1.40 + foot * 0.6); next.l_foot.ori = Quaternion::rotation_x(-1.1 + foot * 0.6);
next.l_foot.scale = Vec3::one(); next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new( next.r_foot.offset = Vec3::new(
skeleton_attr.foot.0, skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 - foot * 1.2, skeleton_attr.foot.1 - foot * 1.2,
-5.0 + skeleton_attr.foot.2 + foot * -6.5, -3.0 + skeleton_attr.foot.2 + foot * -3.5,
); );
next.r_foot.ori = Quaternion::rotation_x(-1.40 + foot * -0.6); next.r_foot.ori = Quaternion::rotation_x(-1.1 + foot * -0.6);
next.r_foot.scale = Vec3::one(); next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new( next.l_shoulder.offset = Vec3::new(
@ -139,7 +151,8 @@ impl Animation for SwimAnimation {
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, -0.3 + shortalt * -0.065, 0.4) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.05); next.torso.ori = Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.05)
* Quaternion::rotation_z(tilt * 12.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();

View File

@ -21,71 +21,77 @@ impl Animation for WieldAnimation {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let head_look = Vec2::new( let head_look = Vec2::new(
((global_time + anim_time) as f32 / 10.0) ((global_time + anim_time) as f32 / 3.0)
.floor() .floor()
.mul(7331.0) .mul(7331.0)
.sin() .sin()
* 0.2, * 0.2,
((global_time + anim_time) as f32 / 10.0) ((global_time + anim_time) as f32 / 3.0)
.floor() .floor()
.mul(1337.0) .mul(1337.0)
.sin() .sin()
* 0.1, * 0.1,
); );
let slow_cos = (anim_time as f32 * 6.0 + PI).cos(); let slowalt = (anim_time as f32 * 6.0 + PI).cos();
let ultra_slow = (anim_time as f32 * 1.0 + PI).sin(); let u_slow = (anim_time as f32 * 1.0 + PI).sin();
let slow = (anim_time as f32 * 3.0 + PI).sin(); let slow = (anim_time as f32 * 3.0 + PI).sin();
let ultra_slow_cos = (anim_time as f32 * 3.0 + PI).cos(); let u_slowalt = (anim_time as f32 * 3.0 + PI).cos();
let short = (((5.0) let short = (((5.0)
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32)))
.sqrt()) .sqrt())
* ((anim_time as f32 * lab as f32 * 16.0).sin()); * ((anim_time as f32 * lab as f32 * 16.0).sin());
let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin();
let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin();
let wave = (anim_time as f32 * 16.0).sin();
if velocity > 0.5 { if velocity > 0.5 {
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.2); next.torso.ori = Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.back.offset = Vec3::new(0.0, -2.8, 7.25); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x( next.back.ori = Quaternion::rotation_x(
(-0.25 + short * 0.3 + noisea * 0.4 + noiseb * 0.4).min(-0.1), (-0.5 + short * 0.3 + noisea * 0.3 + noiseb * 0.3).min(-0.1),
); );
next.back.scale = Vec3::one() * 1.02; next.back.scale = Vec3::one() * 1.02;
} else { } else {
next.head.offset = Vec3::new( next.head.offset = Vec3::new(
0.0, 0.0,
-2.0 + skeleton_attr.head.0, -2.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + ultra_slow * 0.1, skeleton_attr.head.1 + u_slow * 0.1,
); );
next.head.ori = next.head.ori =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new( next.chest.offset = Vec3::new(
0.0 + slow_cos * 0.5, 0.0 + slowalt * 0.5,
skeleton_attr.chest.0, skeleton_attr.chest.0,
skeleton_attr.chest.1 + ultra_slow * 0.5, skeleton_attr.chest.1 + u_slow * 0.5,
); );
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.l_foot.offset = Vec3::new(-3.4, -2.5, 9.0); next.l_foot.offset = Vec3::new(
next.l_foot.ori = Quaternion::rotation_x(ultra_slow_cos * 0.035 - 0.2); -skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(u_slowalt * 0.035 - 0.2);
next.r_foot.offset = Vec3::new(3.4, 3.5, 9.0); next.r_foot.offset = Vec3::new(
next.r_foot.ori = Quaternion::rotation_x(ultra_slow * 0.035); skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(u_slow * 0.035);
next.chest.ori = next.chest.ori =
Quaternion::rotation_y(ultra_slow_cos * 0.04) * Quaternion::rotation_z(0.15); Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.15);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22);
Quaternion::rotation_y(ultra_slow_cos * 0.03) * Quaternion::rotation_z(0.22);
next.belt.scale = Vec3::one() * 1.02; next.belt.scale = Vec3::one() * 1.02;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
@ -97,10 +103,10 @@ impl Animation for WieldAnimation {
match active_tool_kind { match active_tool_kind {
//TODO: Inventory //TODO: Inventory
Some(ToolKind::Sword(_)) => { Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.25, -5.0, -2.0); next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04; next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(1.25, -5.5, -5.0); next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05; next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -3.0); next.main.offset = Vec3::new(0.0, 0.0, -3.0);
@ -109,9 +115,9 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0); * Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(-7.0, 6.0, 6.0); next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(ultra_slow * 0.15) next.control.ori = Quaternion::rotation_x(u_slow * 0.15)
* Quaternion::rotation_y(0.0) * Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(ultra_slow_cos * 0.08); * Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
Some(ToolKind::Axe(_)) => { Some(ToolKind::Axe(_)) => {
@ -131,16 +137,16 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(-0.8); * Quaternion::rotation_z(-0.8);
next.control.offset = Vec3::new(0.0, 0.0, 0.0); next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(ultra_slow_cos * 0.1 + 0.2) next.control.ori = Quaternion::rotation_x(u_slowalt * 0.1 + 0.2)
* Quaternion::rotation_y(-0.3) * Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(ultra_slow * 0.1 + 0.0); * Quaternion::rotation_z(u_slow * 0.1 + 0.0);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
Some(ToolKind::Hammer(_)) => { Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 4.6, 7.5); next.l_hand.offset = Vec3::new(-7.0, 5.5, 3.5);
next.l_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.32); next.l_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.32);
next.l_hand.scale = Vec3::one() * 1.08; next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(8.0, 5.75, 4.0); next.r_hand.offset = Vec3::new(8.0, 7.75, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.22); next.r_hand.ori = Quaternion::rotation_x(0.3) * Quaternion::rotation_y(0.22);
next.r_hand.scale = Vec3::one() * 1.06; next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(6.0, 7.0, 0.0); next.main.offset = Vec3::new(6.0, 7.0, 0.0);
@ -149,16 +155,16 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(1.57); * Quaternion::rotation_z(1.57);
next.control.offset = Vec3::new(0.0, 0.0, 0.0); next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(ultra_slow * 0.15) next.control.ori = Quaternion::rotation_x(u_slow * 0.15)
* Quaternion::rotation_y(0.0) * Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(ultra_slow_cos * 0.08); * Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
Some(ToolKind::Staff(_)) => { Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0); next.l_hand.offset = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05; next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0); next.r_hand.offset = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.ori = Quaternion::rotation_x(1.8) next.r_hand.ori = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5) * Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27); * Quaternion::rotation_z(-0.27);
@ -169,9 +175,9 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.9); * Quaternion::rotation_z(0.9);
next.control.offset = Vec3::new(-14.0, 1.8, 3.0); next.control.offset = Vec3::new(-14.0, 1.8, 3.0);
next.control.ori = Quaternion::rotation_x(ultra_slow * 0.2) next.control.ori = Quaternion::rotation_x(u_slow * 0.2)
* Quaternion::rotation_y(-0.2) * Quaternion::rotation_y(-0.2)
* Quaternion::rotation_z(ultra_slow_cos * 0.1); * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
Some(ToolKind::Shield(_)) => { Some(ToolKind::Shield(_)) => {
@ -188,12 +194,12 @@ impl Animation for WieldAnimation {
next.main.scale = Vec3::one(); next.main.scale = Vec3::one();
}, },
Some(ToolKind::Bow(_)) => { Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(1.0, -4.0, -1.0); next.l_hand.offset = Vec3::new(2.0, 1.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.20) next.l_hand.ori = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6) * Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3); * Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.05; next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(3.0, -1.0, -5.0); next.r_hand.offset = Vec3::new(4.0, 4.5, -5.0);
next.r_hand.ori = Quaternion::rotation_x(1.20) next.r_hand.ori = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6) * Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3); * Quaternion::rotation_z(-0.3);
@ -204,8 +210,8 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(-0.6); * Quaternion::rotation_z(-0.6);
next.control.offset = Vec3::new(-7.0, 6.0, 6.0); next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(ultra_slow * 0.2) next.control.ori =
* Quaternion::rotation_z(ultra_slow_cos * 0.1); Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
Some(ToolKind::Debug(_)) => { Some(ToolKind::Debug(_)) => {
@ -222,7 +228,7 @@ impl Animation for WieldAnimation {
next.main.offset = Vec3::new(5.0, 8.75, -2.0); next.main.offset = Vec3::new(5.0, 8.75, -2.0);
next.main.ori = Quaternion::rotation_x(-0.3) next.main.ori = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27) * Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave * -0.25); * Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one(); next.main.scale = Vec3::one();
}, },
Some(ToolKind::Farming(_)) => { Some(ToolKind::Farming(_)) => {
@ -245,9 +251,9 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_z(0.0); * Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0); next.control.offset = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
next.control.ori = Quaternion::rotation_x(ultra_slow * 0.1) next.control.ori = Quaternion::rotation_x(u_slow * 0.1)
* Quaternion::rotation_y(0.6 + ultra_slow * 0.1) * Quaternion::rotation_y(0.6 + u_slow * 0.1)
* Quaternion::rotation_z(ultra_slow_cos * 0.1); * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one(); next.control.scale = Vec3::one();
}, },
_ => {}, _ => {},

View File

@ -9,6 +9,7 @@ pub struct KeyState {
pub climb_down: bool, pub climb_down: bool,
pub toggle_wield: bool, pub toggle_wield: bool,
pub toggle_sit: bool, pub toggle_sit: bool,
pub toggle_dance: bool,
pub swap_loadout: bool, pub swap_loadout: bool,
pub respawn: bool, pub respawn: bool,
pub analog_matrix: Vec2<f32>, pub analog_matrix: Vec2<f32>,
@ -25,6 +26,7 @@ impl KeyState {
climb_down: false, climb_down: false,
toggle_wield: false, toggle_wield: false,
toggle_sit: false, toggle_sit: false,
toggle_dance: false,
swap_loadout: false, swap_loadout: false,
respawn: false, respawn: false,
analog_matrix: Vec2::zero(), analog_matrix: Vec2::zero(),

View File

@ -151,38 +151,10 @@ impl<Skel: Skeleton> FigureModelCache<Skel> {
)), )),
CameraMode::FirstPerson => None, CameraMode::FirstPerson => None,
}, },
if camera_mode == CameraMode::FirstPerson Some(humanoid_armor_hand_spec.mesh_left_hand(&body, loadout, generate_mesh)),
&& character_state.map(|cs| cs.is_dodge()).unwrap_or_default() Some(humanoid_armor_hand_spec.mesh_right_hand(&body, loadout, generate_mesh)),
{ Some(humanoid_armor_foot_spec.mesh_left_foot(&body, loadout, generate_mesh)),
None Some(humanoid_armor_foot_spec.mesh_right_foot(&body, loadout, generate_mesh)),
} else {
Some(humanoid_armor_hand_spec.mesh_left_hand(&body, loadout, generate_mesh))
},
if character_state.map(|cs| cs.is_dodge()).unwrap_or_default() {
None
} else {
Some(humanoid_armor_hand_spec.mesh_right_hand(
&body,
loadout,
generate_mesh,
))
},
match camera_mode {
CameraMode::ThirdPerson => Some(humanoid_armor_foot_spec.mesh_left_foot(
&body,
loadout,
generate_mesh,
)),
CameraMode::FirstPerson => None,
},
match camera_mode {
CameraMode::ThirdPerson => Some(humanoid_armor_foot_spec.mesh_right_foot(
&body,
loadout,
generate_mesh,
)),
CameraMode::FirstPerson => None,
},
match camera_mode { match camera_mode {
CameraMode::ThirdPerson => { CameraMode::ThirdPerson => {
Some(humanoid_armor_shoulder_spec.mesh_left_shoulder( Some(humanoid_armor_shoulder_spec.mesh_left_shoulder(

View File

@ -558,7 +558,7 @@ impl FigureMgr {
// In air // In air
(false, _, false) => anim::character::JumpAnimation::update_skeleton( (false, _, false) => anim::character::JumpAnimation::update_skeleton(
&CharacterSkeleton::new(), &CharacterSkeleton::new(),
(active_tool_kind, time), (active_tool_kind, ori, state.last_ori, time),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
skeleton_attr, skeleton_attr,
@ -566,7 +566,7 @@ impl FigureMgr {
// Swim // Swim
(false, _, true) => anim::character::SwimAnimation::update_skeleton( (false, _, true) => anim::character::SwimAnimation::update_skeleton(
&CharacterSkeleton::new(), &CharacterSkeleton::new(),
(active_tool_kind, vel.0, ori.magnitude(), time), (active_tool_kind, vel.0, ori, state.last_ori, time),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
skeleton_attr, skeleton_attr,
@ -603,7 +603,13 @@ impl FigureMgr {
} else { } else {
anim::character::ChargeAnimation::update_skeleton( anim::character::ChargeAnimation::update_skeleton(
&target_base, &target_base,
(active_tool_kind, vel.0.magnitude(), time), (
active_tool_kind,
vel.0.magnitude(),
ori,
state.last_ori,
time,
),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
skeleton_attr, skeleton_attr,
@ -721,6 +727,15 @@ impl FigureMgr {
skeleton_attr, skeleton_attr,
) )
}, },
CharacterState::Dance { .. } => {
anim::character::DanceAnimation::update_skeleton(
&CharacterSkeleton::new(),
(active_tool_kind, time),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
},
_ => target_base, _ => target_base,
}; };

View File

@ -312,6 +312,14 @@ impl PlayState for SessionState {
self.client.borrow_mut().toggle_sit(); self.client.borrow_mut().toggle_sit();
} }
} }
Event::InputUpdate(GameInput::Dance, state)
if state != self.key_state.toggle_dance =>
{
self.key_state.toggle_dance = state;
if state {
self.client.borrow_mut().toggle_dance();
}
}
Event::InputUpdate(GameInput::MoveForward, state) => self.key_state.up = state, Event::InputUpdate(GameInput::MoveForward, state) => self.key_state.up = state,
Event::InputUpdate(GameInput::MoveBack, state) => self.key_state.down = state, Event::InputUpdate(GameInput::MoveBack, state) => self.key_state.down = state,
Event::InputUpdate(GameInput::MoveLeft, state) => self.key_state.left = state, Event::InputUpdate(GameInput::MoveLeft, state) => self.key_state.left = state,

View File

@ -116,6 +116,7 @@ impl ControlSettings {
GameInput::MoveRight => KeyMouse::Key(VirtualKeyCode::D), GameInput::MoveRight => KeyMouse::Key(VirtualKeyCode::D),
GameInput::Jump => KeyMouse::Key(VirtualKeyCode::Space), GameInput::Jump => KeyMouse::Key(VirtualKeyCode::Space),
GameInput::Sit => KeyMouse::Key(VirtualKeyCode::K), GameInput::Sit => KeyMouse::Key(VirtualKeyCode::K),
GameInput::Dance => KeyMouse::Key(VirtualKeyCode::J),
GameInput::Glide => KeyMouse::Key(VirtualKeyCode::LShift), GameInput::Glide => KeyMouse::Key(VirtualKeyCode::LShift),
GameInput::Climb => KeyMouse::Key(VirtualKeyCode::Space), GameInput::Climb => KeyMouse::Key(VirtualKeyCode::Space),
GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl), GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl),
@ -172,6 +173,7 @@ impl Default for ControlSettings {
GameInput::MoveRight, GameInput::MoveRight,
GameInput::Jump, GameInput::Jump,
GameInput::Sit, GameInput::Sit,
GameInput::Dance,
GameInput::Glide, GameInput::Glide,
GameInput::Climb, GameInput::Climb,
GameInput::ClimbDown, GameInput::ClimbDown,
@ -273,6 +275,7 @@ pub mod con_settings {
pub move_right: Button, pub move_right: Button,
pub jump: Button, pub jump: Button,
pub sit: Button, pub sit: Button,
pub dance: Button,
pub glide: Button, pub glide: Button,
pub climb: Button, pub climb: Button,
pub climb_down: Button, pub climb_down: Button,
@ -360,6 +363,7 @@ pub mod con_settings {
move_right: Button::Simple(GilButton::Unknown), move_right: Button::Simple(GilButton::Unknown),
jump: Button::Simple(GilButton::South), jump: Button::Simple(GilButton::South),
sit: Button::Simple(GilButton::West), sit: Button::Simple(GilButton::West),
dance: Button::Simple(GilButton::Unknown),
glide: Button::Simple(GilButton::LeftTrigger), glide: Button::Simple(GilButton::LeftTrigger),
climb: Button::Simple(GilButton::South), climb: Button::Simple(GilButton::South),
climb_down: Button::Simple(GilButton::Unknown), climb_down: Button::Simple(GilButton::Unknown),

View File

@ -34,6 +34,7 @@ pub enum GameInput {
MoveRight, MoveRight,
Jump, Jump,
Sit, Sit,
Dance,
Glide, Glide,
Climb, Climb,
ClimbDown, ClimbDown,
@ -75,6 +76,7 @@ impl GameInput {
GameInput::MoveBack => "gameinput.moveback", GameInput::MoveBack => "gameinput.moveback",
GameInput::Jump => "gameinput.jump", GameInput::Jump => "gameinput.jump",
GameInput::Sit => "gameinput.sit", GameInput::Sit => "gameinput.sit",
GameInput::Dance => "gameinput.dance",
GameInput::Glide => "gameinput.glide", GameInput::Glide => "gameinput.glide",
GameInput::Climb => "gameinput.climb", GameInput::Climb => "gameinput.climb",
GameInput::ClimbDown => "gameinput.climbdown", GameInput::ClimbDown => "gameinput.climbdown",