mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fish_medium and bird_medium skelingtons
This commit is contained in:
parent
ee915671ef
commit
54fc712076
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_body.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_body.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_head.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_head.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_leg_l.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_leg_l.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_leg_r.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_leg_r.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_tail.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_tail.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_wing.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/duck_m/duck_m_wing.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/marlin/marlin_fin_l.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/marlin/marlin_fin_l.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/marlin/marlin_fin_r.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/marlin/marlin_fin_r.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/marlin/marlin_head.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/marlin/marlin_head.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/marlin/marlin_rear.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/marlin/marlin_rear.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/marlin/marlin_tail.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/marlin/marlin_tail.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/marlin/marlin_torso.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/marlin/marlin_torso.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -2,6 +2,8 @@ pub mod humanoid;
|
|||||||
pub mod object;
|
pub mod object;
|
||||||
pub mod quadruped;
|
pub mod quadruped;
|
||||||
pub mod quadruped_medium;
|
pub mod quadruped_medium;
|
||||||
|
pub mod bird_medium;
|
||||||
|
pub mod fish_medium;
|
||||||
|
|
||||||
use specs::{Component, FlaggedStorage};
|
use specs::{Component, FlaggedStorage};
|
||||||
use specs_idvs::IDVStorage;
|
use specs_idvs::IDVStorage;
|
||||||
@ -11,6 +13,8 @@ pub enum Body {
|
|||||||
Humanoid(humanoid::Body),
|
Humanoid(humanoid::Body),
|
||||||
Quadruped(quadruped::Body),
|
Quadruped(quadruped::Body),
|
||||||
QuadrupedMedium(quadruped_medium::Body),
|
QuadrupedMedium(quadruped_medium::Body),
|
||||||
|
BirdMedium(bird_medium::Body),
|
||||||
|
FishMedium(fish_medium::Body),
|
||||||
Object(object::Body),
|
Object(object::Body),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
68
common/src/comp/body/bird_medium.rs
Normal file
68
common/src/comp/body/bird_medium.rs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
use rand::{seq::SliceRandom, thread_rng};
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub struct Body {
|
||||||
|
pub head: Head,
|
||||||
|
pub torso: Torso,
|
||||||
|
pub tail: Tail,
|
||||||
|
pub wing_l: WingL,
|
||||||
|
pub wing_r: WingR,
|
||||||
|
pub leg_l: LegL,
|
||||||
|
pub leg_r: LegR,
|
||||||
|
}
|
||||||
|
impl Body {
|
||||||
|
pub fn random() -> Self {
|
||||||
|
let mut rng = thread_rng();
|
||||||
|
Self {
|
||||||
|
head: *(&ALL_HEADS).choose(&mut rng).unwrap(),
|
||||||
|
torso: *(&ALL_TORSOS).choose(&mut rng).unwrap(),
|
||||||
|
tail: *(&ALL_TAILS).choose(&mut rng).unwrap(),
|
||||||
|
wing_l: *(&ALL_WING_LS).choose(&mut rng).unwrap(),
|
||||||
|
wing_r: *(&ALL_WING_RS).choose(&mut rng).unwrap(),
|
||||||
|
leg_l: *(&ALL_LEG_LS).choose(&mut rng).unwrap(),
|
||||||
|
leg_r: *(&ALL_LEG_RS).choose(&mut rng).unwrap(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Head {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_HEADS: [Head; 1] = [Head::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Torso {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_TORSOS: [Torso; 1] = [Torso::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Tail {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_TAILS: [Tail; 1] = [Tail::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum WingL {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_WING_LS: [WingL; 1] = [WingL::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum WingR {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_WING_RS: [WingR; 1] = [WingR::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum LegL {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_LEG_LS: [LegL; 1] = [LegL::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum LegR {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_LEG_RS: [LegR; 1] = [LegR::Default];
|
61
common/src/comp/body/fish_medium.rs
Normal file
61
common/src/comp/body/fish_medium.rs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
use rand::{seq::SliceRandom, thread_rng};
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub struct Body {
|
||||||
|
pub head: Head,
|
||||||
|
pub torso: Torso,
|
||||||
|
pub rear: Rear,
|
||||||
|
pub tail: Tail,
|
||||||
|
pub fin_l: FinL,
|
||||||
|
pub fin_r: FinR,
|
||||||
|
}
|
||||||
|
impl Body {
|
||||||
|
pub fn random() -> Self {
|
||||||
|
let mut rng = thread_rng();
|
||||||
|
Self {
|
||||||
|
head: *(&ALL_HEADS).choose(&mut rng).unwrap(),
|
||||||
|
torso: *(&ALL_TORSOS).choose(&mut rng).unwrap(),
|
||||||
|
rear: *(&ALL_REARS).choose(&mut rng).unwrap(),
|
||||||
|
tail: *(&ALL_TAILS).choose(&mut rng).unwrap(),
|
||||||
|
fin_l: *(&ALL_FIN_LS).choose(&mut rng).unwrap(),
|
||||||
|
fin_r: *(&ALL_FIN_RS).choose(&mut rng).unwrap(),
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Head {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_HEADS: [Head; 1] = [Head::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Torso {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_TORSOS: [Torso; 1] = [Torso::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Rear {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_REARS: [Rear; 1] = [Rear::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum Tail {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_TAILS: [Tail; 1] = [Tail::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum FinL {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_FIN_LS: [FinL; 1] = [FinL::Default];
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||||
|
pub enum FinR {
|
||||||
|
Default,
|
||||||
|
}
|
||||||
|
const ALL_FIN_RS: [FinR; 1] = [FinR::Default];
|
@ -16,7 +16,7 @@ mod visual;
|
|||||||
// Reexports
|
// Reexports
|
||||||
pub use admin::Admin;
|
pub use admin::Admin;
|
||||||
pub use agent::Agent;
|
pub use agent::Agent;
|
||||||
pub use body::{humanoid, object, quadruped, quadruped_medium, Body};
|
pub use body::{humanoid, object, quadruped, quadruped_medium, bird_medium, fish_medium, Body};
|
||||||
pub use character_state::{ActionState, CharacterState, MovementState};
|
pub use character_state::{ActionState, CharacterState, MovementState};
|
||||||
pub use controller::{
|
pub use controller::{
|
||||||
ControlEvent, Controller, ControllerInputs, InventoryManip, MountState, Mounting,
|
ControlEvent, Controller, ControllerInputs, InventoryManip, MountState, Mounting,
|
||||||
|
@ -30,6 +30,7 @@ impl FromStr for NpcKind {
|
|||||||
"humanoid" => Ok(NpcKind::Humanoid),
|
"humanoid" => Ok(NpcKind::Humanoid),
|
||||||
"wolf" => Ok(NpcKind::Wolf),
|
"wolf" => Ok(NpcKind::Wolf),
|
||||||
"pig" => Ok(NpcKind::Pig),
|
"pig" => Ok(NpcKind::Pig),
|
||||||
|
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
74
voxygen/src/anim/birdmedium/idle.rs
Normal file
74
voxygen/src/anim/birdmedium/idle.rs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
BirdMediumSkeleton,
|
||||||
|
};
|
||||||
|
use std::{f32::consts::PI, ops::Mul};
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct IdleAnimation;
|
||||||
|
|
||||||
|
impl Animation for IdleAnimation {
|
||||||
|
type Skeleton = BirdMediumSkeleton;
|
||||||
|
type Dependency = (f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
global_time: Self::Dependency,
|
||||||
|
anim_time: f64,
|
||||||
|
_rate: &mut f32,
|
||||||
|
_skeleton_attr: &SkeletonAttr,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||||
|
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
|
||||||
|
let wave_slow = (anim_time as f32 * 3.5 + PI).sin();
|
||||||
|
let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos();
|
||||||
|
|
||||||
|
let duck_m_look = Vec2::new(
|
||||||
|
((global_time + anim_time) as f32 / 8.0)
|
||||||
|
.floor()
|
||||||
|
.mul(7331.0)
|
||||||
|
.sin()
|
||||||
|
* 0.5,
|
||||||
|
((global_time + anim_time) as f32 / 8.0)
|
||||||
|
.floor()
|
||||||
|
.mul(1337.0)
|
||||||
|
.sin()
|
||||||
|
* 0.25,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
next.duck_m_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||||
|
next.duck_m_head.ori =
|
||||||
|
Quaternion::rotation_z(duck_m_look.x) * Quaternion::rotation_x(duck_m_look.y);
|
||||||
|
next.duck_m_head.scale = Vec3::one() / 10.88;
|
||||||
|
|
||||||
|
next.duck_m_torso.offset =
|
||||||
|
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||||
|
next.duck_m_torso.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_torso.scale = Vec3::one() * 1.01;
|
||||||
|
|
||||||
|
next.duck_m_tail.offset = Vec3::new(0.0, 3.1, -4.5);
|
||||||
|
next.duck_m_tail.ori = Quaternion::rotation_z(0.0);
|
||||||
|
next.duck_m_tail.scale = Vec3::one() * 0.98;
|
||||||
|
|
||||||
|
next.duck_m_wing_l.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
|
||||||
|
next.duck_m_wing_l.ori = Quaternion::rotation_z(0.0)
|
||||||
|
* Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_wing_l.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.duck_m_wing_r.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
|
||||||
|
next.duck_m_wing_r.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.duck_m_wing_r.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.duck_m_leg_l.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
|
||||||
|
next.duck_m_leg_l.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.duck_m_leg_l.scale = Vec3::one() / 10.5;
|
||||||
|
|
||||||
|
next.duck_m_leg_r.offset = Vec3::new(0.0, 0.75, 5.25);
|
||||||
|
next.duck_m_leg_r.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_leg_r.scale = Vec3::one() * 1.00;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
62
voxygen/src/anim/birdmedium/jump.rs
Normal file
62
voxygen/src/anim/birdmedium/jump.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
BirdMediumSkeleton,
|
||||||
|
};
|
||||||
|
use std::f32::consts::PI;
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct JumpAnimation;
|
||||||
|
|
||||||
|
impl Animation for JumpAnimation {
|
||||||
|
type Skeleton = BirdMediumSkeleton;
|
||||||
|
type Dependency = (f32, f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
_global_time: Self::Dependency,
|
||||||
|
anim_time: f64,
|
||||||
|
_rate: &mut f32,
|
||||||
|
_skeleton_attr: &SkeletonAttr,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||||
|
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
|
||||||
|
let wave_slow = (anim_time as f32 * 3.5 + PI).sin();
|
||||||
|
let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
next.duck_m_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||||
|
next.duck_m_head.ori =
|
||||||
|
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_head.scale = Vec3::one() / 10.88;
|
||||||
|
|
||||||
|
next.duck_m_torso.offset =
|
||||||
|
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||||
|
next.duck_m_torso.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_torso.scale = Vec3::one() * 1.01;
|
||||||
|
|
||||||
|
next.duck_m_tail.offset = Vec3::new(0.0, 3.1, -4.5);
|
||||||
|
next.duck_m_tail.ori = Quaternion::rotation_z(0.0);
|
||||||
|
next.duck_m_tail.scale = Vec3::one() * 0.98;
|
||||||
|
|
||||||
|
next.duck_m_wing_l.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
|
||||||
|
next.duck_m_wing_l.ori = Quaternion::rotation_z(0.0)
|
||||||
|
* Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_wing_l.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.duck_m_wing_r.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
|
||||||
|
next.duck_m_wing_r.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.duck_m_wing_r.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.duck_m_leg_l.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
|
||||||
|
next.duck_m_leg_l.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.duck_m_leg_l.scale = Vec3::one() / 10.5;
|
||||||
|
|
||||||
|
next.duck_m_leg_r.offset = Vec3::new(0.0, 0.75, 5.25);
|
||||||
|
next.duck_m_leg_r.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_leg_r.scale = Vec3::one() * 1.00;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
80
voxygen/src/anim/birdmedium/mod.rs
Normal file
80
voxygen/src/anim/birdmedium/mod.rs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
pub mod idle;
|
||||||
|
pub mod jump;
|
||||||
|
pub mod run;
|
||||||
|
|
||||||
|
// Reexports
|
||||||
|
pub use self::idle::IdleAnimation;
|
||||||
|
pub use self::jump::JumpAnimation;
|
||||||
|
pub use self::run::RunAnimation;
|
||||||
|
|
||||||
|
use super::{Bone, Skeleton};
|
||||||
|
use crate::render::FigureBoneData;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct BirdMediumSkeleton {
|
||||||
|
duck_m_head: Bone,
|
||||||
|
duck_m_torso: Bone,
|
||||||
|
duck_m_tail: Bone,
|
||||||
|
duck_m_wing_l: Bone,
|
||||||
|
duck_m_wing_r: Bone,
|
||||||
|
duck_m_leg_l: Bone,
|
||||||
|
duck_m_leg_r: Bone,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BirdMediumSkeleton {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
duck_m_head: Bone::default(),
|
||||||
|
duck_m_torso: Bone::default(),
|
||||||
|
duck_m_tail: Bone::default(),
|
||||||
|
duck_m_wing_l: Bone::default(),
|
||||||
|
duck_m_wing_r: Bone::default(),
|
||||||
|
duck_m_leg_l: Bone::default(),
|
||||||
|
duck_m_leg_r: Bone::default(),
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Skeleton for BirdMediumSkeleton {
|
||||||
|
fn compute_matrices(&self) -> [FigureBoneData; 16] {
|
||||||
|
let torso_mat = self.duck_m_torso.compute_base_matrix();
|
||||||
|
|
||||||
|
|
||||||
|
[
|
||||||
|
FigureBoneData::new(self.duck_m_head.compute_base_matrix() * torso_mat),
|
||||||
|
FigureBoneData::new(
|
||||||
|
torso_mat,
|
||||||
|
),
|
||||||
|
FigureBoneData::new(self.duck_m_tail.compute_base_matrix() * torso_mat),
|
||||||
|
FigureBoneData::new(self.duck_m_wing_l.compute_base_matrix() * torso_mat),
|
||||||
|
FigureBoneData::new(self.duck_m_wing_r.compute_base_matrix() * torso_mat),
|
||||||
|
FigureBoneData::new(self.duck_m_leg_l.compute_base_matrix()),
|
||||||
|
FigureBoneData::new(self.duck_m_leg_r.compute_base_matrix()),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn interpolate(&mut self, target: &Self, dt: f32) {
|
||||||
|
self.duck_m_head
|
||||||
|
.interpolate(&target.duck_m_head, dt);
|
||||||
|
self.duck_m_torso.interpolate(&target.duck_m_torso, dt);
|
||||||
|
self.duck_m_tail
|
||||||
|
.interpolate(&target.duck_m_tail, dt);
|
||||||
|
self.duck_m_wing_l.interpolate(&target.duck_m_wing_l, dt);
|
||||||
|
self.duck_m_wing_r
|
||||||
|
.interpolate(&target.duck_m_wing_r, dt);
|
||||||
|
self.duck_m_leg_l.interpolate(&target.duck_m_leg_l, dt);
|
||||||
|
self.duck_m_leg_r.interpolate(&target.duck_m_leg_r, dt);
|
||||||
|
}
|
||||||
|
}
|
74
voxygen/src/anim/birdmedium/run.rs
Normal file
74
voxygen/src/anim/birdmedium/run.rs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
BirdMediumSkeleton,
|
||||||
|
};
|
||||||
|
use std::{f32::consts::PI, ops::Mul};
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct RunAnimation;
|
||||||
|
|
||||||
|
impl Animation for RunAnimation {
|
||||||
|
type Skeleton = BirdMediumSkeleton;
|
||||||
|
type Dependency = (f32, f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
(_velocity, global_time): Self::Dependency,
|
||||||
|
anim_time: f64,
|
||||||
|
_rate: &mut f32,
|
||||||
|
_skeleton_attr: &SkeletonAttr,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||||
|
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
|
||||||
|
let wave_slow = (anim_time as f32 * 3.5 + PI).sin();
|
||||||
|
let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos();
|
||||||
|
|
||||||
|
let duck_look = Vec2::new(
|
||||||
|
((global_time + anim_time) as f32 / 8.0)
|
||||||
|
.floor()
|
||||||
|
.mul(7331.0)
|
||||||
|
.sin()
|
||||||
|
* 0.5,
|
||||||
|
((global_time + anim_time) as f32 / 8.0)
|
||||||
|
.floor()
|
||||||
|
.mul(1337.0)
|
||||||
|
.sin()
|
||||||
|
* 0.25,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
next.duck_m_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||||
|
next.duck_m_head.ori =
|
||||||
|
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_head.scale = Vec3::one() / 10.88;
|
||||||
|
|
||||||
|
next.duck_m_torso.offset =
|
||||||
|
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||||
|
next.duck_m_torso.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_torso.scale = Vec3::one() * 1.01;
|
||||||
|
|
||||||
|
next.duck_m_tail.offset = Vec3::new(0.0, 3.1, -4.5);
|
||||||
|
next.duck_m_tail.ori = Quaternion::rotation_z(0.0);
|
||||||
|
next.duck_m_tail.scale = Vec3::one() * 0.98;
|
||||||
|
|
||||||
|
next.duck_m_wing_l.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
|
||||||
|
next.duck_m_wing_l.ori = Quaternion::rotation_z(0.0)
|
||||||
|
* Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_wing_l.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.duck_m_wing_r.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
|
||||||
|
next.duck_m_wing_r.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.duck_m_wing_r.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.duck_m_leg_l.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
|
||||||
|
next.duck_m_leg_l.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.duck_m_leg_l.scale = Vec3::one() / 10.5;
|
||||||
|
|
||||||
|
next.duck_m_leg_r.offset = Vec3::new(0.0, 0.75, 5.25);
|
||||||
|
next.duck_m_leg_r.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.duck_m_leg_r.scale = Vec3::one() * 1.00;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
147
voxygen/src/anim/character/run - Copy.rs
Normal file
147
voxygen/src/anim/character/run - Copy.rs
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
CharacterSkeleton,
|
||||||
|
};
|
||||||
|
use std::f32::consts::PI;
|
||||||
|
use std::ops::Mul;
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct SneakAnimation;
|
||||||
|
|
||||||
|
impl Animation for SneakAnimation {
|
||||||
|
type Skeleton = CharacterSkeleton;
|
||||||
|
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
(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 = speed;
|
||||||
|
|
||||||
|
let constant = 1.0;
|
||||||
|
let wave = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.2).sin());
|
||||||
|
let wave_cos = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.5).sin());
|
||||||
|
let wave_cos_dub = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.8).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.5).sin());
|
||||||
|
|
||||||
|
let wave_diff = (anim_time as f32 * 0.6).sin();
|
||||||
|
let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin();
|
||||||
|
let head_look = Vec2::new(
|
||||||
|
((global_time + anim_time) as f32 / 4.0)
|
||||||
|
.floor()
|
||||||
|
.mul(7331.0)
|
||||||
|
.sin()
|
||||||
|
* 0.2,
|
||||||
|
((global_time + anim_time) as f32 / 4.0)
|
||||||
|
.floor()
|
||||||
|
.mul(1337.0)
|
||||||
|
.sin()
|
||||||
|
* 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.5)
|
||||||
|
* last_ori.determine_side(Vec2::zero(), ori).signum()
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
} * 1.3;
|
||||||
|
|
||||||
|
next.head.offset = Vec3::new(
|
||||||
|
0.0,
|
||||||
|
-3.0 + skeleton_attr.neck_forward,
|
||||||
|
skeleton_attr.neck_height + 20.0 + wave_cos * 1.3,
|
||||||
|
);
|
||||||
|
next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1)
|
||||||
|
* Quaternion::rotation_x(head_look.y + 0.35);
|
||||||
|
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||||
|
|
||||||
|
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + wave_cos * 1.1);
|
||||||
|
next.chest.ori = Quaternion::rotation_z(wave * 0.2);
|
||||||
|
next.chest.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.belt.offset = Vec3::new(0.0, 0.0, 5.0 + wave_cos * 1.1);
|
||||||
|
next.belt.ori = Quaternion::rotation_z(wave * 0.35);
|
||||||
|
next.belt.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.shorts.offset = Vec3::new(0.0, 0.0, 2.0 + wave_cos * 1.1);
|
||||||
|
next.shorts.ori = Quaternion::rotation_z(wave * 0.6);
|
||||||
|
next.shorts.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_hand.offset = Vec3::new(
|
||||||
|
-6.0 + wave_stop * -1.0,
|
||||||
|
-0.25 + wave_cos * 2.0,
|
||||||
|
5.0 - wave * 1.5,
|
||||||
|
);
|
||||||
|
next.l_hand.ori =
|
||||||
|
Quaternion::rotation_x(0.8 + wave_cos * 1.2) * Quaternion::rotation_y(wave_stop * 0.1);
|
||||||
|
next.l_hand.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.r_hand.offset = Vec3::new(
|
||||||
|
6.0 + wave_stop * 1.0,
|
||||||
|
-0.25 - wave_cos * 2.0,
|
||||||
|
5.0 + wave * 1.5,
|
||||||
|
);
|
||||||
|
next.r_hand.ori = Quaternion::rotation_x(0.8 + wave_cos * -1.2)
|
||||||
|
* Quaternion::rotation_y(wave_stop * -0.1);
|
||||||
|
next.r_hand.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_foot.offset = Vec3::new(-3.4, 0.0 + wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7);
|
||||||
|
next.l_foot.ori = Quaternion::rotation_x(-0.0 - wave_cos * 1.2);
|
||||||
|
next.l_foot.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.r_foot.offset = Vec3::new(3.4, 0.0 - wave_cos * 1.0, 6.0 - wave_cos_dub * 0.7);
|
||||||
|
next.r_foot.ori = Quaternion::rotation_x(-0.0 + wave_cos * 1.2);
|
||||||
|
next.r_foot.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.weapon.offset = Vec3::new(
|
||||||
|
-7.0 + skeleton_attr.weapon_x,
|
||||||
|
-5.0 + skeleton_attr.weapon_y,
|
||||||
|
15.0,
|
||||||
|
);
|
||||||
|
next.weapon.ori =
|
||||||
|
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25);
|
||||||
|
next.weapon.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
|
||||||
|
next.l_shoulder.ori = Quaternion::rotation_x(wave_cos * 0.15);
|
||||||
|
next.l_shoulder.scale = Vec3::one() * 1.1;
|
||||||
|
|
||||||
|
next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7);
|
||||||
|
next.r_shoulder.ori = Quaternion::rotation_x(wave * 0.15);
|
||||||
|
next.r_shoulder.scale = Vec3::one() * 1.1;
|
||||||
|
|
||||||
|
next.draw.offset = Vec3::new(0.0, 5.0, 0.0);
|
||||||
|
next.draw.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.draw.scale = Vec3::one() * 0.0;
|
||||||
|
|
||||||
|
next.torso.offset = Vec3::new(0.0, 0.3 + wave * -0.08, 0.4) * skeleton_attr.scaler;
|
||||||
|
next.torso.ori =
|
||||||
|
Quaternion::rotation_x(wave_stop * speed * -0.06 + wave_diff * speed * -0.005)
|
||||||
|
* Quaternion::rotation_y(tilt);
|
||||||
|
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||||
|
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
151
voxygen/src/anim/character/sneak.rs
Normal file
151
voxygen/src/anim/character/sneak.rs
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
CharacterSkeleton,
|
||||||
|
};
|
||||||
|
use std::f32::consts::PI;
|
||||||
|
use std::ops::Mul;
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct SneakAnimation;
|
||||||
|
|
||||||
|
impl Animation for SneakAnimation {
|
||||||
|
type Skeleton = CharacterSkeleton;
|
||||||
|
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
(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 = speed;
|
||||||
|
|
||||||
|
let constant = 1.0;
|
||||||
|
let wave = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.2).sin());
|
||||||
|
let wavecos = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 1.2).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.2).cos());
|
||||||
|
let wave_cos = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 2.4).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.5).sin());
|
||||||
|
let wave_cos_dub = (((5.0)
|
||||||
|
/ (1.1 + 3.9 * ((anim_time as f32 * constant as f32 * 4.8).sin()).powf(2.0 as f32)))
|
||||||
|
.sqrt())
|
||||||
|
* ((anim_time as f32 * constant as f32 * 1.5).sin());
|
||||||
|
let wave_slow = (anim_time as f32 * 0.1).sin();
|
||||||
|
let wave_diff = (anim_time as f32 * 0.6).sin();
|
||||||
|
let wave_stop = (anim_time as f32 * 2.6).min(PI / 2.0).sin();
|
||||||
|
let head_look = Vec2::new(
|
||||||
|
((global_time + anim_time) as f32 *0.25)
|
||||||
|
.floor()
|
||||||
|
.mul(7331.0)
|
||||||
|
.sin()
|
||||||
|
* 0.4,
|
||||||
|
((global_time + anim_time) as f32 *0.25)
|
||||||
|
.floor()
|
||||||
|
.mul(1337.0)
|
||||||
|
.sin()
|
||||||
|
* 0.2,
|
||||||
|
);
|
||||||
|
|
||||||
|
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.5)
|
||||||
|
* last_ori.determine_side(Vec2::zero(), ori).signum()
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
} * 1.3;
|
||||||
|
|
||||||
|
next.head.offset = Vec3::new(
|
||||||
|
0.0,
|
||||||
|
0.0 + skeleton_attr.neck_forward,
|
||||||
|
skeleton_attr.neck_height + 16.0,
|
||||||
|
);
|
||||||
|
next.head.ori = Quaternion::rotation_z(head_look.x + wave * 0.1)
|
||||||
|
* Quaternion::rotation_x(head_look.y + 0.05);
|
||||||
|
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
|
||||||
|
|
||||||
|
next.chest.offset = Vec3::new(0.0, -1.5, 3.0 +wave_slow * 2.0);
|
||||||
|
next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(wave * 0.15);
|
||||||
|
next.chest.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.belt.offset = Vec3::new(0.0, 0.0, 1.5 + wave_cos * 0.3);
|
||||||
|
next.belt.ori = Quaternion::rotation_x(-0.1) * Quaternion::rotation_z(wave * 0.25);
|
||||||
|
next.belt.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.shorts.offset = Vec3::new(0.0, 1.0, -1.0 + wave_cos * 0.3);
|
||||||
|
next.shorts.ori = Quaternion::rotation_x(0.2) *Quaternion::rotation_z(wave * 0.4);
|
||||||
|
next.shorts.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_hand.offset = Vec3::new(
|
||||||
|
-5.0 + wave_stop * -0.5,
|
||||||
|
2.25,
|
||||||
|
4.0 - wave * 1.0,
|
||||||
|
);
|
||||||
|
next.l_hand.ori =
|
||||||
|
Quaternion::rotation_x(1.5 + wave_cos * 0.1) * Quaternion::rotation_y(wave_stop * 0.1);
|
||||||
|
next.l_hand.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.r_hand.offset = Vec3::new(
|
||||||
|
5.0 + wave_stop * 0.5,
|
||||||
|
2.25,
|
||||||
|
4.0 + wave * 1.0,
|
||||||
|
);
|
||||||
|
next.r_hand.ori = Quaternion::rotation_x(1.5 + wave_cos * -0.1)
|
||||||
|
* Quaternion::rotation_y(wave_stop * -0.1);
|
||||||
|
next.r_hand.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_foot.offset = Vec3::new(-3.4, 5.0+ wave * -3.0, 4.0);
|
||||||
|
next.l_foot.ori = Quaternion::rotation_x(-0.8 + wavecos * 0.15);
|
||||||
|
next.l_foot.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.r_foot.offset = Vec3::new(3.4, 5.0+ wave * 3.0, 4.0);
|
||||||
|
next.r_foot.ori = Quaternion::rotation_x(-0.8 - wavecos * 0.15);
|
||||||
|
next.r_foot.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.weapon.offset = Vec3::new(
|
||||||
|
-7.0 + skeleton_attr.weapon_x,
|
||||||
|
-5.0 + skeleton_attr.weapon_y,
|
||||||
|
15.0,
|
||||||
|
);
|
||||||
|
next.weapon.ori =
|
||||||
|
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + wave_cos * 0.25);
|
||||||
|
next.weapon.scale = Vec3::one();
|
||||||
|
|
||||||
|
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
|
||||||
|
next.l_shoulder.ori = Quaternion::rotation_x(wavecos * 0.05);
|
||||||
|
next.l_shoulder.scale = Vec3::one() * 1.1;
|
||||||
|
|
||||||
|
next.r_shoulder.offset = Vec3::new(5.0, 0.0, 4.7);
|
||||||
|
next.r_shoulder.ori = Quaternion::rotation_x(wave * 0.05);
|
||||||
|
next.r_shoulder.scale = Vec3::one() * 1.1;
|
||||||
|
|
||||||
|
next.draw.offset = Vec3::new(0.0, 5.0, 0.0);
|
||||||
|
next.draw.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.draw.scale = Vec3::one() * 0.0;
|
||||||
|
|
||||||
|
next.torso.offset = Vec3::new(0.0, 0.3 + wave * -0.08, 0.4) * skeleton_attr.scaler;
|
||||||
|
next.torso.ori =
|
||||||
|
Quaternion::rotation_x(wave_stop * speed * -0.03 + wave_diff * speed * -0.005)
|
||||||
|
* Quaternion::rotation_y(tilt);
|
||||||
|
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
|
||||||
|
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
70
voxygen/src/anim/fishmedium/idle.rs
Normal file
70
voxygen/src/anim/fishmedium/idle.rs
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
FishMediumSkeleton,
|
||||||
|
};
|
||||||
|
use std::{f32::consts::PI, ops::Mul};
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct IdleAnimation;
|
||||||
|
|
||||||
|
impl Animation for IdleAnimation {
|
||||||
|
type Skeleton = FishMediumSkeleton;
|
||||||
|
type Dependency = (f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
global_time: Self::Dependency,
|
||||||
|
anim_time: f64,
|
||||||
|
_rate: &mut f32,
|
||||||
|
_skeleton_attr: &SkeletonAttr,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||||
|
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
|
||||||
|
let wave_slow = (anim_time as f32 * 3.5 + PI).sin();
|
||||||
|
let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos();
|
||||||
|
|
||||||
|
let duck_m_look = Vec2::new(
|
||||||
|
((global_time + anim_time) as f32 / 8.0)
|
||||||
|
.floor()
|
||||||
|
.mul(7331.0)
|
||||||
|
.sin()
|
||||||
|
* 0.5,
|
||||||
|
((global_time + anim_time) as f32 / 8.0)
|
||||||
|
.floor()
|
||||||
|
.mul(1337.0)
|
||||||
|
.sin()
|
||||||
|
* 0.25,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
next.marlin_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||||
|
next.marlin_head.ori =
|
||||||
|
Quaternion::rotation_z(duck_m_look.x) * Quaternion::rotation_x(duck_m_look.y);
|
||||||
|
next.marlin_head.scale = Vec3::one() / 10.88;
|
||||||
|
|
||||||
|
next.marlin_torso.offset =
|
||||||
|
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||||
|
next.marlin_torso.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_torso.scale = Vec3::one() * 1.01;
|
||||||
|
|
||||||
|
next.marlin_rear.offset = Vec3::new(0.0, 3.1, -4.5);
|
||||||
|
next.marlin_rear.ori = Quaternion::rotation_z(0.0);
|
||||||
|
next.marlin_rear.scale = Vec3::one() * 0.98;
|
||||||
|
|
||||||
|
next.marlin_tail.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
|
||||||
|
next.marlin_tail.ori = Quaternion::rotation_z(0.0)
|
||||||
|
* Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_tail.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.marlin_fin_l.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
|
||||||
|
next.marlin_fin_l.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.marlin_fin_l.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.marlin_fin_r.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
|
||||||
|
next.marlin_fin_r.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.marlin_fin_r.scale = Vec3::one() / 10.5;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
58
voxygen/src/anim/fishmedium/jump.rs
Normal file
58
voxygen/src/anim/fishmedium/jump.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
FishMediumSkeleton,
|
||||||
|
};
|
||||||
|
use std::f32::consts::PI;
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct JumpAnimation;
|
||||||
|
|
||||||
|
impl Animation for JumpAnimation {
|
||||||
|
type Skeleton = FishMediumSkeleton;
|
||||||
|
type Dependency = (f32, f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
global_time: Self::Dependency,
|
||||||
|
anim_time: f64,
|
||||||
|
_rate: &mut f32,
|
||||||
|
_skeleton_attr: &SkeletonAttr,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||||
|
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
|
||||||
|
let wave_slow = (anim_time as f32 * 3.5 + PI).sin();
|
||||||
|
let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
next.marlin_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||||
|
next.marlin_head.ori =
|
||||||
|
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_head.scale = Vec3::one() / 10.88;
|
||||||
|
|
||||||
|
next.marlin_torso.offset =
|
||||||
|
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||||
|
next.marlin_torso.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_torso.scale = Vec3::one() * 1.01;
|
||||||
|
|
||||||
|
next.marlin_rear.offset = Vec3::new(0.0, 3.1, -4.5);
|
||||||
|
next.marlin_rear.ori = Quaternion::rotation_z(0.0);
|
||||||
|
next.marlin_rear.scale = Vec3::one() * 0.98;
|
||||||
|
|
||||||
|
next.marlin_tail.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
|
||||||
|
next.marlin_tail.ori = Quaternion::rotation_z(0.0)
|
||||||
|
* Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_tail.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.marlin_fin_l.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
|
||||||
|
next.marlin_fin_l.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.marlin_fin_l.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.marlin_fin_r.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
|
||||||
|
next.marlin_fin_r.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.marlin_fin_r.scale = Vec3::one() / 10.5;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
77
voxygen/src/anim/fishmedium/mod.rs
Normal file
77
voxygen/src/anim/fishmedium/mod.rs
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
pub mod idle;
|
||||||
|
pub mod jump;
|
||||||
|
pub mod run;
|
||||||
|
|
||||||
|
// Reexports
|
||||||
|
pub use self::idle::IdleAnimation;
|
||||||
|
pub use self::jump::JumpAnimation;
|
||||||
|
pub use self::run::RunAnimation;
|
||||||
|
|
||||||
|
use super::{Bone, Skeleton};
|
||||||
|
use crate::render::FigureBoneData;
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct FishMediumSkeleton {
|
||||||
|
marlin_head: Bone,
|
||||||
|
marlin_torso: Bone,
|
||||||
|
marlin_rear: Bone,
|
||||||
|
marlin_tail: Bone,
|
||||||
|
marlin_fin_l: Bone,
|
||||||
|
marlin_fin_r: Bone,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FishMediumSkeleton {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
marlin_head: Bone::default(),
|
||||||
|
marlin_torso: Bone::default(),
|
||||||
|
marlin_rear: Bone::default(),
|
||||||
|
marlin_tail: Bone::default(),
|
||||||
|
marlin_fin_l: Bone::default(),
|
||||||
|
marlin_fin_r: Bone::default(),
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Skeleton for FishMediumSkeleton {
|
||||||
|
fn compute_matrices(&self) -> [FigureBoneData; 16] {
|
||||||
|
let torso_mat = self.marlin_torso.compute_base_matrix();
|
||||||
|
let rear_mat = self.marlin_rear.compute_base_matrix();
|
||||||
|
|
||||||
|
|
||||||
|
[
|
||||||
|
FigureBoneData::new(self.marlin_head.compute_base_matrix() * torso_mat),
|
||||||
|
FigureBoneData::new(
|
||||||
|
torso_mat,
|
||||||
|
),
|
||||||
|
FigureBoneData::new(rear_mat * torso_mat),
|
||||||
|
FigureBoneData::new(self.marlin_tail.compute_base_matrix() * rear_mat),
|
||||||
|
FigureBoneData::new(self.marlin_fin_l.compute_base_matrix() * rear_mat),
|
||||||
|
FigureBoneData::new(self.marlin_fin_r.compute_base_matrix() * rear_mat),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
FigureBoneData::default(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
fn interpolate(&mut self, target: &Self, dt: f32) {
|
||||||
|
self.marlin_head
|
||||||
|
.interpolate(&target.marlin_head, dt);
|
||||||
|
self.marlin_torso.interpolate(&target.marlin_torso, dt);
|
||||||
|
self.marlin_rear
|
||||||
|
.interpolate(&target.marlin_rear, dt);
|
||||||
|
self.marlin_tail.interpolate(&target.marlin_tail, dt);
|
||||||
|
self.marlin_fin_l
|
||||||
|
.interpolate(&target.marlin_fin_l, dt);
|
||||||
|
self.marlin_fin_r.interpolate(&target.marlin_fin_r, dt);
|
||||||
|
}
|
||||||
|
}
|
58
voxygen/src/anim/fishmedium/run.rs
Normal file
58
voxygen/src/anim/fishmedium/run.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
use super::{
|
||||||
|
super::{Animation, SkeletonAttr},
|
||||||
|
FishMediumSkeleton,
|
||||||
|
};
|
||||||
|
use std::{f32::consts::PI};
|
||||||
|
use vek::*;
|
||||||
|
|
||||||
|
pub struct RunAnimation;
|
||||||
|
|
||||||
|
impl Animation for RunAnimation {
|
||||||
|
type Skeleton = FishMediumSkeleton;
|
||||||
|
type Dependency = (f32, f64);
|
||||||
|
|
||||||
|
fn update_skeleton(
|
||||||
|
skeleton: &Self::Skeleton,
|
||||||
|
global_time: Self::Dependency,
|
||||||
|
anim_time: f64,
|
||||||
|
_rate: &mut f32,
|
||||||
|
_skeleton_attr: &SkeletonAttr,
|
||||||
|
) -> Self::Skeleton {
|
||||||
|
let mut next = (*skeleton).clone();
|
||||||
|
|
||||||
|
let wave_ultra_slow = (anim_time as f32 * 1.0 + PI).sin();
|
||||||
|
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI).cos();
|
||||||
|
let wave_slow = (anim_time as f32 * 3.5 + PI).sin();
|
||||||
|
let wave_slow_cos = (anim_time as f32 * 3.5 + PI).cos();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
next.marlin_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||||
|
next.marlin_head.ori =
|
||||||
|
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_head.scale = Vec3::one() / 10.88;
|
||||||
|
|
||||||
|
next.marlin_torso.offset =
|
||||||
|
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||||
|
next.marlin_torso.ori = Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_torso.scale = Vec3::one() * 1.01;
|
||||||
|
|
||||||
|
next.marlin_rear.offset = Vec3::new(0.0, 3.1, -4.5);
|
||||||
|
next.marlin_rear.ori = Quaternion::rotation_z(0.0);
|
||||||
|
next.marlin_rear.scale = Vec3::one() * 0.98;
|
||||||
|
|
||||||
|
next.marlin_tail.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
|
||||||
|
next.marlin_tail.ori = Quaternion::rotation_z(0.0)
|
||||||
|
* Quaternion::rotation_x(0.0);
|
||||||
|
next.marlin_tail.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.marlin_fin_l.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
|
||||||
|
next.marlin_fin_l.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.marlin_fin_l.scale = Vec3::one() / 11.0;
|
||||||
|
|
||||||
|
next.marlin_fin_r.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
|
||||||
|
next.marlin_fin_r.ori = Quaternion::rotation_y(0.0);
|
||||||
|
next.marlin_fin_r.scale = Vec3::one() / 10.5;
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ pub mod fixture;
|
|||||||
pub mod object;
|
pub mod object;
|
||||||
pub mod quadruped;
|
pub mod quadruped;
|
||||||
pub mod quadrupedmedium;
|
pub mod quadrupedmedium;
|
||||||
|
pub mod birdmedium;
|
||||||
|
pub mod fishmedium;
|
||||||
|
|
||||||
use crate::render::FigureBoneData;
|
use crate::render::FigureBoneData;
|
||||||
use common::comp::{self, item::Tool};
|
use common::comp::{self, item::Tool};
|
||||||
|
@ -226,6 +226,42 @@ impl FigureModelCache {
|
|||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
],
|
],
|
||||||
|
Body::BirdMedium(body) => [
|
||||||
|
Some(mesh_duck_m_head(body.head)),
|
||||||
|
Some(mesh_duck_m_torso(body.torso)),
|
||||||
|
Some(mesh_duck_m_tail(body.tail)),
|
||||||
|
Some(mesh_duck_m_wing_l(body.wing_l)),
|
||||||
|
Some(mesh_duck_m_wing_r(body.wing_r)),
|
||||||
|
Some(mesh_duck_m_leg_l(body.leg_l)),
|
||||||
|
Some(mesh_duck_m_leg_r(body.leg_r)),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
],
|
||||||
|
Body::FishMedium(body) => [
|
||||||
|
Some(mesh_marlin_head(body.head)),
|
||||||
|
Some(mesh_marlin_torso(body.torso)),
|
||||||
|
Some(mesh_marlin_rear(body.rear)),
|
||||||
|
Some(mesh_marlin_tail(body.tail)),
|
||||||
|
Some(mesh_marlin_fin_l(body.fin_l)),
|
||||||
|
Some(mesh_marlin_fin_r(body.fin_r)),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
],
|
||||||
Body::Object(object) => [
|
Body::Object(object) => [
|
||||||
Some(mesh_object(object)),
|
Some(mesh_object(object)),
|
||||||
None,
|
None,
|
||||||
|
@ -10,7 +10,7 @@ use common::{
|
|||||||
Belt, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin,
|
Belt, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin,
|
||||||
},
|
},
|
||||||
item::Tool,
|
item::Tool,
|
||||||
object, quadruped, quadruped_medium, Item, ItemKind,
|
object, quadruped, quadruped_medium, bird_medium, fish_medium, Item, Itemkind
|
||||||
},
|
},
|
||||||
figure::{DynaUnionizer, MatSegment, Material, Segment},
|
figure::{DynaUnionizer, MatSegment, Material, Segment},
|
||||||
};
|
};
|
||||||
@ -697,7 +697,124 @@ pub fn mesh_wolf_foot_rb(foot_rb: quadruped_medium::FootRB) -> Mesh<FigurePipeli
|
|||||||
Vec3::new(-2.5, -4.0, -2.5),
|
Vec3::new(-2.5, -4.0, -2.5),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
////
|
||||||
|
pub fn mesh_duck_m_head(head: bird_medium::Head) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match head {
|
||||||
|
bird_medium::Head::Default => "npc.duck_m.duck_m_head",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_duck_m_torso(torso: bird_medium::Torso) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match torso {
|
||||||
|
bird_medium::Torso::Default => "npc.duck_m.duck_m_body",
|
||||||
|
},
|
||||||
|
Vec3::new(-8.0, -5.5, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_duck_m_tail(tail: bird_medium::Tail) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match tail {
|
||||||
|
bird_medium::Tail::Default => "npc.duck_m.duck_m_tail",
|
||||||
|
},
|
||||||
|
Vec3::new(-4.0, -1.0, -1.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_duck_m_wing_l(wing_l: bird_medium::WingL) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match wing_l {
|
||||||
|
bird_medium::WingL::Default => "npc.duck_m.duck_m_wing",
|
||||||
|
},
|
||||||
|
Vec3::new(-2.5, -4.0, -2.5),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_duck_m_wing_r(wing_r: bird_medium::WingR) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match wing_r {
|
||||||
|
bird_medium::WingR::Default => "npc.duck_m.duck_m_wing",
|
||||||
|
},
|
||||||
|
Vec3::new(-2.5, -4.0, -2.5),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_duck_m_leg_l(leg_l: bird_medium::LegL) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match leg_l {
|
||||||
|
bird_medium::LegL::Default => "npc.duck_m.duck_m_leg_l",
|
||||||
|
},
|
||||||
|
Vec3::new(-2.5, -4.0, -2.5),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_duck_m_leg_r(leg_r: bird_medium::LegR) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match leg_r {
|
||||||
|
bird_medium::LegR::Default => "npc.duck_m.duck_m_leg_r",
|
||||||
|
},
|
||||||
|
Vec3::new(-2.5, -4.0, -2.5),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
////
|
||||||
|
pub fn mesh_marlin_head(head: fish_medium::Head) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match head {
|
||||||
|
fish_medium::Head::Default => "npc.marlin.marlin_head",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_marlin_torso(torso: fish_medium::Torso) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match torso {
|
||||||
|
fish_medium::Torso::Default => "npc.marlin.marlin_torso",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_marlin_rear(rear: fish_medium::Rear) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match rear {
|
||||||
|
fish_medium::Rear::Default => "npc.marlin.marlin_rear",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_marlin_tail(tail: fish_medium::Tail) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match tail {
|
||||||
|
fish_medium::Tail::Default => "npc.marlin.marlin_tail",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_marlin_fin_l(fin_l: fish_medium::FinL) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match fin_l {
|
||||||
|
fish_medium::FinL::Default => "npc.marlin.marlin_fin_l",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mesh_marlin_fin_r(fin_r: fish_medium::FinR) -> Mesh<FigurePipeline> {
|
||||||
|
load_mesh(
|
||||||
|
match fin_r {
|
||||||
|
fish_medium::FinR::Default => "npc.marlin.marlin_fin_r",
|
||||||
|
},
|
||||||
|
Vec3::new(-7.0, -6.0, -6.0),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
////
|
||||||
pub fn mesh_object(obj: object::Body) -> Mesh<FigurePipeline> {
|
pub fn mesh_object(obj: object::Body) -> Mesh<FigurePipeline> {
|
||||||
use object::Body;
|
use object::Body;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ pub use load::load_mesh; // TODO: Don't make this public.
|
|||||||
use crate::{
|
use crate::{
|
||||||
anim::{
|
anim::{
|
||||||
self, character::CharacterSkeleton, object::ObjectSkeleton, quadruped::QuadrupedSkeleton,
|
self, character::CharacterSkeleton, object::ObjectSkeleton, quadruped::QuadrupedSkeleton,
|
||||||
quadrupedmedium::QuadrupedMediumSkeleton, Animation, Skeleton,
|
quadrupedmedium::QuadrupedMediumSkeleton, birdmedium::BirdMediumSkeleton, fishmedium::FishMediumSkeleton,Animation, Skeleton,
|
||||||
},
|
},
|
||||||
render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow},
|
render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow},
|
||||||
scene::camera::{Camera, CameraMode},
|
scene::camera::{Camera, CameraMode},
|
||||||
@ -32,6 +32,8 @@ pub struct FigureMgr {
|
|||||||
character_states: HashMap<EcsEntity, FigureState<CharacterSkeleton>>,
|
character_states: HashMap<EcsEntity, FigureState<CharacterSkeleton>>,
|
||||||
quadruped_states: HashMap<EcsEntity, FigureState<QuadrupedSkeleton>>,
|
quadruped_states: HashMap<EcsEntity, FigureState<QuadrupedSkeleton>>,
|
||||||
quadruped_medium_states: HashMap<EcsEntity, FigureState<QuadrupedMediumSkeleton>>,
|
quadruped_medium_states: HashMap<EcsEntity, FigureState<QuadrupedMediumSkeleton>>,
|
||||||
|
bird_medium_states: HashMap<EcsEntity, FigureState<BirdMediumSkeleton>>,
|
||||||
|
fish_medium_states: HashMap<EcsEntity, FigureState<FishMediumSkeleton>>,
|
||||||
object_states: HashMap<EcsEntity, FigureState<ObjectSkeleton>>,
|
object_states: HashMap<EcsEntity, FigureState<ObjectSkeleton>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,6 +44,8 @@ impl FigureMgr {
|
|||||||
character_states: HashMap::new(),
|
character_states: HashMap::new(),
|
||||||
quadruped_states: HashMap::new(),
|
quadruped_states: HashMap::new(),
|
||||||
quadruped_medium_states: HashMap::new(),
|
quadruped_medium_states: HashMap::new(),
|
||||||
|
bird_medium_states: HashMap::new(),
|
||||||
|
fish_medium_states: HashMap::new(),
|
||||||
object_states: HashMap::new(),
|
object_states: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,6 +97,12 @@ impl FigureMgr {
|
|||||||
Body::QuadrupedMedium(_) => {
|
Body::QuadrupedMedium(_) => {
|
||||||
self.quadruped_medium_states.remove(&entity);
|
self.quadruped_medium_states.remove(&entity);
|
||||||
}
|
}
|
||||||
|
Body::BirdMedium(_) => {
|
||||||
|
self.bird_medium_states.remove(&entity);
|
||||||
|
}
|
||||||
|
Body::FishMedium(_) => {
|
||||||
|
self.fish_medium_states.remove(&entity);
|
||||||
|
}
|
||||||
Body::Object(_) => {
|
Body::Object(_) => {
|
||||||
self.object_states.remove(&entity);
|
self.object_states.remove(&entity);
|
||||||
}
|
}
|
||||||
@ -378,6 +388,120 @@ impl FigureMgr {
|
|||||||
action_animation_rate,
|
action_animation_rate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Body::BirdMedium(_) => {
|
||||||
|
let state = self
|
||||||
|
.bird_medium_states
|
||||||
|
.entry(entity)
|
||||||
|
.or_insert_with(|| {
|
||||||
|
FigureState::new(renderer, BirdMediumSkeleton::new())
|
||||||
|
});
|
||||||
|
|
||||||
|
let (character, last_character) = match (character, last_character) {
|
||||||
|
(Some(c), Some(l)) => (c, l),
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
if !character.is_same_movement(&last_character.0) {
|
||||||
|
state.movement_time = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let target_base = match character.movement {
|
||||||
|
Stand => anim::birdmedium::IdleAnimation::update_skeleton(
|
||||||
|
&BirdMediumSkeleton::new(),
|
||||||
|
time,
|
||||||
|
state.movement_time,
|
||||||
|
&mut movement_animation_rate,
|
||||||
|
skeleton_attr,
|
||||||
|
),
|
||||||
|
Run => anim::birdmedium::RunAnimation::update_skeleton(
|
||||||
|
&BirdMediumSkeleton::new(),
|
||||||
|
(vel.0.magnitude(), time),
|
||||||
|
state.movement_time,
|
||||||
|
&mut movement_animation_rate,
|
||||||
|
skeleton_attr,
|
||||||
|
),
|
||||||
|
Jump => anim::birdmedium::JumpAnimation::update_skeleton(
|
||||||
|
&BirdMediumSkeleton::new(),
|
||||||
|
(vel.0.magnitude(), time),
|
||||||
|
state.movement_time,
|
||||||
|
&mut movement_animation_rate,
|
||||||
|
skeleton_attr,
|
||||||
|
),
|
||||||
|
|
||||||
|
// TODO!
|
||||||
|
_ => state.skeleton_mut().clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
state.skeleton.interpolate(&target_base, dt);
|
||||||
|
state.update(
|
||||||
|
renderer,
|
||||||
|
pos.0,
|
||||||
|
vel.0,
|
||||||
|
ori.0,
|
||||||
|
scale,
|
||||||
|
col,
|
||||||
|
dt,
|
||||||
|
movement_animation_rate,
|
||||||
|
action_animation_rate,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Body::FishMedium(_) => {
|
||||||
|
let state = self
|
||||||
|
.fish_medium_states
|
||||||
|
.entry(entity)
|
||||||
|
.or_insert_with(|| {
|
||||||
|
FigureState::new(renderer, FishMediumSkeleton::new())
|
||||||
|
});
|
||||||
|
|
||||||
|
let (character, last_character) = match (character, last_character) {
|
||||||
|
(Some(c), Some(l)) => (c, l),
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
if !character.is_same_movement(&last_character.0) {
|
||||||
|
state.movement_time = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
let target_base = match character.movement {
|
||||||
|
Stand => anim::fishmedium::IdleAnimation::update_skeleton(
|
||||||
|
&FishMediumSkeleton::new(),
|
||||||
|
time,
|
||||||
|
state.movement_time,
|
||||||
|
&mut movement_animation_rate,
|
||||||
|
skeleton_attr,
|
||||||
|
),
|
||||||
|
Run => anim::fishmedium::RunAnimation::update_skeleton(
|
||||||
|
&FishMediumSkeleton::new(),
|
||||||
|
(vel.0.magnitude(), time),
|
||||||
|
state.movement_time,
|
||||||
|
&mut movement_animation_rate,
|
||||||
|
skeleton_attr,
|
||||||
|
),
|
||||||
|
Jump => anim::fishmedium::JumpAnimation::update_skeleton(
|
||||||
|
&FishMediumSkeleton::new(),
|
||||||
|
(vel.0.magnitude(), time),
|
||||||
|
state.movement_time,
|
||||||
|
&mut movement_animation_rate,
|
||||||
|
skeleton_attr,
|
||||||
|
),
|
||||||
|
|
||||||
|
// TODO!
|
||||||
|
_ => state.skeleton_mut().clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
state.skeleton.interpolate(&target_base, dt);
|
||||||
|
state.update(
|
||||||
|
renderer,
|
||||||
|
pos.0,
|
||||||
|
vel.0,
|
||||||
|
ori.0,
|
||||||
|
scale,
|
||||||
|
col,
|
||||||
|
dt,
|
||||||
|
movement_animation_rate,
|
||||||
|
action_animation_rate,
|
||||||
|
);
|
||||||
|
}
|
||||||
Body::Object(_) => {
|
Body::Object(_) => {
|
||||||
let state = self
|
let state = self
|
||||||
.object_states
|
.object_states
|
||||||
@ -407,6 +531,10 @@ impl FigureMgr {
|
|||||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||||
self.quadruped_medium_states
|
self.quadruped_medium_states
|
||||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||||
|
self.bird_medium_states
|
||||||
|
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||||
|
self.fish_medium_states
|
||||||
|
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||||
self.object_states
|
self.object_states
|
||||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||||
}
|
}
|
||||||
@ -464,6 +592,14 @@ impl FigureMgr {
|
|||||||
.quadruped_medium_states
|
.quadruped_medium_states
|
||||||
.get(&entity)
|
.get(&entity)
|
||||||
.map(|state| (state.locals(), state.bone_consts())),
|
.map(|state| (state.locals(), state.bone_consts())),
|
||||||
|
Body::BirdMedium(_) => self
|
||||||
|
.bird_medium_states
|
||||||
|
.get(&entity)
|
||||||
|
.map(|state| (state.locals(), state.bone_consts())),
|
||||||
|
Body::FishMedium(_) => self
|
||||||
|
.fish_medium_states
|
||||||
|
.get(&entity)
|
||||||
|
.map(|state| (state.locals(), state.bone_consts())),
|
||||||
Body::Object(_) => self
|
Body::Object(_) => self
|
||||||
.object_states
|
.object_states
|
||||||
.get(&entity)
|
.get(&entity)
|
||||||
|
Loading…
Reference in New Issue
Block a user