mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'slipped/swim' into 'master'
swim See merge request veloren/veloren!1272
This commit is contained in:
commit
66bc7a194b
@ -594,6 +594,21 @@ impl Client {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_sneak(&mut self) {
|
||||
let is_sneaking = self
|
||||
.state
|
||||
.ecs()
|
||||
.read_storage::<comp::CharacterState>()
|
||||
.get(self.entity)
|
||||
.map(|cs| matches!(cs, comp::CharacterState::Sneak));
|
||||
|
||||
match is_sneaking {
|
||||
Some(true) => self.control_action(ControlAction::Stand),
|
||||
Some(false) => self.control_action(ControlAction::Sneak),
|
||||
None => warn!("Can't toggle sneak, client entity doesn't have a `CharacterState`"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_glide(&mut self) {
|
||||
let is_gliding = self
|
||||
.state
|
||||
|
@ -41,6 +41,7 @@ pub enum CharacterState {
|
||||
Climb,
|
||||
Sit,
|
||||
Dance,
|
||||
Sneak,
|
||||
Glide,
|
||||
GlideWield,
|
||||
/// A basic blocking state
|
||||
|
@ -46,6 +46,7 @@ pub enum ControlAction {
|
||||
Unwield,
|
||||
Sit,
|
||||
Dance,
|
||||
Sneak,
|
||||
Stand,
|
||||
}
|
||||
|
||||
@ -170,7 +171,8 @@ pub struct ControllerInputs {
|
||||
pub wall_leap: Input,
|
||||
pub charge: Input,
|
||||
pub climb: Option<Climb>,
|
||||
pub swim: Input,
|
||||
pub swimup: Input,
|
||||
pub swimdown: Input,
|
||||
pub move_dir: Vec2<f32>,
|
||||
pub look_dir: Dir,
|
||||
}
|
||||
@ -194,7 +196,8 @@ impl ControllerInputs {
|
||||
self.glide.tick(dt);
|
||||
self.wall_leap.tick(dt);
|
||||
self.charge.tick(dt);
|
||||
self.swim.tick(dt);
|
||||
self.swimup.tick(dt);
|
||||
self.swimdown.tick(dt);
|
||||
}
|
||||
|
||||
pub fn tick_freshness(&mut self) {
|
||||
@ -206,7 +209,8 @@ impl ControllerInputs {
|
||||
self.glide.tick_freshness();
|
||||
self.wall_leap.tick_freshness();
|
||||
self.charge.tick_freshness();
|
||||
self.swim.tick_freshness();
|
||||
self.swimup.tick_freshness();
|
||||
self.swimdown.tick_freshness();
|
||||
}
|
||||
|
||||
/// Updates Controller inputs with new version received from the client
|
||||
@ -220,7 +224,8 @@ impl ControllerInputs {
|
||||
self.wall_leap.update_with_new(new.wall_leap);
|
||||
self.charge.update_with_new(new.charge);
|
||||
self.climb = new.climb;
|
||||
self.swim.update_with_new(new.swim);
|
||||
self.swimup.update_with_new(new.swimup);
|
||||
self.swimdown.update_with_new(new.swimdown);
|
||||
self.move_dir = new.move_dir;
|
||||
self.look_dir = new.look_dir;
|
||||
}
|
||||
|
@ -52,7 +52,8 @@ impl CharacterBehavior for Data {
|
||||
|
||||
// Expend energy if climbing
|
||||
let energy_use = match climb {
|
||||
Climb::Up | Climb::Down => 8,
|
||||
Climb::Up => 5,
|
||||
Climb::Down => 1,
|
||||
Climb::Hold => 1,
|
||||
};
|
||||
|
||||
@ -79,14 +80,15 @@ impl CharacterBehavior for Data {
|
||||
match climb {
|
||||
Climb::Down => {
|
||||
update.vel.0 -=
|
||||
data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0);
|
||||
data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 1.0);
|
||||
},
|
||||
Climb::Up => {
|
||||
update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED);
|
||||
},
|
||||
Climb::Hold => {
|
||||
// Antigrav
|
||||
update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.5).min(CLIMB_SPEED);
|
||||
update.vel.0.z =
|
||||
(update.vel.0.z + data.dt.0 * GRAVITY * 1.075).min(CLIMB_SPEED);
|
||||
update.vel.0 = Lerp::lerp(
|
||||
update.vel.0,
|
||||
Vec3::zero(),
|
||||
|
@ -24,7 +24,9 @@ impl CharacterBehavior for Data {
|
||||
update.character = CharacterState::GlideWield;
|
||||
return update;
|
||||
}
|
||||
|
||||
if data.physics.in_fluid {
|
||||
update.character = CharacterState::Idle;
|
||||
}
|
||||
// If there is a wall in front of character and they are trying to climb go to
|
||||
// climb
|
||||
handle_climb(&data, &mut update);
|
||||
|
@ -16,9 +16,12 @@ impl CharacterBehavior for Data {
|
||||
handle_wield(data, &mut update);
|
||||
|
||||
// If not on the ground while wielding glider enter gliding state
|
||||
if !data.physics.on_ground && !data.physics.in_fluid {
|
||||
if !data.physics.on_ground {
|
||||
update.character = CharacterState::Glide;
|
||||
}
|
||||
if data.physics.in_fluid {
|
||||
update.character = CharacterState::Idle;
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
@ -35,6 +38,12 @@ impl CharacterBehavior for Data {
|
||||
update
|
||||
}
|
||||
|
||||
fn sneak(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_sneak(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn unwield(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
update.character = CharacterState::Idle;
|
||||
|
@ -37,6 +37,12 @@ impl CharacterBehavior for Data {
|
||||
update
|
||||
}
|
||||
|
||||
fn sneak(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_sneak(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn glide_wield(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_glide_wield(data, &mut update);
|
||||
|
@ -13,6 +13,7 @@ pub mod idle;
|
||||
pub mod leap_melee;
|
||||
pub mod roll;
|
||||
pub mod sit;
|
||||
pub mod sneak;
|
||||
pub mod spin_melee;
|
||||
pub mod triple_strike;
|
||||
pub mod utils;
|
||||
|
56
common/src/states/sneak.rs
Normal file
56
common/src/states/sneak.rs
Normal file
@ -0,0 +1,56 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, StateUpdate},
|
||||
sys::character_behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
|
||||
pub struct Data;
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
handle_move(data, &mut update, 0.4);
|
||||
handle_jump(data, &mut update);
|
||||
handle_wield(data, &mut update);
|
||||
handle_climb(data, &mut update);
|
||||
handle_dodge_input(data, &mut update);
|
||||
|
||||
// Try to Fall/Stand up/Move
|
||||
if !data.physics.on_ground {
|
||||
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 dance(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_dance(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn glide_wield(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_glide_wield(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn swap_loadout(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_swap_loadout(data, &mut update);
|
||||
update
|
||||
}
|
||||
}
|
@ -118,9 +118,14 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) {
|
||||
handle_orientation(data, update, if data.physics.on_ground { 9.0 } else { 2.0 });
|
||||
|
||||
// Swim
|
||||
if data.inputs.swim.is_pressed() {
|
||||
if data.inputs.swimup.is_pressed() {
|
||||
update.vel.0.z =
|
||||
(update.vel.0.z + data.dt.0 * GRAVITY * 2.25).min(BASE_HUMANOID_WATER_SPEED);
|
||||
(update.vel.0.z + data.dt.0 * GRAVITY * 4.0).min(BASE_HUMANOID_WATER_SPEED);
|
||||
}
|
||||
// Swim
|
||||
if data.inputs.swimdown.is_pressed() {
|
||||
update.vel.0.z =
|
||||
(update.vel.0.z + data.dt.0 * GRAVITY * -3.5).min(BASE_HUMANOID_WATER_SPEED);
|
||||
}
|
||||
}
|
||||
|
||||
@ -159,6 +164,12 @@ pub fn attempt_dance(data: &JoinData, update: &mut StateUpdate) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn attempt_sneak(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.physics.on_ground && data.body.is_humanoid() {
|
||||
update.character = CharacterState::Sneak;
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks that player can `Climb` and updates `CharacterState` if so
|
||||
pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) {
|
||||
if data.inputs.climb.is_some()
|
||||
|
@ -33,6 +33,12 @@ impl CharacterBehavior for Data {
|
||||
update
|
||||
}
|
||||
|
||||
fn sneak(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_sneak(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn unwield(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
update.character = CharacterState::Idle;
|
||||
|
@ -27,6 +27,7 @@ pub trait CharacterBehavior {
|
||||
fn unwield(&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 sneak(&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 {
|
||||
match event {
|
||||
@ -36,6 +37,7 @@ pub trait CharacterBehavior {
|
||||
ControlAction::Unwield => self.unwield(data),
|
||||
ControlAction::Sit => self.sit(data),
|
||||
ControlAction::Dance => self.dance(data),
|
||||
ControlAction::Sneak => self.sneak(data),
|
||||
ControlAction::Stand => self.stand(data),
|
||||
}
|
||||
}
|
||||
@ -232,6 +234,9 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::Dance => {
|
||||
states::dance::Data::handle_event(&states::dance::Data, &j, action)
|
||||
},
|
||||
CharacterState::Sneak => {
|
||||
states::sneak::Data::handle_event(&states::sneak::Data, &j, action)
|
||||
},
|
||||
CharacterState::BasicBlock => {
|
||||
states::basic_block::Data.handle_event(&j, action)
|
||||
},
|
||||
@ -261,6 +266,7 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::GlideWield => states::glide_wield::Data.behavior(&j),
|
||||
CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j),
|
||||
CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, &j),
|
||||
CharacterState::Sneak => states::sneak::Data::behavior(&states::sneak::Data, &j),
|
||||
CharacterState::BasicBlock => states::basic_block::Data.behavior(&j),
|
||||
CharacterState::Roll(data) => data.behavior(&j),
|
||||
CharacterState::Wielding => states::wielding::Data.behavior(&j),
|
||||
|
@ -15,7 +15,7 @@ use specs::{
|
||||
use vek::*;
|
||||
|
||||
pub const GRAVITY: f32 = 9.81 * 5.0;
|
||||
const BOUYANCY: f32 = 0.0;
|
||||
const BOUYANCY: f32 = 1.0;
|
||||
// Friction values used for linear damping. They are unitless quantities. The
|
||||
// value of these quantities must be between zero and one. They represent the
|
||||
// amount an object will slow down within 1/60th of a second. Eg. if the frction
|
||||
|
@ -77,6 +77,7 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::Idle { .. }
|
||||
| CharacterState::Sit { .. }
|
||||
| CharacterState::Dance { .. }
|
||||
| CharacterState::Sneak { .. }
|
||||
| CharacterState::Glide { .. }
|
||||
| CharacterState::GlideWield { .. }
|
||||
| CharacterState::Wielding { .. }
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
|
||||
use common::comp::item::{Hands, ToolKind};
|
||||
use std::f32::consts::PI;
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
|
||||
use vek::*;
|
||||
|
||||
pub struct ClimbAnimation;
|
||||
@ -21,19 +22,20 @@ impl Animation for ClimbAnimation {
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_climb")]
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(active_tool_kind, second_tool_kind, velocity, _orientation, _global_time): Self::Dependency,
|
||||
(active_tool_kind, second_tool_kind, velocity, _orientation, global_time): Self::Dependency,
|
||||
anim_time: f64,
|
||||
rate: &mut f32,
|
||||
skeleton_attr: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let speed = velocity.magnitude();
|
||||
let lateral = Vec2::<f32>::from(velocity).magnitude();
|
||||
let speed = velocity.z;
|
||||
*rate = speed;
|
||||
|
||||
let constant = 1.0;
|
||||
let smooth = (anim_time as f32 * constant as f32 * 1.5).sin();
|
||||
let smootha = (anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin();
|
||||
let drop = (anim_time as f32 * constant as f32 * 4.0 + PI / 2.0).sin();
|
||||
let dropa = (anim_time as f32 * constant as f32 * 4.0).sin();
|
||||
|
||||
let quick = (((5.0)
|
||||
/ (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5).sin()).powf(2.0 as f32)))
|
||||
@ -46,146 +48,269 @@ impl Animation for ClimbAnimation {
|
||||
.powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin());
|
||||
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-4.0 + skeleton_attr.head.0,
|
||||
skeleton_attr.head.1 + smootha * 0.2,
|
||||
let head_look = Vec2::new(
|
||||
((global_time + anim_time) as f32 / 2.0)
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.3,
|
||||
((global_time + anim_time) as f32 / 2.0)
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
* 0.15,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_z(smooth * 0.1)
|
||||
* Quaternion::rotation_x(0.6)
|
||||
* Quaternion::rotation_y(quick * 0.1);
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
let stagnant = if speed > -0.7 { 1.0 } else { 0.0 }; //sets static position when there is no movement
|
||||
if speed > 0.7 || lateral > 0.1 {
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-4.0 + skeleton_attr.head.0,
|
||||
skeleton_attr.head.1 + smootha * 0.2,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_z(smooth * 0.1)
|
||||
* Quaternion::rotation_x(0.6)
|
||||
* Quaternion::rotation_y(quick * 0.1);
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
|
||||
next.chest.offset = Vec3::new(
|
||||
0.0,
|
||||
skeleton_attr.chest.0 + 1.0,
|
||||
skeleton_attr.chest.1 + smootha * 1.1,
|
||||
);
|
||||
next.chest.ori = Quaternion::rotation_z(quick * 0.25)
|
||||
* Quaternion::rotation_x(-0.15)
|
||||
* Quaternion::rotation_y(quick * -0.12);
|
||||
next.chest.scale = Vec3::one();
|
||||
next.chest.offset = Vec3::new(
|
||||
0.0,
|
||||
skeleton_attr.chest.0,
|
||||
skeleton_attr.chest.1 + smootha * 1.1,
|
||||
);
|
||||
next.chest.ori = Quaternion::rotation_z(quick * 0.25)
|
||||
* Quaternion::rotation_x(-0.15)
|
||||
* Quaternion::rotation_y(quick * -0.12);
|
||||
next.chest.scale = Vec3::one();
|
||||
|
||||
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0);
|
||||
next.belt.scale = Vec3::one();
|
||||
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0);
|
||||
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.2);
|
||||
next.back.scale = Vec3::one() * 1.02;
|
||||
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
|
||||
next.back.ori = Quaternion::rotation_x(-0.2);
|
||||
next.back.scale = Vec3::one() * 1.02;
|
||||
|
||||
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1);
|
||||
next.shorts.ori = Quaternion::rotation_z(quick * 0.0)
|
||||
* Quaternion::rotation_x(0.1)
|
||||
* Quaternion::rotation_y(quick * 0.10);
|
||||
next.shorts.scale = Vec3::one();
|
||||
next.shorts.offset =
|
||||
Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1);
|
||||
next.shorts.ori = Quaternion::rotation_z(quick * 0.0)
|
||||
* Quaternion::rotation_x(0.1)
|
||||
* Quaternion::rotation_y(quick * 0.10);
|
||||
next.shorts.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(
|
||||
-skeleton_attr.hand.0,
|
||||
skeleton_attr.hand.1 + quicka * 1.5,
|
||||
5.0 + skeleton_attr.hand.2 - quick * 4.0,
|
||||
);
|
||||
next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5);
|
||||
next.l_hand.scale = Vec3::one();
|
||||
next.l_hand.offset = Vec3::new(
|
||||
-skeleton_attr.hand.0,
|
||||
4.0 + skeleton_attr.hand.1 + quicka * 1.5,
|
||||
5.0 + skeleton_attr.hand.2 - quick * 4.0,
|
||||
);
|
||||
next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5);
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(
|
||||
skeleton_attr.hand.0,
|
||||
skeleton_attr.hand.1 - quicka * 1.5,
|
||||
5.0 + skeleton_attr.hand.2 + quick * 4.0,
|
||||
);
|
||||
next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
next.r_hand.offset = Vec3::new(
|
||||
skeleton_attr.hand.0,
|
||||
5.0 + skeleton_attr.hand.1 - quicka * 1.5,
|
||||
5.0 + skeleton_attr.hand.2 + quick * 4.0,
|
||||
);
|
||||
next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
1.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2 + quick * 2.5,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(0.2 - quicka * 0.5);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
match active_tool_kind {
|
||||
Some(ToolKind::Dagger(_)) => {
|
||||
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
|
||||
next.main.ori =
|
||||
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
|
||||
},
|
||||
Some(ToolKind::Shield(_)) => {
|
||||
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
|
||||
next.main.ori =
|
||||
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
|
||||
},
|
||||
_ => {
|
||||
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
|
||||
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
},
|
||||
}
|
||||
next.main.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
1.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2 - quick * 2.5,
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(0.2 + quicka * 0.5);
|
||||
next.r_foot.scale = Vec3::one();
|
||||
match second_tool_kind {
|
||||
Some(ToolKind::Dagger(_)) => {
|
||||
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
|
||||
next.second.ori =
|
||||
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
|
||||
},
|
||||
Some(ToolKind::Shield(_)) => {
|
||||
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
|
||||
next.second.ori =
|
||||
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
|
||||
},
|
||||
_ => {
|
||||
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
|
||||
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
},
|
||||
}
|
||||
next.second.scale = Vec3::one();
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
5.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2 + quick * 2.5,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(0.2 - quicka * 0.5);
|
||||
next.l_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(smootha * 0.15);
|
||||
next.l_shoulder.scale = Vec3::one() * 1.1;
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
4.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2 - quick * 2.5,
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(0.2 + quicka * 0.5);
|
||||
next.r_foot.scale = Vec3::one();
|
||||
|
||||
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(smooth * 0.15);
|
||||
next.r_shoulder.scale = Vec3::one() * 1.1;
|
||||
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(smootha * 0.15);
|
||||
next.l_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.r_shoulder.offset = Vec3::new(
|
||||
skeleton_attr.shoulder.0,
|
||||
skeleton_attr.shoulder.1,
|
||||
skeleton_attr.shoulder.2,
|
||||
);
|
||||
next.r_shoulder.ori = Quaternion::rotation_x(smooth * 0.15);
|
||||
next.r_shoulder.scale = Vec3::one() * 1.1;
|
||||
|
||||
match active_tool_kind {
|
||||
Some(ToolKind::Dagger(_)) => {
|
||||
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
|
||||
next.main.ori =
|
||||
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
|
||||
},
|
||||
Some(ToolKind::Shield(_)) => {
|
||||
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
|
||||
next.main.ori =
|
||||
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
|
||||
},
|
||||
_ => {
|
||||
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
|
||||
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
},
|
||||
}
|
||||
next.main.scale = Vec3::one();
|
||||
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
|
||||
next.glider.scale = Vec3::one() * 0.0;
|
||||
|
||||
match second_tool_kind {
|
||||
Some(ToolKind::Dagger(_)) => {
|
||||
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
|
||||
next.second.ori =
|
||||
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
|
||||
},
|
||||
Some(ToolKind::Shield(_)) => {
|
||||
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
|
||||
next.second.ori =
|
||||
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
|
||||
},
|
||||
_ => {
|
||||
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
|
||||
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
},
|
||||
}
|
||||
next.second.scale = Vec3::one();
|
||||
next.main.offset = Vec3::new(-7.0, -5.0, 18.0);
|
||||
next.main.ori =
|
||||
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + smootha * 0.25);
|
||||
next.main.scale = Vec3::one();
|
||||
|
||||
next.lantern.offset = Vec3::new(
|
||||
skeleton_attr.lantern.0,
|
||||
skeleton_attr.lantern.1,
|
||||
skeleton_attr.lantern.2,
|
||||
);
|
||||
next.lantern.ori =
|
||||
Quaternion::rotation_x(smooth * -0.3) * Quaternion::rotation_y(smooth * -0.3);
|
||||
next.lantern.scale = Vec3::one() * 0.65;
|
||||
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.second.ori = Quaternion::rotation_y(0.0);
|
||||
next.second.scale = Vec3::one() * 0.0;
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
next.lantern.offset = Vec3::new(
|
||||
skeleton_attr.lantern.0,
|
||||
skeleton_attr.lantern.1,
|
||||
skeleton_attr.lantern.2,
|
||||
);
|
||||
next.lantern.ori =
|
||||
Quaternion::rotation_x(smooth * -0.3) * Quaternion::rotation_y(smooth * -0.3);
|
||||
next.lantern.scale = Vec3::one() * 0.65;
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
} else {
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-1.0 - stagnant + skeleton_attr.head.0,
|
||||
skeleton_attr.head.1,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_x(
|
||||
-0.25 * (1.0 - stagnant) + stagnant * 2.0 * head_look.x.abs(),
|
||||
) * Quaternion::rotation_z(stagnant * 3.5 * head_look.x.abs());
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
|
||||
next.chest.offset = Vec3::new(0.0, 1.0 + skeleton_attr.chest.0, skeleton_attr.chest.1);
|
||||
next.chest.ori = Quaternion::rotation_z(0.6 * stagnant)
|
||||
* Quaternion::rotation_x((0.2 + drop * 0.05) * (1.0 - stagnant));
|
||||
next.chest.scale = Vec3::one();
|
||||
|
||||
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 0.5, skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_x(0.1 + dropa * 0.1);
|
||||
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.2 + dropa * 0.1 - 0.15 * (1.0 - stagnant) + stagnant * 0.1,
|
||||
);
|
||||
next.back.scale = Vec3::one() * 1.02;
|
||||
|
||||
next.shorts.offset =
|
||||
Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1);
|
||||
next.shorts.ori = Quaternion::rotation_x(0.1 + dropa * 0.12 * (1.0 - stagnant));
|
||||
next.shorts.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(
|
||||
-skeleton_attr.hand.0,
|
||||
7.5 + stagnant * -5.0 + skeleton_attr.hand.1,
|
||||
7.0 + stagnant * -7.0 + skeleton_attr.hand.2 + dropa * -1.0 * (1.0 - stagnant),
|
||||
);
|
||||
next.l_hand.ori = Quaternion::rotation_x(2.2 + stagnant * -1.4)
|
||||
* Quaternion::rotation_y((0.3 + dropa * 0.1) * (1.0 - stagnant));
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(
|
||||
skeleton_attr.hand.0,
|
||||
7.5 + stagnant * -2.5 + skeleton_attr.hand.1,
|
||||
5.0 + skeleton_attr.hand.2 + drop * -1.0 * (1.0 - stagnant),
|
||||
);
|
||||
next.r_hand.ori = Quaternion::rotation_x(2.2)
|
||||
* Quaternion::rotation_y(-0.3 + drop * 0.1 * (1.0 - stagnant));
|
||||
next.r_hand.scale = Vec3::one();
|
||||
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
4.0 + stagnant * 3.0 + skeleton_attr.foot.1,
|
||||
1.0 + skeleton_attr.foot.2 + drop * -2.0 * (1.0 - stagnant),
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(0.55 + drop * 0.1 * (1.0 - stagnant));
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
2.0 + stagnant * 4.0 + skeleton_attr.foot.1,
|
||||
-2.0 + skeleton_attr.foot.2 + smooth * 1.0 * (1.0 - stagnant),
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(0.2 + smooth * 0.15 * (1.0 - stagnant));
|
||||
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(0.0);
|
||||
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(0.0);
|
||||
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, -5.0, 18.0);
|
||||
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
next.main.scale = Vec3::one();
|
||||
|
||||
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.second.ori = Quaternion::rotation_y(0.0);
|
||||
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(0.0);
|
||||
next.lantern.scale = Vec3::one() * 0.65;
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, -0.2, 0.4) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
};
|
||||
next.control.scale = Vec3::one();
|
||||
|
||||
next.l_control.scale = Vec3::one();
|
||||
|
||||
next.r_control.scale = Vec3::one();
|
||||
next.l_control.scale = Vec3::one();
|
||||
|
||||
next.second.scale = match (
|
||||
active_tool_kind.map(|tk| tk.hands()),
|
||||
|
@ -16,10 +16,12 @@ pub mod roll;
|
||||
pub mod run;
|
||||
pub mod shoot;
|
||||
pub mod sit;
|
||||
pub mod sneak;
|
||||
pub mod spin;
|
||||
pub mod spinmelee;
|
||||
pub mod stand;
|
||||
pub mod swim;
|
||||
pub mod swimwield;
|
||||
pub mod wield;
|
||||
|
||||
// Reexports
|
||||
@ -29,8 +31,9 @@ pub use self::{
|
||||
dance::DanceAnimation, dash::DashAnimation, equip::EquipAnimation,
|
||||
glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation,
|
||||
jump::JumpAnimation, leapmelee::LeapAnimation, roll::RollAnimation, run::RunAnimation,
|
||||
shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, spinmelee::SpinMeleeAnimation,
|
||||
stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation,
|
||||
shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation, spin::SpinAnimation,
|
||||
spinmelee::SpinMeleeAnimation, stand::StandAnimation, swim::SwimAnimation,
|
||||
swimwield::SwimWieldAnimation, wield::WieldAnimation,
|
||||
};
|
||||
|
||||
use super::{Bone, FigureBoneData, Skeleton};
|
||||
|
@ -48,17 +48,17 @@ impl Animation for RunAnimation {
|
||||
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)
|
||||
let footrotl = (((1.0)
|
||||
/ (0.5
|
||||
+ (0.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)
|
||||
let footrotr = (((1.0)
|
||||
/ (0.5
|
||||
+ (0.5)
|
||||
* ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin())
|
||||
.powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
|
318
voxygen/src/anim/src/character/sneak.rs
Normal file
318
voxygen/src/anim/src/character/sneak.rs
Normal file
@ -0,0 +1,318 @@
|
||||
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
|
||||
use common::comp::item::ToolKind;
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
use vek::*;
|
||||
|
||||
pub struct SneakAnimation;
|
||||
|
||||
impl Animation for SneakAnimation {
|
||||
type Dependency = (Option<ToolKind>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||
type Skeleton = CharacterSkeleton;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
const UPDATE_FN: &'static [u8] = b"character_sneak\0";
|
||||
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_sneak")]
|
||||
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
||||
anim_time: f64,
|
||||
rate: &mut f32,
|
||||
skeleton_attr: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
let mut next = (*skeleton).clone();
|
||||
let speed = Vec2::<f32>::from(velocity).magnitude();
|
||||
*rate = 1.0;
|
||||
let slow = (anim_time as f32 * 3.0).sin();
|
||||
let breathe = ((anim_time as f32 * 0.5).sin()).abs();
|
||||
let walkintensity = if speed > 5.0 { 1.0 } else { 0.45 };
|
||||
let lower = if speed > 5.0 { 0.0 } else { 1.0 };
|
||||
let _snapfoot = if speed > 5.0 { 1.1 } else { 2.0 };
|
||||
let lab = 1.0;
|
||||
let foothoril = (anim_time as f32 * 7.0 * lab as f32 + PI * 1.45).sin();
|
||||
let foothorir = (anim_time as f32 * 7.0 * lab as f32 + PI * (0.45)).sin();
|
||||
|
||||
let footvertl = (anim_time as f32 * 7.0 * lab as f32).sin();
|
||||
let footvertr = (anim_time as f32 * 7.0 * lab as f32 + PI).sin();
|
||||
|
||||
let footrotl = (((5.0)
|
||||
/ (2.5
|
||||
+ (2.5)
|
||||
* ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin());
|
||||
|
||||
let footrotr = (((5.0)
|
||||
/ (1.0
|
||||
+ (4.0)
|
||||
* ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin());
|
||||
|
||||
let short = (anim_time as f32 * lab as f32 * 7.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 = (((5.0)
|
||||
/ (4.0 + 1.0 * ((anim_time as f32 * lab as f32 * 7.0).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * lab as f32 * 7.0).sin());
|
||||
|
||||
let shortalt = (anim_time as f32 * lab as f32 * 7.0 + PI / 2.0).sin();
|
||||
|
||||
let head_look = Vec2::new(
|
||||
((global_time + anim_time) as f32 / 18.0)
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.2,
|
||||
((global_time + anim_time) as f32 / 18.0)
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
* 0.1,
|
||||
);
|
||||
|
||||
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||
let last_ori = Vec2::from(last_ori);
|
||||
let tilt = if Vec2::new(ori, last_ori)
|
||||
.map(|o| o.magnitude_squared())
|
||||
.map(|m| m > 0.001 && m.is_finite())
|
||||
.reduce_and()
|
||||
&& ori.angle_between(last_ori).is_finite()
|
||||
{
|
||||
ori.angle_between(last_ori).min(0.2)
|
||||
* last_ori.determine_side(Vec2::zero(), ori).signum()
|
||||
} else {
|
||||
0.0
|
||||
} * 1.3;
|
||||
|
||||
if speed > 0.5 {
|
||||
next.l_hand.offset = Vec3::new(
|
||||
1.0 - skeleton_attr.hand.0,
|
||||
4.0 + skeleton_attr.hand.1,
|
||||
1.0 + skeleton_attr.hand.2,
|
||||
);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.0);
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(
|
||||
-1.0 + skeleton_attr.hand.0,
|
||||
-1.0 + skeleton_attr.hand.1,
|
||||
skeleton_attr.hand.2,
|
||||
);
|
||||
next.r_hand.ori = Quaternion::rotation_x(0.4);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-4.0 + skeleton_attr.head.0,
|
||||
-1.0 + skeleton_attr.head.1 + short * 0.06,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.06)
|
||||
* Quaternion::rotation_x(head_look.y + 0.45);
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
|
||||
next.chest.offset = Vec3::new(
|
||||
0.0,
|
||||
skeleton_attr.chest.0,
|
||||
-1.0 + skeleton_attr.chest.1 + shortalt * -0.5,
|
||||
);
|
||||
next.chest.ori = Quaternion::rotation_z(0.3 + short * 0.08 + tilt * -0.2)
|
||||
* Quaternion::rotation_y(tilt * 0.8)
|
||||
* Quaternion::rotation_x(-0.5);
|
||||
next.chest.scale = Vec3::one();
|
||||
|
||||
next.belt.offset =
|
||||
Vec3::new(0.0, 0.5 + skeleton_attr.belt.0, 0.7 + skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_z(short * 0.1 + tilt * -1.1)
|
||||
* Quaternion::rotation_y(tilt * 0.5)
|
||||
* Quaternion::rotation_x(0.2);
|
||||
next.belt.scale = Vec3::one();
|
||||
|
||||
next.glider.ori = Quaternion::rotation_x(0.0);
|
||||
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
|
||||
next.glider.scale = Vec3::one() * 0.0;
|
||||
|
||||
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
|
||||
next.back.ori =
|
||||
Quaternion::rotation_x(-0.25 + short * 0.1 + noisea * 0.1 + noiseb * 0.1);
|
||||
next.back.scale = Vec3::one() * 1.02;
|
||||
|
||||
next.shorts.offset = Vec3::new(
|
||||
0.0,
|
||||
1.0 + skeleton_attr.shorts.0,
|
||||
1.0 + skeleton_attr.shorts.1,
|
||||
);
|
||||
next.shorts.ori = Quaternion::rotation_z(short * 0.16 + tilt * -1.5)
|
||||
* Quaternion::rotation_y(tilt * 0.7)
|
||||
* Quaternion::rotation_x(0.3);
|
||||
next.shorts.scale = Vec3::one();
|
||||
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
skeleton_attr.foot.1 + foothoril * -10.5 * walkintensity - lower * 1.0,
|
||||
1.0 + skeleton_attr.foot.2 + ((footvertl * -1.7).max(-1.0)) * walkintensity,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(-0.2 + footrotl * -0.8 * walkintensity)
|
||||
* Quaternion::rotation_y(tilt * 1.8);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
skeleton_attr.foot.1 + foothorir * -10.5 * walkintensity - lower * 1.0,
|
||||
1.0 + skeleton_attr.foot.2 + ((footvertr * -1.7).max(-1.0)) * walkintensity,
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(-0.2 + footrotr * -0.8 * walkintensity)
|
||||
* Quaternion::rotation_y(tilt * 1.8);
|
||||
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(short * 0.15 * walkintensity);
|
||||
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(short * -0.15 * walkintensity);
|
||||
next.r_shoulder.scale = Vec3::one() * 1.1;
|
||||
|
||||
next.main.offset = Vec3::new(-7.0, -6.5, 15.0);
|
||||
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
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.2 + 0.4) * Quaternion::rotation_y(shorte * 0.1);
|
||||
next.lantern.scale = Vec3::one() * 0.65;
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_y(0.0);
|
||||
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();
|
||||
} else {
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-4.0 + skeleton_attr.head.0,
|
||||
-2.0 + skeleton_attr.head.1 + slow * 0.1 + breathe * -0.05,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_z(head_look.x)
|
||||
* Quaternion::rotation_x(0.6 + head_look.y.abs());
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale + breathe * -0.05;
|
||||
|
||||
next.chest.offset = Vec3::new(
|
||||
0.0,
|
||||
skeleton_attr.chest.0,
|
||||
-3.0 + skeleton_attr.chest.1 + slow * 0.1,
|
||||
);
|
||||
next.chest.ori = Quaternion::rotation_x(-0.7);
|
||||
next.chest.scale = Vec3::one() * 1.01 + breathe * 0.03;
|
||||
|
||||
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_z(0.3 + head_look.x * -0.1);
|
||||
next.belt.scale = Vec3::one() + breathe * -0.03;
|
||||
|
||||
next.l_hand.offset = Vec3::new(
|
||||
1.0 - skeleton_attr.hand.0,
|
||||
5.0 + skeleton_attr.hand.1,
|
||||
0.0 + skeleton_attr.hand.2,
|
||||
);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.35);
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(
|
||||
-1.0 + skeleton_attr.hand.0,
|
||||
skeleton_attr.hand.1,
|
||||
skeleton_attr.hand.2,
|
||||
);
|
||||
next.r_hand.ori = Quaternion::rotation_x(0.4);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
|
||||
next.glider.ori = Quaternion::rotation_x(0.35);
|
||||
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
|
||||
next.glider.scale = Vec3::one() * 0.0;
|
||||
|
||||
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(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
|
||||
next.shorts.ori = Quaternion::rotation_z(0.6 + head_look.x * -0.2);
|
||||
next.shorts.scale = Vec3::one() + breathe * -0.03;
|
||||
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
-6.0 + skeleton_attr.foot.1,
|
||||
1.0 + skeleton_attr.foot.2,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(-0.5);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
4.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2,
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(0.0);
|
||||
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.scale = (Vec3::one() + breathe * -0.05) * 1.15;
|
||||
|
||||
next.r_shoulder.offset = Vec3::new(
|
||||
skeleton_attr.shoulder.0,
|
||||
skeleton_attr.shoulder.1,
|
||||
skeleton_attr.shoulder.2,
|
||||
);
|
||||
next.r_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15;
|
||||
|
||||
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
|
||||
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
|
||||
next.main.scale = Vec3::one();
|
||||
|
||||
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
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(0.1) * Quaternion::rotation_y(0.1);
|
||||
next.lantern.scale = Vec3::one() * 0.65;
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(0.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
|
||||
next.control.scale = Vec3::one();
|
||||
|
||||
next.l_control.scale = Vec3::one();
|
||||
|
||||
next.r_control.scale = Vec3::one();
|
||||
}
|
||||
next
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ type SwimAnimationDependency = (
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
f64,
|
||||
Vec3<f32>,
|
||||
);
|
||||
|
||||
impl Animation for SwimAnimation {
|
||||
@ -25,33 +26,50 @@ impl Animation for SwimAnimation {
|
||||
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency,
|
||||
(active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency,
|
||||
anim_time: f64,
|
||||
rate: &mut f32,
|
||||
skeleton_attr: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
let mut next = (*skeleton).clone();
|
||||
let avgspeed = Vec2::<f32>::from(avg_vel).magnitude();
|
||||
|
||||
let speed = Vec2::<f32>::from(velocity).magnitude();
|
||||
let avgtotal = avg_vel.magnitude();
|
||||
|
||||
let speed = velocity.magnitude();
|
||||
*rate = 1.0;
|
||||
let tempo = if speed > 0.5 { 1.5 } else { 0.7 };
|
||||
let intensity = if speed > 0.5 { 1.0 } else { 0.3 };
|
||||
|
||||
let lab = 1.0;
|
||||
let lab = 1.0 * tempo;
|
||||
|
||||
let short = (anim_time as f32 * lab as f32 * 6.0).sin();
|
||||
let short = (anim_time as f32 * lab as f32 * 6.0 + PI * 0.9).sin();
|
||||
|
||||
let shortalt = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin();
|
||||
let foot = (anim_time as f32 * lab as f32 * 6.0 + PI * -0.1).sin();
|
||||
|
||||
let foot = (anim_time as f32 * lab as f32 * 6.0).sin();
|
||||
let footrotl = (((1.0)
|
||||
/ (0.2
|
||||
+ (0.8)
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin());
|
||||
|
||||
let wave_stop = (anim_time as f32 * 9.0).min(PI / 2.0 / 2.0).sin();
|
||||
let footrotr = (((1.0)
|
||||
/ (0.2
|
||||
+ (0.8)
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin());
|
||||
|
||||
let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin();
|
||||
let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.4)).sin();
|
||||
let head_look = Vec2::new(
|
||||
((global_time + anim_time) as f32 / 18.0)
|
||||
((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo))
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.2,
|
||||
((global_time + anim_time) as f32 / 18.0)
|
||||
((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo))
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
@ -65,67 +83,84 @@ impl Animation for SwimAnimation {
|
||||
.reduce_and()
|
||||
&& ori.angle_between(last_ori).is_finite()
|
||||
{
|
||||
ori.angle_between(last_ori).min(0.2)
|
||||
ori.angle_between(last_ori).min(0.8)
|
||||
* last_ori.determine_side(Vec2::zero(), ori).signum()
|
||||
} else {
|
||||
0.0
|
||||
} * 1.3;
|
||||
let abstilt = tilt.abs();
|
||||
|
||||
let squash = if abstilt > 0.2 { 0.35 } else { 1.0 }; //condenses the body at strong turns
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-3.0 + skeleton_attr.head.0,
|
||||
skeleton_attr.head.1 - 1.0 + short * 0.3,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.4)
|
||||
* Quaternion::rotation_x(head_look.y + 0.35 + speed * 0.045);
|
||||
next.head.ori =
|
||||
Quaternion::rotation_z(head_look.x * 0.3 + short * -0.2 * intensity + tilt * 3.0)
|
||||
* Quaternion::rotation_x(
|
||||
(0.4 * head_look.y * (1.0 / intensity)).abs()
|
||||
+ 0.45 * intensity
|
||||
+ velocity.z * 0.03
|
||||
- (abstilt * 1.8).min(0.0),
|
||||
);
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
|
||||
next.chest.offset = Vec3::new(
|
||||
0.0,
|
||||
skeleton_attr.chest.0,
|
||||
skeleton_attr.chest.1 + short * 1.3,
|
||||
-10.0 + skeleton_attr.chest.1 + short * 0.3 * intensity,
|
||||
);
|
||||
next.chest.ori = Quaternion::rotation_z(short * 0.4);
|
||||
next.chest.ori = Quaternion::rotation_z(short * 0.1 * intensity);
|
||||
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_x(velocity.z.abs() * -0.005 + abstilt * 1.0)
|
||||
* Quaternion::rotation_z(short * -0.2 * intensity);
|
||||
next.belt.scale = Vec3::one();
|
||||
|
||||
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(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
|
||||
next.shorts.ori = Quaternion::rotation_x(velocity.z.abs() * -0.005 + abstilt * 1.0)
|
||||
* Quaternion::rotation_z(short * -0.3 * intensity);
|
||||
next.shorts.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(
|
||||
-skeleton_attr.hand.0,
|
||||
1.5 + skeleton_attr.hand.1 - foot * 1.2,
|
||||
2.0 + skeleton_attr.hand.2 + foot * -3.0,
|
||||
-1.0 - skeleton_attr.hand.0,
|
||||
1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity * squash,
|
||||
intensity * 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity * squash,
|
||||
);
|
||||
next.l_hand.ori = Quaternion::rotation_x(0.8 + foot * -0.6) * Quaternion::rotation_y(0.2);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity * squash)
|
||||
* Quaternion::rotation_y(0.4 + foot * -0.35);
|
||||
next.l_hand.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(
|
||||
skeleton_attr.hand.0,
|
||||
1.5 + skeleton_attr.hand.1 + foot * 1.2,
|
||||
2.0 + skeleton_attr.hand.2 + foot * 3.0,
|
||||
1.0 + skeleton_attr.hand.0,
|
||||
1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity * squash,
|
||||
intensity * 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity * squash,
|
||||
);
|
||||
next.r_hand.ori = Quaternion::rotation_x(0.8 + foot * 0.6) * Quaternion::rotation_y(-0.2);
|
||||
next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity * squash)
|
||||
* Quaternion::rotation_y(-0.4 + foot * -0.35);
|
||||
next.r_hand.scale = Vec3::one();
|
||||
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
skeleton_attr.foot.1 + foot * 1.2,
|
||||
-3.0 + skeleton_attr.foot.2 + foot * 3.5,
|
||||
skeleton_attr.foot.1 + foothoril * 1.5 * intensity * squash,
|
||||
-10.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity * squash,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(-1.1 + foot * 0.6);
|
||||
next.l_foot.ori =
|
||||
Quaternion::rotation_x(-0.8 * squash + footrotl * 0.4 * intensity * squash);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
skeleton_attr.foot.1 - foot * 1.2,
|
||||
-3.0 + skeleton_attr.foot.2 + foot * -3.5,
|
||||
skeleton_attr.foot.1 + foothorir * 1.5 * intensity * squash,
|
||||
-10.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity * squash,
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(-1.1 + foot * -0.6);
|
||||
next.r_foot.ori =
|
||||
Quaternion::rotation_x(-0.8 * squash + footrotr * 0.4 * intensity * squash);
|
||||
next.r_foot.scale = Vec3::one();
|
||||
|
||||
next.l_shoulder.offset = Vec3::new(
|
||||
@ -133,7 +168,7 @@ impl Animation for SwimAnimation {
|
||||
skeleton_attr.shoulder.1,
|
||||
skeleton_attr.shoulder.2,
|
||||
);
|
||||
next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15);
|
||||
next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15 * intensity);
|
||||
next.l_shoulder.scale = Vec3::one() * 1.1;
|
||||
|
||||
next.r_shoulder.offset = Vec3::new(
|
||||
@ -141,7 +176,7 @@ impl Animation for SwimAnimation {
|
||||
skeleton_attr.shoulder.1,
|
||||
skeleton_attr.shoulder.2,
|
||||
);
|
||||
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15);
|
||||
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15 * intensity);
|
||||
next.r_shoulder.scale = Vec3::one() * 1.1;
|
||||
|
||||
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
|
||||
@ -190,13 +225,20 @@ impl Animation for SwimAnimation {
|
||||
);
|
||||
next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
|
||||
next.lantern.scale = Vec3::one() * 0.65;
|
||||
|
||||
next.torso.offset = Vec3::new(0.0, -1.2 + shortalt * -0.065, 0.4) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.05)
|
||||
* Quaternion::rotation_z(tilt * 12.0);
|
||||
let switch = if avg_vel.z > 0.0 && avgspeed < 0.5 {
|
||||
avgtotal.min(0.5)
|
||||
} else {
|
||||
avgtotal
|
||||
};
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 1.0 - avgspeed * 0.05) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(
|
||||
(((1.0 / switch) * PI / 2.0 + avg_vel.z * 0.12).min(1.57) - PI / 2.0)
|
||||
+ avgspeed * avg_vel.z * -0.003,
|
||||
) * Quaternion::rotation_y(tilt * 8.0)
|
||||
* Quaternion::rotation_z(tilt * 8.0);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
|
||||
next.control.scale = Vec3::one();
|
||||
next.control.scale = Vec3::one(); //avgspeed*-0.14*reverse +
|
||||
|
||||
next.l_control.scale = Vec3::one();
|
||||
|
||||
|
426
voxygen/src/anim/src/character/swimwield.rs
Normal file
426
voxygen/src/anim/src/character/swimwield.rs
Normal file
@ -0,0 +1,426 @@
|
||||
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
|
||||
use common::comp::item::{Hands, ToolKind};
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
use vek::*;
|
||||
|
||||
pub struct SwimWieldAnimation;
|
||||
|
||||
impl Animation for SwimWieldAnimation {
|
||||
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f64);
|
||||
type Skeleton = CharacterSkeleton;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
const UPDATE_FN: &'static [u8] = b"character_swimwield\0";
|
||||
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_swimwield")]
|
||||
#[allow(clippy::approx_constant)] // TODO: Pending review in #587
|
||||
fn update_skeleton_inner(
|
||||
skeleton: &Self::Skeleton,
|
||||
(active_tool_kind, second_tool_kind, velocity, 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 speed = Vec3::<f32>::from(velocity).magnitude();
|
||||
*rate = 1.0;
|
||||
let intensity = if speed > 0.5 { 1.0 } else { 0.3 };
|
||||
let footrotl = (((1.0)
|
||||
/ (0.2
|
||||
+ (0.8)
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin());
|
||||
|
||||
let footrotr = (((1.0)
|
||||
/ (0.2
|
||||
+ (0.8)
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin());
|
||||
|
||||
let head_look = Vec2::new(
|
||||
((global_time + anim_time) as f32 / 3.0)
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.2,
|
||||
((global_time + anim_time) as f32 / 3.0)
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
* 0.1,
|
||||
);
|
||||
|
||||
let slowalt = (anim_time as f32 * 6.0 + PI).cos();
|
||||
let u_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||
let slow = (anim_time as f32 * 3.0 + PI).sin();
|
||||
let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.45).sin();
|
||||
let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.45)).sin();
|
||||
let u_slowalt = (anim_time as f32 * 3.0 + PI).cos();
|
||||
let short = (((5.0)
|
||||
/ (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32)))
|
||||
.sqrt())
|
||||
* ((anim_time as f32 * lab as f32 * 16.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();
|
||||
|
||||
next.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
skeleton_attr.foot.1 + foothoril * 1.5 * intensity,
|
||||
-10.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity,
|
||||
);
|
||||
next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity);
|
||||
next.l_foot.scale = Vec3::one();
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
skeleton_attr.foot.1 + foothorir * 1.5 * intensity,
|
||||
-10.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity,
|
||||
);
|
||||
next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity);
|
||||
next.r_foot.scale = Vec3::one();
|
||||
if velocity > 0.01 {
|
||||
next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler;
|
||||
next.torso.ori = Quaternion::rotation_x(velocity * -0.05);
|
||||
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||
|
||||
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
|
||||
next.back.ori = Quaternion::rotation_x(
|
||||
(-0.5 + short * 0.3 + noisea * 0.3 + noiseb * 0.3).min(-0.1),
|
||||
);
|
||||
next.back.scale = Vec3::one() * 1.02;
|
||||
} else {
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-2.0 + skeleton_attr.head.0,
|
||||
skeleton_attr.head.1 + u_slow * 0.1,
|
||||
);
|
||||
next.head.ori =
|
||||
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
|
||||
next.chest.offset = Vec3::new(
|
||||
0.0 + slowalt * 0.5,
|
||||
skeleton_attr.chest.0,
|
||||
skeleton_attr.chest.1 + u_slow * 0.5,
|
||||
);
|
||||
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.l_foot.offset = Vec3::new(
|
||||
-skeleton_attr.foot.0,
|
||||
-2.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2,
|
||||
);
|
||||
|
||||
next.r_foot.offset = Vec3::new(
|
||||
skeleton_attr.foot.0,
|
||||
2.0 + skeleton_attr.foot.1,
|
||||
skeleton_attr.foot.2,
|
||||
);
|
||||
|
||||
next.chest.ori =
|
||||
Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.25);
|
||||
|
||||
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22);
|
||||
next.belt.scale = Vec3::one() * 1.02;
|
||||
|
||||
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
|
||||
next.back.ori = Quaternion::rotation_x(-0.2);
|
||||
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(0.3);
|
||||
}
|
||||
match active_tool_kind {
|
||||
//TODO: Inventory
|
||||
Some(ToolKind::Sword(_)) => {
|
||||
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.scale = Vec3::one() * 1.04;
|
||||
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.scale = Vec3::one() * 1.05;
|
||||
next.main.offset = Vec3::new(0.0, 0.0, -3.0);
|
||||
next.main.ori = Quaternion::rotation_x(-0.1)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
|
||||
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
|
||||
next.control.ori = Quaternion::rotation_x(u_slow * 0.15)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(u_slowalt * 0.08);
|
||||
next.control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Dagger(_)) => {
|
||||
// hands should be larger when holding a dagger grip,
|
||||
// also reduce flicker with overlapping polygons
|
||||
let hand_scale = 1.12;
|
||||
|
||||
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
//next.control.ori = Quaternion::rotation_x(slow * 1.0);
|
||||
// * Quaternion::rotation_y(0.0)
|
||||
// * Quaternion::rotation_z(u_slowalt * 0.08);
|
||||
// next.control.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
next.l_hand.scale = Vec3::one() * hand_scale;
|
||||
|
||||
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
|
||||
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
|
||||
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
|
||||
// * Quaternion::rotation_y(0.0)
|
||||
// * Quaternion::rotation_z(u_slowalt * 0.08);
|
||||
// next.l_control.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
next.r_hand.scale = Vec3::one() * hand_scale;
|
||||
|
||||
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.second.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
next.second.scale = Vec3::one();
|
||||
|
||||
next.r_control.offset = Vec3::new(7.0, 0.0, 0.0);
|
||||
// next.r_control.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
// * Quaternion::rotation_y(0.0 * PI)
|
||||
// * Quaternion::rotation_z(0.0 * PI);
|
||||
// next.r_control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Axe(_)) => {
|
||||
if velocity < 0.5 {
|
||||
next.head.offset = Vec3::new(
|
||||
0.0,
|
||||
-3.5 + skeleton_attr.head.0,
|
||||
skeleton_attr.head.1 + u_slow * 0.1,
|
||||
);
|
||||
next.head.ori = Quaternion::rotation_z(head_look.x)
|
||||
* Quaternion::rotation_x(0.35 + head_look.y.abs());
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
next.chest.ori = Quaternion::rotation_x(-0.35)
|
||||
* Quaternion::rotation_y(u_slowalt * 0.04)
|
||||
* Quaternion::rotation_z(0.15);
|
||||
next.belt.offset =
|
||||
Vec3::new(0.0, 1.0 + skeleton_attr.belt.0, skeleton_attr.belt.1);
|
||||
next.belt.ori = Quaternion::rotation_x(0.15)
|
||||
* Quaternion::rotation_y(u_slowalt * 0.03)
|
||||
* Quaternion::rotation_z(0.15);
|
||||
next.shorts.offset =
|
||||
Vec3::new(0.0, 1.0 + skeleton_attr.shorts.0, skeleton_attr.shorts.1);
|
||||
next.shorts.ori = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
|
||||
next.control.ori = Quaternion::rotation_x(1.8)
|
||||
* Quaternion::rotation_y(-0.5)
|
||||
* Quaternion::rotation_z(PI - 0.2);
|
||||
next.control.scale = Vec3::one();
|
||||
} else {
|
||||
next.control.ori = Quaternion::rotation_x(2.1)
|
||||
* Quaternion::rotation_y(-0.4)
|
||||
* Quaternion::rotation_z(PI - 0.2);
|
||||
next.control.scale = Vec3::one();
|
||||
}
|
||||
next.l_hand.offset = Vec3::new(-0.5, 0.0, 4.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(PI / 2.0)
|
||||
* Quaternion::rotation_z(0.0)
|
||||
* Quaternion::rotation_y(0.0);
|
||||
next.l_hand.scale = Vec3::one() * 1.08;
|
||||
next.r_hand.offset = Vec3::new(0.5, 0.0, -2.5);
|
||||
next.r_hand.ori = Quaternion::rotation_x(PI / 2.0)
|
||||
* Quaternion::rotation_z(0.0)
|
||||
* Quaternion::rotation_y(0.0);
|
||||
next.r_hand.scale = Vec3::one() * 1.06;
|
||||
next.main.offset = Vec3::new(-0.0, -2.0, -1.0);
|
||||
next.main.ori = Quaternion::rotation_x(0.0)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
|
||||
next.control.offset = Vec3::new(-3.0, 11.0, 3.0);
|
||||
},
|
||||
Some(ToolKind::Hammer(_)) => {
|
||||
next.l_hand.offset = Vec3::new(-12.0, 0.0, 0.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
|
||||
next.l_hand.scale = Vec3::one() * 1.08;
|
||||
next.r_hand.offset = Vec3::new(2.0, 0.0, 0.0);
|
||||
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
|
||||
next.r_hand.scale = Vec3::one() * 1.06;
|
||||
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.ori = Quaternion::rotation_x(0.0)
|
||||
* Quaternion::rotation_y(-1.57)
|
||||
* Quaternion::rotation_z(1.57);
|
||||
|
||||
next.control.offset = Vec3::new(6.0, 7.0, 1.0);
|
||||
next.control.ori = Quaternion::rotation_x(0.3 + u_slow * 0.15)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(u_slowalt * 0.08);
|
||||
next.control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Staff(_)) => {
|
||||
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.scale = Vec3::one() * 1.05;
|
||||
next.r_hand.offset = Vec3::new(8.0, 4.0, 2.0);
|
||||
next.r_hand.ori = Quaternion::rotation_x(1.8)
|
||||
* Quaternion::rotation_y(0.5)
|
||||
* Quaternion::rotation_z(-0.27);
|
||||
next.r_hand.scale = Vec3::one() * 1.05;
|
||||
next.main.offset = Vec3::new(12.0, 8.4, 13.2);
|
||||
next.main.ori = Quaternion::rotation_x(-0.3)
|
||||
* Quaternion::rotation_y(3.14 + 0.3)
|
||||
* Quaternion::rotation_z(0.9);
|
||||
|
||||
next.control.offset = Vec3::new(-14.0, 1.8, 3.0);
|
||||
next.control.ori = Quaternion::rotation_x(u_slow * 0.2)
|
||||
* Quaternion::rotation_y(-0.2)
|
||||
* Quaternion::rotation_z(u_slowalt * 0.1);
|
||||
next.control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Shield(_)) => {
|
||||
// hands should be larger when holding a dagger grip,
|
||||
// also reduce flicker with overlapping polygons
|
||||
let hand_scale = 1.12;
|
||||
|
||||
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
// next.control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
|
||||
// * Quaternion::rotation_y(0.0)
|
||||
// * Quaternion::rotation_z(u_slowalt * 0.08);
|
||||
// next.control.scale = Vec3::one();
|
||||
|
||||
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
next.l_hand.scale = Vec3::one() * hand_scale;
|
||||
|
||||
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.main.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
|
||||
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
|
||||
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
|
||||
// * Quaternion::rotation_y(0.0)
|
||||
// * Quaternion::rotation_z(u_slowalt * 0.08);
|
||||
// next.l_control.scale = Vec3::one();
|
||||
|
||||
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
next.r_hand.scale = Vec3::one() * hand_scale;
|
||||
|
||||
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
|
||||
next.second.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
* Quaternion::rotation_y(0.0 * PI)
|
||||
* Quaternion::rotation_z(0.0 * PI);
|
||||
next.second.scale = Vec3::one();
|
||||
|
||||
next.r_control.offset = Vec3::new(7.0, 0.0, 0.0);
|
||||
// next.r_control.ori = Quaternion::rotation_x(0.0 * PI)
|
||||
// * Quaternion::rotation_y(0.0 * PI)
|
||||
// * Quaternion::rotation_z(0.0 * PI);
|
||||
// next.r_control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Bow(_)) => {
|
||||
next.l_hand.offset = Vec3::new(2.0, 1.5, 0.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.20)
|
||||
* Quaternion::rotation_y(-0.6)
|
||||
* Quaternion::rotation_z(-0.3);
|
||||
next.l_hand.scale = Vec3::one() * 1.05;
|
||||
next.r_hand.offset = Vec3::new(5.9, 4.5, -5.0);
|
||||
next.r_hand.ori = Quaternion::rotation_x(1.20)
|
||||
* Quaternion::rotation_y(-0.6)
|
||||
* Quaternion::rotation_z(-0.3);
|
||||
next.r_hand.scale = Vec3::one() * 1.05;
|
||||
next.main.offset = Vec3::new(3.0, 2.0, -13.0);
|
||||
next.main.ori = Quaternion::rotation_x(-0.3)
|
||||
* Quaternion::rotation_y(0.3)
|
||||
* Quaternion::rotation_z(-0.6);
|
||||
|
||||
next.hold.offset = Vec3::new(1.2, -1.0, -5.2);
|
||||
next.hold.ori = Quaternion::rotation_x(-1.7)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(-0.1);
|
||||
next.hold.scale = Vec3::one() * 1.0;
|
||||
|
||||
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
|
||||
next.control.ori =
|
||||
Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
|
||||
next.control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Debug(_)) => {
|
||||
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.27)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
next.l_hand.scale = Vec3::one() * 1.01;
|
||||
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
|
||||
next.r_hand.ori = Quaternion::rotation_x(1.27)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(-0.3);
|
||||
next.r_hand.scale = Vec3::one() * 1.01;
|
||||
next.main.offset = Vec3::new(5.0, 8.75, -2.0);
|
||||
next.main.ori = Quaternion::rotation_x(-0.3)
|
||||
* Quaternion::rotation_y(-1.27)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
next.main.scale = Vec3::one();
|
||||
next.control.offset = Vec3::new(0.0, 6.0, 6.0);
|
||||
next.control.ori =
|
||||
Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
|
||||
next.control.scale = Vec3::one();
|
||||
},
|
||||
Some(ToolKind::Farming(_)) => {
|
||||
if velocity < 0.5 {
|
||||
next.head.ori = Quaternion::rotation_z(head_look.x)
|
||||
* Quaternion::rotation_x(-0.2 + head_look.y.abs());
|
||||
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||
}
|
||||
next.l_hand.offset = Vec3::new(9.0, 1.0, 1.0);
|
||||
next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.0);
|
||||
next.l_hand.scale = Vec3::one() * 1.05;
|
||||
next.r_hand.offset = Vec3::new(9.0, 1.0, 11.0);
|
||||
next.r_hand.ori = Quaternion::rotation_x(1.57)
|
||||
* Quaternion::rotation_y(0.0)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
next.r_hand.scale = Vec3::one() * 1.05;
|
||||
next.main.offset = Vec3::new(7.5, 7.5, 13.2);
|
||||
next.main.ori = Quaternion::rotation_x(0.0)
|
||||
* Quaternion::rotation_y(3.14)
|
||||
* Quaternion::rotation_z(0.0);
|
||||
|
||||
next.control.offset = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
|
||||
next.control.ori = Quaternion::rotation_x(u_slow * 0.1)
|
||||
* Quaternion::rotation_y(0.6 + u_slow * 0.1)
|
||||
* Quaternion::rotation_z(u_slowalt * 0.1);
|
||||
next.control.scale = Vec3::one();
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
|
||||
next.l_control.scale = Vec3::one();
|
||||
|
||||
next.r_control.scale = Vec3::one();
|
||||
|
||||
next.second.scale = match (
|
||||
active_tool_kind.map(|tk| tk.hands()),
|
||||
second_tool_kind.map(|tk| tk.hands()),
|
||||
) {
|
||||
(Some(Hands::OneHand), Some(Hands::OneHand)) => Vec3::one(),
|
||||
(_, _) => Vec3::zero(),
|
||||
};
|
||||
|
||||
next
|
||||
}
|
||||
}
|
@ -142,7 +142,7 @@ impl<'a> From<&'a comp::quadruped_low::Body> for SkeletonAttr {
|
||||
(Tortoise, _) => (5.0, 1.0),
|
||||
(Rocksnapper, _) => (6.0, 0.5),
|
||||
(Pangolin, _) => (-0.5, 8.0),
|
||||
(Maneater, _) => (6.0, 9.5),
|
||||
(Maneater, _) => (7.0, 11.5),
|
||||
},
|
||||
head_lower: match (body.species, body.body_type) {
|
||||
(Crocodile, _) => (8.0, 0.0),
|
||||
|
@ -209,7 +209,7 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
|
||||
(Wolf, _) => (5.0, -3.0),
|
||||
(Frostfang, _) => (4.0, -3.0),
|
||||
(Mouflon, _) => (10.5, -4.0),
|
||||
(Catoblepas, _) => (1.0, -6.0),
|
||||
(Catoblepas, _) => (1.0, -4.0),
|
||||
(Bonerattler, _) => (3.0, -3.0),
|
||||
},
|
||||
tail: match (body.species, body.body_type) {
|
||||
|
@ -10,6 +10,7 @@ pub struct KeyState {
|
||||
pub toggle_wield: bool,
|
||||
pub toggle_glide: bool,
|
||||
pub toggle_sit: bool,
|
||||
pub toggle_sneak: bool,
|
||||
pub toggle_dance: bool,
|
||||
pub auto_walk: bool,
|
||||
pub swap_loadout: bool,
|
||||
@ -30,6 +31,7 @@ impl Default for KeyState {
|
||||
toggle_wield: false,
|
||||
toggle_glide: false,
|
||||
toggle_sit: false,
|
||||
toggle_sneak: false,
|
||||
toggle_dance: false,
|
||||
auto_walk: false,
|
||||
swap_loadout: false,
|
||||
|
@ -584,7 +584,7 @@ impl FigureMgr {
|
||||
physics.in_fluid, // In water
|
||||
) {
|
||||
// Standing
|
||||
(true, false, _) => anim::character::StandAnimation::update_skeleton(
|
||||
(true, false, false) => anim::character::StandAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(),
|
||||
(
|
||||
active_tool_kind.clone(),
|
||||
@ -597,7 +597,7 @@ impl FigureMgr {
|
||||
skeleton_attr,
|
||||
),
|
||||
// Running
|
||||
(true, true, _) => anim::character::RunAnimation::update_skeleton(
|
||||
(true, true, false) => anim::character::RunAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(),
|
||||
(
|
||||
active_tool_kind.clone(),
|
||||
@ -627,7 +627,7 @@ impl FigureMgr {
|
||||
skeleton_attr,
|
||||
),
|
||||
// Swim
|
||||
(false, _, true) => anim::character::SwimAnimation::update_skeleton(
|
||||
(_, _, true) => anim::character::SwimAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(),
|
||||
(
|
||||
active_tool_kind.clone(),
|
||||
@ -636,6 +636,7 @@ impl FigureMgr {
|
||||
ori,
|
||||
state.last_ori,
|
||||
time,
|
||||
state.avg_vel,
|
||||
),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
@ -719,6 +720,15 @@ impl FigureMgr {
|
||||
)
|
||||
}
|
||||
},
|
||||
CharacterState::Sneak { .. } => {
|
||||
anim::character::SneakAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(),
|
||||
(active_tool_kind, vel.0, ori, state.last_ori, time),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::Boost(_) => {
|
||||
anim::character::AlphaAnimation::update_skeleton(
|
||||
&target_base,
|
||||
@ -813,13 +823,23 @@ impl FigureMgr {
|
||||
)
|
||||
},
|
||||
CharacterState::Wielding { .. } => {
|
||||
anim::character::WieldAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
if physics.in_fluid {
|
||||
anim::character::SwimWieldAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
} else {
|
||||
anim::character::WieldAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(active_tool_kind, second_tool_kind, vel.0.magnitude(), time),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
}
|
||||
},
|
||||
CharacterState::Glide { .. } => {
|
||||
anim::character::GlidingAnimation::update_skeleton(
|
||||
|
@ -322,8 +322,11 @@ impl PlayState for SessionState {
|
||||
Event::InputUpdate(GameInput::Jump, state) => {
|
||||
self.inputs.jump.set_state(state);
|
||||
},
|
||||
Event::InputUpdate(GameInput::Swim, state) => {
|
||||
self.inputs.swim.set_state(state);
|
||||
Event::InputUpdate(GameInput::SwimUp, state) => {
|
||||
self.inputs.swimup.set_state(state);
|
||||
},
|
||||
Event::InputUpdate(GameInput::SwimDown, state) => {
|
||||
self.inputs.swimdown.set_state(state);
|
||||
},
|
||||
Event::InputUpdate(GameInput::Sit, state)
|
||||
if state != self.key_state.toggle_sit =>
|
||||
@ -344,6 +347,15 @@ impl PlayState for SessionState {
|
||||
self.client.borrow_mut().toggle_dance();
|
||||
}
|
||||
}
|
||||
Event::InputUpdate(GameInput::Sneak, state)
|
||||
if state != self.key_state.toggle_sneak =>
|
||||
{
|
||||
self.key_state.toggle_sneak = state;
|
||||
if state {
|
||||
self.stop_auto_walk();
|
||||
self.client.borrow_mut().toggle_sneak();
|
||||
}
|
||||
}
|
||||
Event::InputUpdate(GameInput::MoveForward, state) => {
|
||||
if state && global_state.settings.gameplay.stop_auto_walk_on_input {
|
||||
self.stop_auto_walk();
|
||||
|
@ -134,7 +134,9 @@ impl ControlSettings {
|
||||
GameInput::Glide => KeyMouse::Key(VirtualKeyCode::LShift),
|
||||
GameInput::Climb => KeyMouse::Key(VirtualKeyCode::Space),
|
||||
GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl),
|
||||
GameInput::Swim => KeyMouse::Key(VirtualKeyCode::Space),
|
||||
GameInput::SwimUp => KeyMouse::Key(VirtualKeyCode::Space),
|
||||
GameInput::SwimDown => KeyMouse::Key(VirtualKeyCode::LShift),
|
||||
GameInput::Sneak => KeyMouse::Key(VirtualKeyCode::LControl),
|
||||
//GameInput::WallLeap => MIDDLE_CLICK_KEY,
|
||||
GameInput::ToggleLantern => KeyMouse::Key(VirtualKeyCode::G),
|
||||
GameInput::Mount => KeyMouse::Key(VirtualKeyCode::F),
|
||||
@ -199,7 +201,9 @@ impl Default for ControlSettings {
|
||||
GameInput::Glide,
|
||||
GameInput::Climb,
|
||||
GameInput::ClimbDown,
|
||||
GameInput::Swim,
|
||||
GameInput::SwimUp,
|
||||
GameInput::SwimDown,
|
||||
GameInput::Sneak,
|
||||
//GameInput::WallLeap,
|
||||
GameInput::ToggleLantern,
|
||||
GameInput::Mount,
|
||||
@ -308,7 +312,9 @@ pub mod con_settings {
|
||||
pub glide: Button,
|
||||
pub climb: Button,
|
||||
pub climb_down: Button,
|
||||
pub swim: Button,
|
||||
pub swimup: Button,
|
||||
pub swimdown: Button,
|
||||
pub sneak: Button,
|
||||
//pub wall_leap: Button,
|
||||
pub toggle_lantern: Button,
|
||||
pub mount: Button,
|
||||
@ -398,7 +404,9 @@ pub mod con_settings {
|
||||
glide: Button::Simple(GilButton::LeftTrigger),
|
||||
climb: Button::Simple(GilButton::South),
|
||||
climb_down: Button::Simple(GilButton::Unknown),
|
||||
swim: Button::Simple(GilButton::South),
|
||||
swimup: Button::Simple(GilButton::South),
|
||||
swimdown: Button::Simple(GilButton::Unknown),
|
||||
sneak: Button::Simple(GilButton::Unknown),
|
||||
//wall_leap: Button::Simple(GilButton::Unknown),
|
||||
toggle_lantern: Button::Simple(GilButton::East),
|
||||
mount: Button::Simple(GilButton::North),
|
||||
|
@ -39,7 +39,9 @@ pub enum GameInput {
|
||||
Glide,
|
||||
Climb,
|
||||
ClimbDown,
|
||||
Swim,
|
||||
SwimUp,
|
||||
SwimDown,
|
||||
Sneak,
|
||||
//WallLeap,
|
||||
ToggleLantern,
|
||||
Mount,
|
||||
@ -88,7 +90,9 @@ impl GameInput {
|
||||
GameInput::Glide => "gameinput.glide",
|
||||
GameInput::Climb => "gameinput.climb",
|
||||
GameInput::ClimbDown => "gameinput.climbdown",
|
||||
GameInput::Swim => "gameinput.swim",
|
||||
GameInput::SwimUp => "gameinput.swimup",
|
||||
GameInput::SwimDown => "gameinput.swimdown",
|
||||
GameInput::Sneak => "gameinput.sneak",
|
||||
//GameInput::WallLeap => "gameinput.wallleap",
|
||||
GameInput::ToggleLantern => "gameinput.togglelantern",
|
||||
GameInput::Mount => "gameinput.mount",
|
||||
@ -147,7 +151,9 @@ impl GameInput {
|
||||
GameInput::Glide,
|
||||
GameInput::Climb,
|
||||
GameInput::ClimbDown,
|
||||
GameInput::Swim,
|
||||
GameInput::SwimUp,
|
||||
GameInput::SwimDown,
|
||||
GameInput::Sneak,
|
||||
GameInput::ToggleLantern,
|
||||
GameInput::Mount,
|
||||
GameInput::Enter,
|
||||
@ -201,7 +207,7 @@ impl GameInput {
|
||||
match self {
|
||||
GameInput::Jump => GameInput::Jump,
|
||||
GameInput::Climb => GameInput::Jump,
|
||||
GameInput::Swim => GameInput::Jump,
|
||||
GameInput::SwimUp => GameInput::Jump,
|
||||
GameInput::Respawn => GameInput::Jump,
|
||||
|
||||
GameInput::FreeLook => GameInput::FreeLook,
|
||||
|
Loading…
Reference in New Issue
Block a user