mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
added dragon skeleton
This commit is contained in:
parent
54fc712076
commit
644939810f
BIN
assets/voxygen/voxel/npc/dragon/dragon_chest_front.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_chest_front.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_chest_rear.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_chest_rear.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_bl.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_bl.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_br.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_br.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_fl.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_fl.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_fr.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_foot_fr.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_head.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_head.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_tail_front.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_tail_front.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_tail_rear.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_tail_rear.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_in_l.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_in_l.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_in_r.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_in_r.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_out_l.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_out_l.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_out_r.vox
(Stored with Git LFS)
Normal file
BIN
assets/voxygen/voxel/npc/dragon/dragon_wing_out_r.vox
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -4,6 +4,7 @@ pub mod quadruped;
|
||||
pub mod quadruped_medium;
|
||||
pub mod bird_medium;
|
||||
pub mod fish_medium;
|
||||
pub mod dragon;
|
||||
|
||||
use specs::{Component, FlaggedStorage};
|
||||
use specs_idvs::IDVStorage;
|
||||
@ -15,6 +16,7 @@ pub enum Body {
|
||||
QuadrupedMedium(quadruped_medium::Body),
|
||||
BirdMedium(bird_medium::Body),
|
||||
FishMedium(fish_medium::Body),
|
||||
Dragon(dragon::Body),
|
||||
Object(object::Body),
|
||||
}
|
||||
|
||||
|
121
common/src/comp/body/dragon.rs
Normal file
121
common/src/comp/body/dragon.rs
Normal file
@ -0,0 +1,121 @@
|
||||
use rand::{seq::SliceRandom, thread_rng};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub struct Body {
|
||||
pub head: Head,
|
||||
pub chest_front: ChestFront,
|
||||
pub chest_rear: ChestRear,
|
||||
pub tail_front: TailFront,
|
||||
pub tail_rear: TailRear,
|
||||
pub wing_in_l: WingInL,
|
||||
pub wing_in_r: WingInR,
|
||||
pub wing_out_l: WingOutL,
|
||||
pub wing_out_r: WingOutR,
|
||||
pub foot_fl: FootFL,
|
||||
pub foot_fr: FootFR,
|
||||
pub foot_bl: FootBL,
|
||||
pub foot_br: FootBR,
|
||||
|
||||
|
||||
|
||||
}
|
||||
impl Body {
|
||||
pub fn random() -> Self {
|
||||
let mut rng = thread_rng();
|
||||
Self {
|
||||
head: *(&ALL_HEADS).choose(&mut rng).unwrap(),
|
||||
chest_front: *(&ALL_CHEST_FRONTS).choose(&mut rng).unwrap(),
|
||||
chest_rear: *(&ALL_CHEST_REARS).choose(&mut rng).unwrap(),
|
||||
tail_front: *(&ALL_TAIL_FRONTS).choose(&mut rng).unwrap(),
|
||||
tail_rear: *(&ALL_TAIL_REARS).choose(&mut rng).unwrap(),
|
||||
wing_in_l: *(&ALL_WING_IN_LS).choose(&mut rng).unwrap(),
|
||||
wing_in_r: *(&ALL_WING_IN_RS).choose(&mut rng).unwrap(),
|
||||
wing_out_l: *(&ALL_WING_OUT_LS).choose(&mut rng).unwrap(),
|
||||
wing_out_r: *(&ALL_WING_OUT_RS).choose(&mut rng).unwrap(),
|
||||
foot_fl: *(&ALL_FOOT_FLS).choose(&mut rng).unwrap(),
|
||||
foot_fr: *(&ALL_FOOT_FRS).choose(&mut rng).unwrap(),
|
||||
foot_bl: *(&ALL_FOOT_BLS).choose(&mut rng).unwrap(),
|
||||
foot_br: *(&ALL_FOOT_BRS).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 ChestFront {
|
||||
Default,
|
||||
}
|
||||
const ALL_CHEST_FRONTS: [ChestFront; 1] = [ChestFront::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum ChestRear {
|
||||
Default,
|
||||
}
|
||||
const ALL_CHEST_REARS: [ChestRear; 1] = [ChestRear::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum TailFront {
|
||||
Default,
|
||||
}
|
||||
const ALL_TAIL_FRONTS: [TailFront; 1] = [TailFront::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum TailRear {
|
||||
Default,
|
||||
}
|
||||
const ALL_TAIL_REARS: [TailRear; 1] = [TailRear::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum WingInL {
|
||||
Default,
|
||||
}
|
||||
const ALL_WING_IN_LS: [WingInL; 1] = [WingInL::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum WingInR {
|
||||
Default,
|
||||
}
|
||||
const ALL_WING_IN_RS: [WingInR; 1] = [WingInR::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum WingOutL {
|
||||
Default,
|
||||
}
|
||||
const ALL_WING_OUT_LS: [WingOutL; 1] = [WingOutL::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum WingOutR {
|
||||
Default,
|
||||
}
|
||||
const ALL_WING_OUT_RS: [WingOutR; 1] = [WingOutR::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum FootFL {
|
||||
Default,
|
||||
}
|
||||
const ALL_FOOT_FLS: [FootFL; 1] = [FootFL::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum FootFR {
|
||||
Default,
|
||||
}
|
||||
const ALL_FOOT_FRS: [FootFR; 1] = [FootFR::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum FootBL {
|
||||
Default,
|
||||
}
|
||||
const ALL_FOOT_BLS: [FootBL; 1] = [FootBL::Default];
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum FootBR {
|
||||
Default,
|
||||
}
|
||||
const ALL_FOOT_BRS: [FootBR; 1] = [FootBR::Default];
|
@ -16,7 +16,7 @@ mod visual;
|
||||
// Reexports
|
||||
pub use admin::Admin;
|
||||
pub use agent::Agent;
|
||||
pub use body::{humanoid, object, quadruped, quadruped_medium, bird_medium, fish_medium, Body};
|
||||
pub use body::{humanoid, object, quadruped, quadruped_medium, bird_medium, fish_medium, dragon, Body};
|
||||
pub use character_state::{ActionState, CharacterState, MovementState};
|
||||
pub use controller::{
|
||||
ControlEvent, Controller, ControllerInputs, InventoryManip, MountState, Mounting,
|
||||
|
108
voxygen/src/anim/dragon/idle.rs
Normal file
108
voxygen/src/anim/dragon/idle.rs
Normal file
@ -0,0 +1,108 @@
|
||||
use super::{
|
||||
super::{Animation, SkeletonAttr},
|
||||
DragonSkeleton,
|
||||
};
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
use vek::*;
|
||||
|
||||
pub struct IdleAnimation;
|
||||
|
||||
impl Animation for IdleAnimation {
|
||||
type Skeleton = DragonSkeleton;
|
||||
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.dragon_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||
next.dragon_head.ori =
|
||||
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||
next.dragon_head.scale = Vec3::one() / 10.88;
|
||||
|
||||
next.dragon_chest_front.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_chest_front.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_chest_front.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_chest_rear.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_chest_rear.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_chest_rear.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_tail_front.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_tail_front.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_tail_front.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_tail_rear.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_tail_rear.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_tail_rear.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_in_l.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_in_l.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_in_l.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_in_r.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_in_r.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_in_r.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_out_l.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_out_l.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_out_l.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_out_r.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_out_r.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_out_r.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_fl.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_fl.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_fl.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_fr.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_fr.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_fr.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_bl.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_bl.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_bl.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_br.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_br.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_br.scale = Vec3::one() * 1.01;
|
||||
next
|
||||
}
|
||||
}
|
96
voxygen/src/anim/dragon/jump.rs
Normal file
96
voxygen/src/anim/dragon/jump.rs
Normal file
@ -0,0 +1,96 @@
|
||||
use super::{
|
||||
super::{Animation, SkeletonAttr},
|
||||
DragonSkeleton,
|
||||
};
|
||||
use std::f32::consts::PI;
|
||||
use vek::*;
|
||||
|
||||
pub struct JumpAnimation;
|
||||
|
||||
impl Animation for JumpAnimation {
|
||||
type Skeleton = DragonSkeleton;
|
||||
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.dragon_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||
next.dragon_head.ori =
|
||||
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||
next.dragon_head.scale = Vec3::one() / 10.88;
|
||||
|
||||
next.dragon_chest_front.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_chest_front.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_chest_front.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_chest_rear.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_chest_rear.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_chest_rear.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_tail_front.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_tail_front.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_tail_front.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_tail_rear.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_tail_rear.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_tail_rear.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_in_l.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_in_l.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_in_l.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_in_r.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_in_r.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_in_r.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_out_l.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_out_l.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_out_l.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_out_r.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_out_r.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_out_r.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_fl.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_fl.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_fl.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_fr.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_fr.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_fr.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_bl.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_bl.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_bl.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_br.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_br.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_br.scale = Vec3::one() * 1.01;
|
||||
next
|
||||
}
|
||||
}
|
100
voxygen/src/anim/dragon/mod.rs
Normal file
100
voxygen/src/anim/dragon/mod.rs
Normal file
@ -0,0 +1,100 @@
|
||||
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 DragonSkeleton {
|
||||
dragon_head: Bone,
|
||||
dragon_chest_front: Bone,
|
||||
dragon_chest_rear: Bone,
|
||||
dragon_tail_front: Bone,
|
||||
dragon_tail_rear: Bone,
|
||||
dragon_wing_in_l: Bone,
|
||||
dragon_wing_in_r: Bone,
|
||||
dragon_wing_out_l: Bone,
|
||||
dragon_wing_out_r: Bone,
|
||||
dragon_foot_fl: Bone,
|
||||
dragon_foot_fr: Bone,
|
||||
dragon_foot_bl: Bone,
|
||||
dragon_foot_br: Bone,
|
||||
|
||||
}
|
||||
|
||||
impl DragonSkeleton {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
dragon_head: Bone::default(),
|
||||
dragon_chest_front: Bone::default(),
|
||||
dragon_chest_rear: Bone::default(),
|
||||
dragon_tail_front: Bone::default(),
|
||||
dragon_tail_rear: Bone::default(),
|
||||
dragon_wing_in_l: Bone::default(),
|
||||
dragon_wing_in_r: Bone::default(),
|
||||
dragon_wing_out_l: Bone::default(),
|
||||
dragon_wing_out_r: Bone::default(),
|
||||
dragon_foot_fl: Bone::default(),
|
||||
dragon_foot_fr: Bone::default(),
|
||||
dragon_foot_bl: Bone::default(),
|
||||
dragon_foot_br: Bone::default(),
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Skeleton for DragonSkeleton {
|
||||
fn compute_matrices(&self) -> [FigureBoneData; 16] {
|
||||
let chest_front_mat = self.dragon_chest_front.compute_base_matrix();
|
||||
let wing_in_l_mat = self.dragon_wing_in_l.compute_base_matrix();
|
||||
let wing_in_r_mat = self.dragon_wing_in_r.compute_base_matrix();
|
||||
let tail_front_mat = self.dragon_tail_front.compute_base_matrix();
|
||||
|
||||
|
||||
[
|
||||
FigureBoneData::new(self.dragon_head.compute_base_matrix() * chest_front_mat),
|
||||
FigureBoneData::new(
|
||||
chest_front_mat,
|
||||
),
|
||||
FigureBoneData::new(self.dragon_chest_rear.compute_base_matrix() * chest_front_mat),
|
||||
FigureBoneData::new(tail_front_mat),
|
||||
FigureBoneData::new(self.dragon_tail_rear.compute_base_matrix() * tail_front_mat),
|
||||
FigureBoneData::new(wing_in_l_mat),
|
||||
FigureBoneData::new(wing_in_r_mat),
|
||||
FigureBoneData::new(self.dragon_wing_out_l.compute_base_matrix() * wing_in_l_mat),
|
||||
FigureBoneData::new(self.dragon_wing_out_r.compute_base_matrix() * wing_in_r_mat),
|
||||
FigureBoneData::new(self.dragon_foot_fl.compute_base_matrix()),
|
||||
FigureBoneData::new(self.dragon_foot_fr.compute_base_matrix()),
|
||||
FigureBoneData::new(self.dragon_foot_bl.compute_base_matrix()),
|
||||
FigureBoneData::new(self.dragon_foot_br.compute_base_matrix()),
|
||||
FigureBoneData::default(),
|
||||
FigureBoneData::default(),
|
||||
FigureBoneData::default(),
|
||||
]
|
||||
}
|
||||
|
||||
fn interpolate(&mut self, target: &Self, dt: f32) {
|
||||
self.dragon_head.interpolate(&target.dragon_head, dt);
|
||||
self.dragon_chest_front.interpolate(&target.dragon_chest_front, dt);
|
||||
self.dragon_chest_rear.interpolate(&target.dragon_chest_rear, dt);
|
||||
self.dragon_tail_front.interpolate(&target.dragon_tail_front, dt);
|
||||
self.dragon_tail_rear.interpolate(&target.dragon_tail_rear, dt);
|
||||
self.dragon_wing_in_l.interpolate(&target.dragon_wing_in_l, dt);
|
||||
self.dragon_wing_in_r.interpolate(&target.dragon_wing_in_r, dt);
|
||||
self.dragon_wing_out_l.interpolate(&target.dragon_wing_out_l, dt);
|
||||
self.dragon_wing_out_r.interpolate(&target.dragon_wing_out_r, dt);
|
||||
self.dragon_foot_fl.interpolate(&target.dragon_foot_fl, dt);
|
||||
self.dragon_foot_fr.interpolate(&target.dragon_foot_fr, dt);
|
||||
self.dragon_foot_bl.interpolate(&target.dragon_foot_bl, dt);
|
||||
self.dragon_foot_br.interpolate(&target.dragon_foot_br, dt);
|
||||
|
||||
|
||||
}
|
||||
}
|
108
voxygen/src/anim/dragon/run.rs
Normal file
108
voxygen/src/anim/dragon/run.rs
Normal file
@ -0,0 +1,108 @@
|
||||
use super::{
|
||||
super::{Animation, SkeletonAttr},
|
||||
DragonSkeleton,
|
||||
};
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
use vek::*;
|
||||
|
||||
pub struct RunAnimation;
|
||||
|
||||
impl Animation for RunAnimation {
|
||||
type Skeleton = DragonSkeleton;
|
||||
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.dragon_head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
|
||||
next.dragon_head.ori =
|
||||
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
|
||||
next.dragon_head.scale = Vec3::one() / 10.88;
|
||||
|
||||
next.dragon_chest_front.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_chest_front.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_chest_front.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_chest_rear.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_chest_rear.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_chest_rear.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_tail_front.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_tail_front.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_tail_front.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_tail_rear.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_tail_rear.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_tail_rear.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_in_l.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_in_l.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_in_l.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_in_r.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_in_r.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_in_r.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_out_l.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_out_l.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_out_l.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_wing_out_r.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_wing_out_r.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_wing_out_r.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_fl.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_fl.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_fl.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_fr.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_fr.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_fr.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_bl.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_bl.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_bl.scale = Vec3::one() * 1.01;
|
||||
|
||||
next.dragon_foot_br.offset =
|
||||
Vec3::new(0.0, 4.5 - wave_ultra_slow_cos * 0.12, 2.0);
|
||||
next.dragon_foot_br.ori = Quaternion::rotation_x(0.0);
|
||||
next.dragon_foot_br.scale = Vec3::one() * 1.01;
|
||||
next
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ pub mod quadruped;
|
||||
pub mod quadrupedmedium;
|
||||
pub mod birdmedium;
|
||||
pub mod fishmedium;
|
||||
pub mod dragon;
|
||||
|
||||
use crate::render::FigureBoneData;
|
||||
use common::comp::{self, item::Tool};
|
||||
|
@ -262,6 +262,24 @@ impl FigureModelCache {
|
||||
None,
|
||||
None,
|
||||
],
|
||||
Body::Dragon(body) => [
|
||||
Some(mesh_dragon_head(body.head)),
|
||||
Some(mesh_dragon_chest_front(body.chest_front)),
|
||||
Some(mesh_dragon_chest_rear(body.chest_rear)),
|
||||
Some(mesh_dragon_tail_front(body.tail_front)),
|
||||
Some(mesh_dragon_tail_rear(body.tail_rear)),
|
||||
Some(mesh_dragon_wing_in_l(body.wing_in_l)),
|
||||
Some(mesh_dragon_wing_in_r(body.wing_in_r)),
|
||||
Some(mesh_dragon_wing_out_l(body.wing_out_l)),
|
||||
Some(mesh_dragon_wing_out_r(body.wing_out_r)),
|
||||
Some(mesh_dragon_foot_fl(body.foot_fl)),
|
||||
Some(mesh_dragon_foot_fr(body.foot_fr)),
|
||||
Some(mesh_dragon_foot_bl(body.foot_bl)),
|
||||
Some(mesh_dragon_foot_br(body.foot_br)),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
],
|
||||
Body::Object(object) => [
|
||||
Some(mesh_object(object)),
|
||||
None,
|
||||
|
@ -10,7 +10,7 @@ use common::{
|
||||
Belt, BodyType, Chest, EyeColor, Eyebrows, Foot, Hand, Pants, Race, Shoulder, Skin,
|
||||
},
|
||||
item::Tool,
|
||||
object, quadruped, quadruped_medium, bird_medium, fish_medium, Item, Itemkind
|
||||
object, quadruped, quadruped_medium, bird_medium, fish_medium, dragon, Item, Itemkind
|
||||
},
|
||||
figure::{DynaUnionizer, MatSegment, Material, Segment},
|
||||
};
|
||||
@ -814,6 +814,125 @@ pub fn mesh_marlin_fin_r(fin_r: fish_medium::FinR) -> Mesh<FigurePipeline> {
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
////
|
||||
pub fn mesh_dragon_head(head: dragon::Head) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match head {
|
||||
dragon::Head::Default => "npc.dragon.dragon_head",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_chest_front(chest_front: dragon::ChestFront) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match chest_front {
|
||||
dragon::ChestFront::Default => "npc.dragon.dragon_chest_front",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_chest_rear(chest_rear: dragon::ChestRear) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match chest_rear {
|
||||
dragon::ChestRear::Default => "npc.dragon.dragon_chest_rear",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_tail_front(tail_front: dragon::TailFront) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match tail_front {
|
||||
dragon::TailFront::Default => "npc.dragon.dragon_tail_front",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_tail_rear(tail_rear: dragon::TailRear) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match tail_rear {
|
||||
dragon::TailRear::Default => "npc.dragon.dragon_tail_rear",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_wing_in_l(wing_in_l: dragon::WingInL) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match wing_in_l {
|
||||
dragon::WingInL::Default => "npc.dragon.dragon_wing_in_l",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_wing_in_r(wing_in_r: dragon::WingInR) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match wing_in_r {
|
||||
dragon::WingInR::Default => "npc.dragon.dragon_wing_in_r",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_wing_out_l(wing_out_l: dragon::WingOutL) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match wing_out_l {
|
||||
dragon::WingOutL::Default => "npc.dragon.dragon_wing_out_l",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_wing_out_r(wing_out_r: dragon::WingOutR) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match wing_out_r {
|
||||
dragon::WingOutR::Default => "npc.dragon.dragon_wing_out_r",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_foot_fl(foot_fl: dragon::FootFL) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match foot_fl {
|
||||
dragon::FootFL::Default => "npc.dragon.dragon_foot_fl",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_foot_fr(foot_fr: dragon::FootFR) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match foot_fr {
|
||||
dragon::FootFR::Default => "npc.dragon.dragon_foot_fr",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_foot_bl(foot_bl: dragon::FootBL) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match foot_bl {
|
||||
dragon::FootBL::Default => "npc.dragon.dragon_foot_bl",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn mesh_dragon_foot_br(foot_br: dragon::FootBR) -> Mesh<FigurePipeline> {
|
||||
load_mesh(
|
||||
match foot_br {
|
||||
dragon::FootBR::Default => "npc.dragon.dragon_foot_br",
|
||||
},
|
||||
Vec3::new(-7.0, -6.0, -6.0),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
////
|
||||
pub fn mesh_object(obj: object::Body) -> Mesh<FigurePipeline> {
|
||||
use object::Body;
|
||||
|
@ -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,Animation, Skeleton,
|
||||
quadrupedmedium::QuadrupedMediumSkeleton, birdmedium::BirdMediumSkeleton, fishmedium::FishMediumSkeleton, dragon::DragonSkeleton, Animation, Skeleton,
|
||||
},
|
||||
render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow},
|
||||
scene::camera::{Camera, CameraMode},
|
||||
@ -34,6 +34,7 @@ pub struct FigureMgr {
|
||||
quadruped_medium_states: HashMap<EcsEntity, FigureState<QuadrupedMediumSkeleton>>,
|
||||
bird_medium_states: HashMap<EcsEntity, FigureState<BirdMediumSkeleton>>,
|
||||
fish_medium_states: HashMap<EcsEntity, FigureState<FishMediumSkeleton>>,
|
||||
dragon_states: HashMap<EcsEntity, FigureState<DragonSkeleton>>,
|
||||
object_states: HashMap<EcsEntity, FigureState<ObjectSkeleton>>,
|
||||
}
|
||||
|
||||
@ -46,6 +47,7 @@ impl FigureMgr {
|
||||
quadruped_medium_states: HashMap::new(),
|
||||
bird_medium_states: HashMap::new(),
|
||||
fish_medium_states: HashMap::new(),
|
||||
dragon_states: HashMap::new(),
|
||||
object_states: HashMap::new(),
|
||||
}
|
||||
}
|
||||
@ -103,6 +105,9 @@ impl FigureMgr {
|
||||
Body::FishMedium(_) => {
|
||||
self.fish_medium_states.remove(&entity);
|
||||
}
|
||||
Body::Dragon(_) => {
|
||||
self.dragon_states.remove(&entity);
|
||||
}
|
||||
Body::Object(_) => {
|
||||
self.object_states.remove(&entity);
|
||||
}
|
||||
@ -502,6 +507,63 @@ impl FigureMgr {
|
||||
action_animation_rate,
|
||||
);
|
||||
}
|
||||
Body::Dragon(_) => {
|
||||
let state = self
|
||||
.dragon_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(renderer, DragonSkeleton::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::dragon::IdleAnimation::update_skeleton(
|
||||
&DragonSkeleton::new(),
|
||||
time,
|
||||
state.movement_time,
|
||||
&mut movement_animation_rate,
|
||||
skeleton_attr,
|
||||
),
|
||||
Run => anim::dragon::RunAnimation::update_skeleton(
|
||||
&DragonSkeleton::new(),
|
||||
(vel.0.magnitude(), time),
|
||||
state.movement_time,
|
||||
&mut movement_animation_rate,
|
||||
skeleton_attr,
|
||||
),
|
||||
Jump => anim::dragon::JumpAnimation::update_skeleton(
|
||||
&DragonSkeleton::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
|
||||
@ -535,6 +597,8 @@ impl FigureMgr {
|
||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||
self.fish_medium_states
|
||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||
self.dragon_states
|
||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||
self.object_states
|
||||
.retain(|entity, _| ecs.entities().is_alive(*entity));
|
||||
}
|
||||
@ -600,6 +664,10 @@ impl FigureMgr {
|
||||
.fish_medium_states
|
||||
.get(&entity)
|
||||
.map(|state| (state.locals(), state.bone_consts())),
|
||||
Body::Dragon(_) => self
|
||||
.dragon_states
|
||||
.get(&entity)
|
||||
.map(|state| (state.locals(), state.bone_consts())),
|
||||
Body::Object(_) => self
|
||||
.object_states
|
||||
.get(&entity)
|
||||
|
Loading…
Reference in New Issue
Block a user