added large bipeds, small birbs, small fish skeletons

This commit is contained in:
jshipsey 2019-10-23 21:10:26 -04:00
parent 644939810f
commit 574f070758
16 changed files with 1256 additions and 2 deletions

View File

@ -0,0 +1,98 @@
use super::{
super::{Animation, SkeletonAttr},
BipedLargeSkeleton,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;
impl Animation for IdleAnimation {
type Skeleton = BipedLargeSkeleton;
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.knight_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_head.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_head.scale = Vec3::one() / 10.88;
next.knight_upper_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_upper_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_upper_torso.scale = Vec3::one() / 10.88;
next.knight_lower_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_lower_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_lower_torso.scale = Vec3::one() / 10.88;
next.knight_shoulder_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_shoulder_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_shoulder_l.scale = Vec3::one() / 10.88;
next.knight_shoulder_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_shoulder_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_shoulder_r.scale = Vec3::one() / 10.88;
next.knight_hand_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_hand_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_hand_l.scale = Vec3::one() / 10.88;
next.knight_hand_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_hand_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_hand_r.scale = Vec3::one() / 10.88;
next.knight_leg_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_leg_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_leg_l.scale = Vec3::one() / 10.88;
next.knight_leg_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_leg_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_leg_r.scale = Vec3::one() / 10.88;
next.knight_foot_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_foot_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_foot_l.scale = Vec3::one() / 10.88;
next.knight_foot_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_foot_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_foot_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -0,0 +1,86 @@
use super::{
super::{Animation, SkeletonAttr},
BipedLargeSkeleton,
};
use std::f32::consts::PI;
use vek::*;
pub struct JumpAnimation;
impl Animation for JumpAnimation {
type Skeleton = BipedLargeSkeleton;
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.knight_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_head.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_head.scale = Vec3::one() / 10.88;
next.knight_upper_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_upper_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_upper_torso.scale = Vec3::one() / 10.88;
next.knight_lower_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_lower_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_lower_torso.scale = Vec3::one() / 10.88;
next.knight_shoulder_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_shoulder_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_shoulder_l.scale = Vec3::one() / 10.88;
next.knight_shoulder_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_shoulder_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_shoulder_r.scale = Vec3::one() / 10.88;
next.knight_hand_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_hand_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_hand_l.scale = Vec3::one() / 10.88;
next.knight_hand_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_hand_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_hand_r.scale = Vec3::one() / 10.88;
next.knight_leg_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_leg_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_leg_l.scale = Vec3::one() / 10.88;
next.knight_leg_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_leg_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_leg_r.scale = Vec3::one() / 10.88;
next.knight_foot_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_foot_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_foot_l.scale = Vec3::one() / 10.88;
next.knight_foot_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_foot_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_foot_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -0,0 +1,99 @@
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 BipedLargeSkeleton {
knight_head: Bone,
knight_upper_torso: Bone,
knight_lower_torso: Bone,
knight_shoulder_l: Bone,
knight_shoulder_r: Bone,
knight_hand_l: Bone,
knight_hand_r: Bone,
knight_leg_l: Bone,
knight_leg_r: Bone,
knight_foot_l: Bone,
knight_foot_r: Bone,
}
impl BipedLargeSkeleton {
pub fn new() -> Self {
Self {
knight_head: Bone::default(),
knight_upper_torso: Bone::default(),
knight_lower_torso: Bone::default(),
knight_shoulder_l: Bone::default(),
knight_shoulder_r: Bone::default(),
knight_hand_l: Bone::default(),
knight_hand_r: Bone::default(),
knight_leg_l: Bone::default(),
knight_leg_r: Bone::default(),
knight_foot_l: Bone::default(),
knight_foot_r: Bone::default(),
}
}
}
impl Skeleton for BipedLargeSkeleton {
fn compute_matrices(&self) -> [FigureBoneData; 16] {
let upper_torso_mat = self.knight_upper_torso.compute_base_matrix();
let shoulder_l_mat = self.knight_shoulder_l.compute_base_matrix();
let shoulder_r_mat = self.knight_shoulder_r.compute_base_matrix();
let leg_l_mat = self.knight_leg_l.compute_base_matrix();
let leg_r_mat = self.knight_leg_r.compute_base_matrix();
[
FigureBoneData::new(self.knight_head.compute_base_matrix()),
FigureBoneData::new(
upper_torso_mat,
),
FigureBoneData::new(self.knight_lower_torso.compute_base_matrix() * upper_torso_mat),
FigureBoneData::new(shoulder_l_mat * upper_torso_mat),
FigureBoneData::new(shoulder_r_mat * upper_torso_mat),
FigureBoneData::new(self.knight_hand_l.compute_base_matrix() * shoulder_l_mat * upper_torso_mat),
FigureBoneData::new(self.knight_hand_r.compute_base_matrix() * shoulder_r_mat * upper_torso_mat),
FigureBoneData::new(leg_l_mat),
FigureBoneData::new(leg_r_mat),
FigureBoneData::new(self.knight_foot_l.compute_base_matrix() * leg_l_mat),
FigureBoneData::new(self.knight_foot_r.compute_base_matrix() * leg_r_mat),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
]
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.knight_head
.interpolate(&target.knight_head, dt);
self.knight_upper_torso.interpolate(&target.knight_upper_torso, dt);
self.knight_lower_torso
.interpolate(&target.knight_lower_torso, dt);
self.knight_shoulder_l.interpolate(&target.knight_shoulder_l, dt);
self.knight_shoulder_r
.interpolate(&target.knight_shoulder_r, dt);
self.knight_hand_l.interpolate(&target.knight_hand_l, dt);
self.knight_hand_r.interpolate(&target.knight_hand_r, dt);
self.knight_leg_l.interpolate(&target.knight_leg_l, dt);
self.knight_leg_r.interpolate(&target.knight_leg_r, dt);
self.knight_foot_l.interpolate(&target.knight_foot_l, dt);
self.knight_foot_r.interpolate(&target.knight_foot_r, dt);
}
}

View File

@ -0,0 +1,98 @@
use super::{
super::{Animation, SkeletonAttr},
BipedLargeSkeleton,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct RunAnimation;
impl Animation for RunAnimation {
type Skeleton = BipedLargeSkeleton;
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.knight_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_head.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_head.scale = Vec3::one() / 10.88;
next.knight_upper_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_upper_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_upper_torso.scale = Vec3::one() / 10.88;
next.knight_lower_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_lower_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_lower_torso.scale = Vec3::one() / 10.88;
next.knight_shoulder_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_shoulder_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_shoulder_l.scale = Vec3::one() / 10.88;
next.knight_shoulder_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_shoulder_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_shoulder_r.scale = Vec3::one() / 10.88;
next.knight_hand_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_hand_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_hand_l.scale = Vec3::one() / 10.88;
next.knight_hand_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_hand_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_hand_r.scale = Vec3::one() / 10.88;
next.knight_leg_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_leg_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_leg_l.scale = Vec3::one() / 10.88;
next.knight_leg_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_leg_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_leg_r.scale = Vec3::one() / 10.88;
next.knight_foot_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_foot_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_foot_l.scale = Vec3::one() / 10.88;
next.knight_foot_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.knight_foot_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.knight_foot_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -0,0 +1,64 @@
use super::{
super::{Animation, SkeletonAttr},
BirdSmallSkeleton,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;
impl Animation for IdleAnimation {
type Skeleton = BirdSmallSkeleton;
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.crow_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_head.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_head.scale = Vec3::one() / 10.88;
next.crow_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_torso.scale = Vec3::one() / 10.88;
next.crow_wing_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_wing_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_wing_l.scale = Vec3::one() / 10.88;
next.crow_wing_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_wing_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_wing_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -0,0 +1,52 @@
use super::{
super::{Animation, SkeletonAttr},
BirdSmallSkeleton,
};
use std::f32::consts::PI;
use vek::*;
pub struct JumpAnimation;
impl Animation for JumpAnimation {
type Skeleton = BirdSmallSkeleton;
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.crow_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_head.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_head.scale = Vec3::one() / 10.88;
next.crow_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_torso.scale = Vec3::one() / 10.88;
next.crow_wing_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_wing_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_wing_l.scale = Vec3::one() / 10.88;
next.crow_wing_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_wing_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_wing_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -0,0 +1,68 @@
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 BirdSmallSkeleton {
crow_head: Bone,
crow_torso: Bone,
crow_wing_l: Bone,
crow_wing_r: Bone,
}
impl BirdSmallSkeleton {
pub fn new() -> Self {
Self {
crow_head: Bone::default(),
crow_torso: Bone::default(),
crow_wing_l: Bone::default(),
crow_wing_r: Bone::default(),
}
}
}
impl Skeleton for BirdSmallSkeleton {
fn compute_matrices(&self) -> [FigureBoneData; 16] {
let torso_mat = self.crow_torso.compute_base_matrix();
[
FigureBoneData::new(self.crow_head.compute_base_matrix() * torso_mat),
FigureBoneData::new(
torso_mat,
),
FigureBoneData::new(self.crow_wing_l.compute_base_matrix() * torso_mat),
FigureBoneData::new(self.crow_wing_r.compute_base_matrix() * torso_mat),
FigureBoneData::default(),
FigureBoneData::default(),
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.crow_head
.interpolate(&target.crow_head, dt);
self.crow_torso.interpolate(&target.crow_torso, dt);
self.crow_wing_l.interpolate(&target.crow_wing_l, dt);
self.crow_wing_r
.interpolate(&target.crow_wing_r, dt);
}
}

View File

@ -0,0 +1,64 @@
use super::{
super::{Animation, SkeletonAttr},
BirdSmallSkeleton,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct RunAnimation;
impl Animation for RunAnimation {
type Skeleton = BirdSmallSkeleton;
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.crow_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_head.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_head.scale = Vec3::one() / 10.88;
next.crow_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_torso.scale = Vec3::one() / 10.88;
next.crow_wing_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_wing_l.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_wing_l.scale = Vec3::one() / 10.88;
next.crow_wing_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.crow_wing_r.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.crow_wing_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -0,0 +1,54 @@
use super::{
super::{Animation, SkeletonAttr},
FishSmallSkeleton,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;
impl Animation for IdleAnimation {
type Skeleton = FishSmallSkeleton;
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.cardinalfish_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.cardinalfish_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.cardinalfish_torso.scale = Vec3::one() / 10.88;
next.cardinalfish_tail.offset =
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
next.cardinalfish_tail.ori = Quaternion::rotation_x(0.0);
next.cardinalfish_tail.scale = Vec3::one() * 1.01;
next
}
}

View File

@ -0,0 +1,42 @@
use super::{
super::{Animation, SkeletonAttr},
FishSmallSkeleton,
};
use std::f32::consts::PI;
use vek::*;
pub struct JumpAnimation;
impl Animation for JumpAnimation {
type Skeleton = FishSmallSkeleton;
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.cardinalfish_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.cardinalfish_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.cardinalfish_torso.scale = Vec3::one() / 10.88;
next.cardinalfish_tail.offset =
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
next.cardinalfish_tail.ori = Quaternion::rotation_x(0.0);
next.cardinalfish_tail.scale = Vec3::one() * 1.01;
next
}
}

View File

@ -0,0 +1,59 @@
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 FishSmallSkeleton {
cardinalfish_torso: Bone,
cardinalfish_tail: Bone,
}
impl FishSmallSkeleton {
pub fn new() -> Self {
Self {
cardinalfish_torso: Bone::default(),
cardinalfish_tail: Bone::default(),
}
}
}
impl Skeleton for FishSmallSkeleton {
fn compute_matrices(&self) -> [FigureBoneData; 16] {
let torso_mat = self.cardinalfish_torso.compute_base_matrix();
[
FigureBoneData::new(torso_mat),
FigureBoneData::new(self.cardinalfish_tail.compute_base_matrix() * torso_mat),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
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.cardinalfish_torso
.interpolate(&target.cardinalfish_torso, dt);
self.cardinalfish_tail.interpolate(&target.cardinalfish_tail, dt);
}
}

View File

@ -0,0 +1,54 @@
use super::{
super::{Animation, SkeletonAttr},
FishSmallSkeleton,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct RunAnimation;
impl Animation for RunAnimation {
type Skeleton = FishSmallSkeleton;
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.cardinalfish_torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.cardinalfish_torso.ori =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.cardinalfish_torso.scale = Vec3::one() / 10.88;
next.cardinalfish_tail.offset =
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
next.cardinalfish_tail.ori = Quaternion::rotation_x(0.0);
next.cardinalfish_tail.scale = Vec3::one() * 1.01;
next
}
}

View File

@ -6,6 +6,9 @@ pub mod quadrupedmedium;
pub mod birdmedium;
pub mod fishmedium;
pub mod dragon;
pub mod bird_small;
pub mod fish_small;
pub mod biped_large;
use crate::render::FigureBoneData;
use common::comp::{self, item::Tool};

View File

@ -280,6 +280,60 @@ impl FigureModelCache {
None,
None,
],
Body::BirdSmall(body) => [
Some(mesh_crow_head(body.head)),
Some(mesh_crow_torso(body.torso)),
Some(mesh_crow_wing_l(body.wing_l)),
Some(mesh_crow_wing_r(body.wing_r)),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
],
Body::FishSmall(body) => [
Some(mesh_cardinalfish_torso(body.torso)),
Some(mesh_cardinalfish_tail(body.tail)),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
],
Body::BipedLarge(body) => [
Some(mesh_knight_head(body.head)),
Some(mesh_knight_upper_torso(body.upper_torso)),
Some(mesh_knight_lower_torso(body.lower_torso)),
Some(mesh_knight_shoulder_l(body.shoulder_l)),
Some(mesh_knight_shoulder_r(body.shoulder_r)),
Some(mesh_knight_hand_l(body.hand_l)),
Some(mesh_knight_hand_r(body.hand_r)),
Some(mesh_knight_leg_l(body.leg_l)),
Some(mesh_knight_leg_r(body.leg_r)),
Some(mesh_knight_foot_l(body.foot_l)),
Some(mesh_knight_foot_r(body.foot_r)),
None,
None,
None,
None,
None,
],
Body::Object(object) => [
Some(mesh_object(object)),
None,

View File

@ -10,7 +10,8 @@ use common::{
Belt, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin,
},
item::Tool,
object, quadruped, quadruped_medium, bird_medium, fish_medium, dragon, Item, Itemkind
object, quadruped, quadruped_medium, bird_medium, fish_medium, dragon, bird_small, fish_small, biped_large, Item, Itemkind
},
figure::{DynaUnionizer, MatSegment, Material, Segment},
};
@ -932,6 +933,160 @@ pub fn mesh_dragon_foot_br(foot_br: dragon::FootBR) -> Mesh<FigurePipeline> {
)
}
////
pub fn mesh_crow_head(head: bird_small::Head) -> Mesh<FigurePipeline> {
load_mesh(
match head {
bird_small::Head::Default => "npc.crow.crow_head",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_crow_torso(torso: bird_small::Torso) -> Mesh<FigurePipeline> {
load_mesh(
match torso {
bird_small::Torso::Default => "npc.crow.crow_torso",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_crow_wing_l(wing_l: bird_small::WingL) -> Mesh<FigurePipeline> {
load_mesh(
match wing_l {
bird_small::WingL::Default => "npc.crow.crow_wing_l",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_crow_wing_r(wing_r: bird_small::WingR) -> Mesh<FigurePipeline> {
load_mesh(
match wing_r {
bird_small::WingR::Default => "npc.crow.crow_wing_r",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
////
pub fn mesh_cardinalfish_torso(torso: fish_small::Torso) -> Mesh<FigurePipeline> {
load_mesh(
match torso {
fish_small::Torso::Default => "npc.cardinalfish.cardinalfish_torso",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_cardinalfish_tail(tail: fish_small::Tail) -> Mesh<FigurePipeline> {
load_mesh(
match tail {
fish_small::Tail::Default => "npc.cardinalfish.cardinalfish_tail",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
////
pub fn mesh_knight_head(head: biped_large::Head) -> Mesh<FigurePipeline> {
load_mesh(
match head {
biped_large::Head::Default => "npc.knight.knight_",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_upper_torso(upper_torso: biped_large::UpperTorso) -> Mesh<FigurePipeline> {
load_mesh(
match upper_torso {
biped_large::UpperTorso::Default => "npc.knight.knight_upper_torso",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_lower_torso(lower_torso: biped_large::LowerTorso) -> Mesh<FigurePipeline> {
load_mesh(
match lower_torso {
biped_large::LowerTorso::Default => "npc.knight.knight_lower_torso",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_shoulder_l(shoulder_l: biped_large::ShoulderL) -> Mesh<FigurePipeline> {
load_mesh(
match shoulder_l {
biped_large::ShoulderL::Default => "npc.knight.knight_shoulder_l",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_shoulder_r(shoulder_r: biped_large::ShoulderR) -> Mesh<FigurePipeline> {
load_mesh(
match shoulder_r {
biped_large::ShoulderR::Default => "npc.knight.knight_shoulder_r",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_hand_l(hand_l: biped_large::HandL) -> Mesh<FigurePipeline> {
load_mesh(
match hand_l {
biped_large::HandL::Default => "npc.knight.knight_hand_l",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_hand_r(hand_r: biped_large::HandR) -> Mesh<FigurePipeline> {
load_mesh(
match hand_r {
biped_large::HandR::Default => "npc.knight.knight_hand_r",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_leg_l(leg_l: biped_large::LegL) -> Mesh<FigurePipeline> {
load_mesh(
match leg_l {
biped_large::LegL::Default => "npc.knight.knight_leg_l",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_leg_r(leg_r: biped_large::LegR) -> Mesh<FigurePipeline> {
load_mesh(
match leg_r {
biped_large::LegR::Default => "npc.knight.knight_leg_r",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_foot_l(foot_l: biped_large::FootL) -> Mesh<FigurePipeline> {
load_mesh(
match foot_l {
biped_large::FootL::Default => "npc.knight.knight_foot_l",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
pub fn mesh_knight_foot_r(foot_r: biped_large::FootR) -> Mesh<FigurePipeline> {
load_mesh(
match foot_r {
biped_large::FootR::Default => "npc.knight.knight_foot_r",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
////
pub fn mesh_object(obj: object::Body) -> Mesh<FigurePipeline> {

View File

@ -7,7 +7,7 @@ pub use load::load_mesh; // TODO: Don't make this public.
use crate::{
anim::{
self, character::CharacterSkeleton, object::ObjectSkeleton, quadruped::QuadrupedSkeleton,
quadrupedmedium::QuadrupedMediumSkeleton, birdmedium::BirdMediumSkeleton, fishmedium::FishMediumSkeleton, dragon::DragonSkeleton, Animation, Skeleton,
quadrupedmedium::QuadrupedMediumSkeleton, birdmedium::BirdMediumSkeleton, fishmedium::FishMediumSkeleton, dragon::DragonSkeleton, bird_small::BirdSmallSkeleton, fish_small::FishSmallSkeleton, biped_large::BipedLargeSkeleton, Animation, Skeleton,
},
render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow},
scene::camera::{Camera, CameraMode},
@ -35,6 +35,9 @@ pub struct FigureMgr {
bird_medium_states: HashMap<EcsEntity, FigureState<BirdMediumSkeleton>>,
fish_medium_states: HashMap<EcsEntity, FigureState<FishMediumSkeleton>>,
dragon_states: HashMap<EcsEntity, FigureState<DragonSkeleton>>,
bird_small_states: HashMap<EcsEntity, FigureState<BirdSmallSkeleton>>,
fish_small_states: HashMap<EcsEntity, FigureState<FishSmallSkeleton>>,
biped_large_states: HashMap<EcsEntity, FigureState<BipedLargeSkeleton>>,
object_states: HashMap<EcsEntity, FigureState<ObjectSkeleton>>,
}
@ -48,6 +51,9 @@ impl FigureMgr {
bird_medium_states: HashMap::new(),
fish_medium_states: HashMap::new(),
dragon_states: HashMap::new(),
bird_small_states: HashMap::new(),
fish_small_states: HashMap::new(),
biped_large_states: HashMap::new(),
object_states: HashMap::new(),
}
}
@ -108,6 +114,15 @@ impl FigureMgr {
Body::Dragon(_) => {
self.dragon_states.remove(&entity);
}
Body::BirdSmall(_) => {
self.bird_small_states.remove(&entity);
}
Body::FishSmall(_) => {
self.fish_small_states.remove(&entity);
}
Body::BipedLarge(_) => {
self.biped_large_states.remove(&entity);
}
Body::Object(_) => {
self.object_states.remove(&entity);
}
@ -564,6 +579,177 @@ impl FigureMgr {
action_animation_rate,
);
}
Body::BirdSmall(_) => {
let state = self
.bird_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BirdSmallSkeleton::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::bird_small::IdleAnimation::update_skeleton(
&BirdSmallSkeleton::new(),
time,
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Run => anim::bird_small::RunAnimation::update_skeleton(
&BirdSmallSkeleton::new(),
(vel.0.magnitude(), time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Jump => anim::bird_small::JumpAnimation::update_skeleton(
&BirdSmallSkeleton::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::FishSmall(_) => {
let state = self
.fish_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer,FishSmallSkeleton::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::fish_small::IdleAnimation::update_skeleton(
&FishSmallSkeleton::new(),
time,
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Run => anim::fish_small::RunAnimation::update_skeleton(
&FishSmallSkeleton::new(),
(vel.0.magnitude(), time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Jump => anim::fish_small::JumpAnimation::update_skeleton(
&FishSmallSkeleton::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::BipedLarge(_) => {
let state = self
.biped_large_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BipedLargeSkeleton::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::biped_large::IdleAnimation::update_skeleton(
&BipedLargeSkeleton::new(),
time,
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Run => anim::biped_large::RunAnimation::update_skeleton(
&BipedLargeSkeleton::new(),
(vel.0.magnitude(), time),
state.movement_time,
&mut movement_animation_rate,
skeleton_attr,
),
Jump => anim::biped_large::JumpAnimation::update_skeleton(
&BipedLargeSkeleton::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(_) => {
let state = self
.object_states
@ -599,6 +785,12 @@ impl FigureMgr {
.retain(|entity, _| ecs.entities().is_alive(*entity));
self.dragon_states
.retain(|entity, _| ecs.entities().is_alive(*entity));
self.bird_small_states
.retain(|entity, _| ecs.entities().is_alive(*entity));
self.fish_small_states
.retain(|entity, _| ecs.entities().is_alive(*entity));
self.biped_large_states
.retain(|entity, _| ecs.entities().is_alive(*entity));
self.object_states
.retain(|entity, _| ecs.entities().is_alive(*entity));
}
@ -668,6 +860,18 @@ impl FigureMgr {
.dragon_states
.get(&entity)
.map(|state| (state.locals(), state.bone_consts())),
Body::BirdSmall(_) => self
.bird_small_states
.get(&entity)
.map(|state| (state.locals(), state.bone_consts())),
Body::FishSmall(_) => self
.fish_small_states
.get(&entity)
.map(|state| (state.locals(), state.bone_consts())),
Body::BipedLarge(_) => self
.biped_large_states
.get(&entity)
.map(|state| (state.locals(), state.bone_consts())),
Body::Object(_) => self
.object_states
.get(&entity)