Miscellaneous performance improvements.

This commit is contained in:
Joshua Yanovski 2020-08-06 13:40:35 +02:00
parent be37acf287
commit b44e442325
100 changed files with 3195 additions and 3392 deletions

6
Cargo.lock generated
View File

@ -587,7 +587,7 @@ dependencies = [
[[package]]
name = "conrod_core"
version = "0.63.0"
source = "git+https://gitlab.com/veloren/conrod.git#1ab6eccf94b16a8977a3274b31d4dbfef9cf9a30"
source = "git+https://gitlab.com/veloren/conrod.git#09d4675c4549b0fa5b6a87eacf6e1851876a80b8"
dependencies = [
"conrod_derive",
"copypasta",
@ -602,7 +602,7 @@ dependencies = [
[[package]]
name = "conrod_derive"
version = "0.63.0"
source = "git+https://gitlab.com/veloren/conrod.git#1ab6eccf94b16a8977a3274b31d4dbfef9cf9a30"
source = "git+https://gitlab.com/veloren/conrod.git#09d4675c4549b0fa5b6a87eacf6e1851876a80b8"
dependencies = [
"proc-macro2 0.4.30",
"quote 0.6.13",
@ -612,7 +612,7 @@ dependencies = [
[[package]]
name = "conrod_winit"
version = "0.63.0"
source = "git+https://gitlab.com/veloren/conrod.git#1ab6eccf94b16a8977a3274b31d4dbfef9cf9a30"
source = "git+https://gitlab.com/veloren/conrod.git#09d4675c4549b0fa5b6a87eacf6e1851876a80b8"
[[package]]
name = "const-random"

View File

@ -47,6 +47,9 @@ opt-level = 2
[profile.no_overflow.package."veloren-world"]
opt-level = 3
[profile.no_overflow.package."veloren-voxygen-anim"]
opt-level = 3
# this profile is used by developers if dev doesn't has enough debug information, the name must != debug, as debug is used by dev because....
[profile.debuginfo]
inherits= 'dev'
@ -74,6 +77,6 @@ debug = false
inherits = 'release'
debug = 1
# cpal conflict fix isn't released yet
[patch.crates-io]
# cpal conflict fix isn't released yet
winit = { git = "https://github.com/Imberflur/winit.git", branch = "macos-test" }

View File

@ -197,12 +197,14 @@ float horizon_at2(vec4 f_horizons, float alt, vec3 pos, /*float time_of_day*/vec
vec2 splay(vec2 pos) {
// const float SPLAY_MULT = 1048576.0;
float len = length(pos);
float len_2 = dot(pos, pos);
float len_pow = len_2 * sqrt(len_2);
// float len_pow = pow(len/* * SQRT_2*//* * 0.5*/, 3.0);
// vec2 splayed = pos * pow(len * 0.5, 3.0) * SPLAY_MULT;
const float SQRT_2 = sqrt(2.0) / 2.0;
// /const float CBRT_2 = cbrt(2.0) / 2.0;
// vec2 splayed = pos * (view_distance.x * SQRT_2 + pow(len * 0.5, 3.0) * (SPLAY_MULT - view_distance.x));
vec2 splayed = pos * (view_distance.x * SQRT_2 + pow(len/* * SQRT_2*//* * 0.5*/, 3.0) * (textureSize(t_alt, 0) * 32.0 - view_distance.x));
vec2 splayed = pos * (view_distance.x * SQRT_2 + len_pow * (textureSize(t_alt, 0) * 32.0/* - view_distance.x*/));
return splayed;
// Radial: pos.x = r - view_distance.x from focus_pos, pos.y = θ from cam_pos to focus_pos on xy plane.

View File

@ -17,13 +17,13 @@ const float PI = 3.141592;
const vec3 SKY_DAY_TOP = vec3(0.1, 0.5, 0.9);
const vec3 SKY_DAY_MID = vec3(0.02, 0.28, 0.8);
const vec3 SKY_DAY_BOT = vec3(0.1, 0.2, 0.3);
const vec3 DAY_LIGHT = vec3(1.5, 1.4, 1.0);//vec3(1.5, 1.4, 1.0);
const vec3 DAY_LIGHT = vec3(1.9, 1.75, 0.9);//vec3(1.5, 1.4, 1.0);
const vec3 SUN_HALO_DAY = vec3(0.35, 0.35, 0.0);
const vec3 SKY_DUSK_TOP = vec3(0.06, 0.1, 0.20);
const vec3 SKY_DUSK_MID = vec3(0.35, 0.1, 0.15);
const vec3 SKY_DUSK_BOT = vec3(0.0, 0.1, 0.23);
const vec3 DUSK_LIGHT = vec3(8.0, 1.5, 0.15);
const vec3 DUSK_LIGHT = vec3(9.0, 1.5, 0.15);
const vec3 SUN_HALO_DUSK = vec3(1.2, 0.15, 0.0);
const vec3 SKY_NIGHT_TOP = vec3(0.001, 0.001, 0.0025);
@ -35,13 +35,13 @@ const vec3 NIGHT_LIGHT = vec3(0.002, 0.02, 0.02);
// Linear RGB, scattering coefficients for atmosphere at roughly R, G, B wavelengths.
//
// See https://en.wikipedia.org/wiki/Diffuse_sky_radiation
const vec3 MU_SCATTER = vec3(0.05, 0.10, 0.23) * 2.0;
const vec3 MU_SCATTER = vec3(0.05, 0.10, 0.23) * 1.5;
const float SUN_COLOR_FACTOR = 6.0;//6.0;// * 1.5;//1.8;
const float SUN_COLOR_FACTOR = 5.0;//6.0;// * 1.5;//1.8;
const float UNDERWATER_MIST_DIST = 100.0;
const float PERSISTENT_AMBIANCE = 1.0 / 512;// 1.0 / 512; // 0.00125 // 0.1;// 0.025; // 0.1;
const float PERSISTENT_AMBIANCE = 1.0 / 80.0;// 1.0 / 512; // 0.00125 // 0.1;// 0.025; // 0.1;
//vec3 get_sun_dir(float time_of_day) {
// const float TIME_FACTOR = (PI * 2.0) / (3600.0 * 24.0);

View File

@ -427,6 +427,23 @@ void main() {
#endif
float moon_shade_frac = 1.0;//horizon_at2(f_shadow, shadow_alt, f_pos, moon_dir);
// Magic stop-gap code without any physical justification.
vec3 lerpy_norm;
if (my_norm.z/*f_norm.z*/ > 0.99999) {
lerpy_norm = vec3(0, 0, 1);
} else {
vec3 side_norm = normalize(vec3(my_norm.xy, 0));
// lerpy_norm = f_norm;
float mix_factor = clamp(abs(dot(f_orig_view_dir, side_norm)), 0, 1);
lerpy_norm = mix(
mix(my_norm, side_norm, clamp(dot(side_norm, my_norm) + 0.5, 0, 1)),
my_norm,
mix_factor
);
}
const float DIST = 0.07;
voxel_norm = normalize(mix(voxel_norm, lerpy_norm, clamp(my_norm.z * my_norm.z - (1.0 - DIST), 0, 1) / DIST));
f_pos.xyz += abs(voxel_norm) * delta_sides;
voxel_norm = voxel_norm == vec3(0.0) ? f_norm : voxel_norm;

View File

@ -19,6 +19,6 @@ num_cpus = "1.10.1"
tracing = { version = "0.1", default-features = false }
rayon = "^1.3.0"
specs = { git = "https://github.com/amethyst/specs.git", rev = "7a2e348ab2223818bad487695c66c43db88050a5" }
vek = { version = "0.11.0", features = ["serde"] }
vek = { version = "0.11.2", features = ["repr_simd", "serde"] }
hashbrown = { version = "0.7.2", features = ["rayon", "serde", "nightly"] }
authc = { git = "https://gitlab.com/veloren/auth.git", rev = "b943c85e4a38f5ec60cd18c34c73097640162bfe" }

View File

@ -13,7 +13,7 @@ specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", branch = "spec
roots = "0.0.5"
specs = { git = "https://github.com/amethyst/specs.git", features = ["serde", "storage-event-control"], rev = "7a2e348ab2223818bad487695c66c43db88050a5" }
vek = { version = "0.11.0", features = ["serde"] }
vek = { version = "0.11.2", features = ["repr_simd", "serde"] }
dot_vox = "4.0"
image = { version = "0.23.8", default-features = false, features = ["png"] }
serde = { version = "1.0.110", features = ["derive"] }

View File

@ -153,7 +153,7 @@ pub const DWARF_HAIR_COLORS: [(u8, u8, u8); 21] = [
(146, 198, 238), // Lagoon Blue
(174, 148, 161), // Matte Pink
(163, 186, 192), // Matte Green
(84, 139, 107), // Grass Green
(0, 139, 58), // Grass Green
(48, 61, 52), // Dark Green
(20, 19, 17), // Black
];
@ -625,8 +625,8 @@ impl Skin {
Self::DanariTwo => (30, 149, 201),
Self::DanariThree => (57, 120, 148),
Self::DanariFour => (40, 85, 105),
Self::ElfOne => (178, 164, 186),
Self::ElfTwo => (132, 139, 161),
Self::ElfOne => (159, 136, 173),
Self::ElfTwo => (99, 114, 161),
//Self::ElfThree => (230, 188, 198),
Self::OrcOne => (61, 130, 42),
Self::OrcTwo => (82, 117, 36),
@ -665,7 +665,7 @@ impl Skin {
Self::DanariTwo => (42, 158, 206),
Self::DanariThree => (70, 133, 160),
Self::DanariFour => (53, 96, 116),
Self::ElfOne => (190, 176, 199), //178, 164, 186
Self::ElfOne => (183, 155, 199), //178, 164, 186
Self::ElfTwo => (137, 144, 167),
//Self::ElfThree => (242, 199, 209),
Self::OrcOne => (83, 165, 56),
@ -705,7 +705,7 @@ impl Skin {
Self::DanariTwo => (25, 142, 192),
Self::DanariThree => (52, 115, 143),
Self::DanariFour => (34, 80, 99),
Self::ElfOne => (170, 155, 175), //170, 157, 179
Self::ElfOne => (148, 125, 161), //170, 157, 179
Self::ElfTwo => (126, 132, 153),
//Self::ElfThree => (217, 178, 187),
Self::OrcOne => (55, 114, 36),

View File

@ -17,7 +17,7 @@ specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", branch = "spec
tracing = "0.1"
specs = { git = "https://github.com/amethyst/specs.git", features = ["shred-derive"], rev = "7a2e348ab2223818bad487695c66c43db88050a5" }
vek = { version = "0.11.0", features = ["serde"] }
vek = { version = "0.11.2", features = ["repr_simd", "serde"] }
uvth = "3.1.1"
futures-util = "0.3"
futures-executor = "0.3"

View File

@ -95,7 +95,7 @@ pub fn handle_create_waypoint(server: &mut Server, pos: Vec3<f32>) {
.create_object(Pos(pos), comp::object::Body::CampfireLit)
.with(LightEmitter {
col: Rgb::new(1.0, 0.65, 0.2),
strength: 2.0,
strength: 5.0,
flicker: 1.0,
animated: true,
})

View File

@ -38,10 +38,7 @@ specs = { git = "https://github.com/amethyst/specs.git", rev = "7a2e348ab2223818
specs-idvs = { git = "https://gitlab.com/veloren/specs-idvs.git", branch = "specs-git" }
# Mathematics
vek = { version = "0.11.0", features = [
# "repr_simd",
"serde"
] }
vek = { version = "0.11.2", features = ["repr_simd", "serde"] }
# Controller
gilrs = { version = "0.7", features = ["serde"] }
@ -72,6 +69,7 @@ chrono = "0.4.9"
bincode = "1.2"
deunicode = "1.0"
uvth = "3.1.1"
# vec_map = { version = "0.8.2" }
const-tweaker = { version = "0.3.1", optional = true }
# Logging

View File

@ -17,7 +17,7 @@ be-dyn-lib = []
default = ["be-dyn-lib"]
[dependencies]
vek = { version = "0.11.2", features = ["serde"] }
vek = { version = "0.11.2", features = ["repr_simd", "serde"] }
common = { package = "veloren-common", path = "../../../common" }
libloading = { version = "0.6.2", optional = true }
notify = { version = "5.0.0-pre.2", optional = true }

View File

@ -39,105 +39,106 @@ impl Animation for IdleAnimation {
* 0.25,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
skeleton_attr.head.1 + torso * 0.2,
) * 1.02;
next.head.ori = Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.head.orientation =
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + torso * 0.5,
);
next.upper_torso.ori = Quaternion::rotation_z(0.0);
next.upper_torso.orientation = Quaternion::rotation_z(0.0);
next.upper_torso.scale = Vec3::one();
next.lower_torso.offset = Vec3::new(
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1 + torso * 0.15,
);
next.lower_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one() * 1.02;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.main.offset = Vec3::new(-5.0, -7.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-5.0, -7.0, 7.0);
next.main.orientation =
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
next.main.scale = Vec3::one() * 1.02;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 + torso * 0.6,
);
next.hand_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 + torso * 0.6,
);
next.hand_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + torso * 0.2,
) * 1.02;
next.leg_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + torso * 0.2,
) * 1.02;
next.leg_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 8.0;
next

View File

@ -21,92 +21,92 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1,
) / 8.0;
next.upper_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.lower_torso.offset = Vec3::new(
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one() * 1.02;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one();
next
}

View File

@ -8,91 +8,62 @@ pub use self::{
idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, wield::WieldAnimation,
};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct BipedLargeSkeleton {
head: Bone,
upper_torso: Bone,
lower_torso: Bone,
main: Bone,
shoulder_l: Bone,
shoulder_r: Bone,
hand_l: Bone,
hand_r: Bone,
leg_l: Bone,
leg_r: Bone,
foot_l: Bone,
foot_r: Bone,
torso: Bone,
control: Bone,
}
impl BipedLargeSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct BipedLargeSkeleton {
+ head,
+ upper_torso,
+ lower_torso,
+ main,
+ shoulder_l,
+ shoulder_r,
+ hand_l,
+ hand_r,
+ leg_l,
+ leg_r,
+ foot_l,
+ foot_r,
torso,
control,
});
impl Skeleton for BipedLargeSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 12;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"biped_large_compute_mats\0";
fn bone_count(&self) -> usize { 12 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "biped_large_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let upper_torso_mat = self.upper_torso.compute_base_matrix();
let lower_torso_mat = self.lower_torso.compute_base_matrix();
let main_mat = self.main.compute_base_matrix();
let shoulder_l_mat = self.shoulder_l.compute_base_matrix();
let shoulder_r_mat = self.shoulder_r.compute_base_matrix();
let hand_l_mat = self.hand_l.compute_base_matrix();
let hand_r_mat = self.hand_r.compute_base_matrix();
let leg_l_mat = self.leg_l.compute_base_matrix();
let leg_r_mat = self.leg_r.compute_base_matrix();
let torso_mat = self.torso.compute_base_matrix();
let control_mat = self.control.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let upper_torso = Mat4::<f32>::from(self.upper_torso);
(
[
FigureBoneData::new(torso_mat * upper_torso_mat * self.head.compute_base_matrix()),
FigureBoneData::new(torso_mat * upper_torso_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * lower_torso_mat),
FigureBoneData::new(torso_mat * control_mat * upper_torso_mat * main_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * shoulder_l_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * shoulder_r_mat),
FigureBoneData::new(torso_mat * control_mat * upper_torso_mat * hand_l_mat),
FigureBoneData::new(torso_mat * control_mat * upper_torso_mat * hand_r_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * lower_torso_mat * leg_l_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * lower_torso_mat * leg_r_mat),
FigureBoneData::new(self.foot_l.compute_base_matrix()),
FigureBoneData::new(self.foot_r.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
],
Vec3::default(),
)
}
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let control_mat = torso_mat * Mat4::<f32>::from(self.control) * upper_torso;
let upper_torso_mat = torso_mat * upper_torso;
let lower_torso_mat = upper_torso_mat * Mat4::<f32>::from(self.lower_torso);
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.upper_torso.interpolate(&target.upper_torso, dt);
self.lower_torso.interpolate(&target.lower_torso, dt);
self.main.interpolate(&target.main, dt);
self.shoulder_l.interpolate(&target.shoulder_l, dt);
self.shoulder_r.interpolate(&target.shoulder_r, dt);
self.hand_l.interpolate(&target.hand_l, dt);
self.hand_r.interpolate(&target.hand_r, dt);
self.leg_l.interpolate(&target.leg_l, dt);
self.leg_r.interpolate(&target.leg_r, dt);
self.foot_l.interpolate(&target.foot_l, dt);
self.foot_r.interpolate(&target.foot_r, dt);
self.torso.interpolate(&target.torso, dt);
self.control.interpolate(&target.control, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(upper_torso_mat * Mat4::<f32>::from(self.head)),
make_bone(upper_torso_mat),
make_bone(lower_torso_mat),
make_bone(control_mat * Mat4::<f32>::from(self.main)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_l)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_r)),
make_bone(control_mat * Mat4::<f32>::from(self.hand_l)),
make_bone(control_mat * Mat4::<f32>::from(self.hand_r)),
make_bone(lower_torso_mat * Mat4::<f32>::from(self.leg_l)),
make_bone(lower_torso_mat * Mat4::<f32>::from(self.leg_r)),
make_bone(base_mat * Mat4::<f32>::from(self.foot_l)),
make_bone(base_mat * Mat4::<f32>::from(self.foot_r)),
];
Vec3::default()
}
}

View File

@ -59,112 +59,114 @@ impl Animation for RunAnimation {
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.ori = Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation =
Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + shortalt * -1.5,
);
next.upper_torso.ori = Quaternion::rotation_z(short * 0.18);
next.upper_torso.orientation = Quaternion::rotation_z(short * 0.18);
next.upper_torso.scale = Vec3::one();
next.lower_torso.offset = Vec3::new(
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.ori = Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.lower_torso.orientation =
Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.lower_torso.scale = Vec3::one() * 1.02;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
next.main.offset = Vec3::new(-5.0, -7.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-5.0, -7.0, 7.0);
next.main.orientation =
Quaternion::rotation_x(PI) * Quaternion::rotation_y(0.6) * Quaternion::rotation_z(1.57);
next.main.scale = Vec3::one() * 1.02;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -3.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_x(footrotl * -0.36)
next.shoulder_l.orientation = Quaternion::rotation_x(footrotl * -0.36)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * 0.3);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothorir * -3.0,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_x(footrotr * -0.36)
next.shoulder_r.orientation = Quaternion::rotation_x(footrotr * -0.36)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.3);
next.shoulder_r.scale = Vec3::one();
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-1.0 + -skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothoril * -4.0,
skeleton_attr.hand.2 + foothoril * 1.0,
);
next.hand_l.ori = Quaternion::rotation_x(0.15 + (handhoril * -1.2).max(-0.3))
next.hand_l.orientation = Quaternion::rotation_x(0.15 + (handhoril * -1.2).max(-0.3))
* Quaternion::rotation_y(handhoril * -0.1);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
1.0 + skeleton_attr.hand.0,
skeleton_attr.hand.1 + foothorir * -4.0,
skeleton_attr.hand.2 + foothorir * 1.0,
);
next.hand_r.ori = Quaternion::rotation_x(0.15 + (handhorir * -1.2).max(-0.3))
next.hand_r.orientation = Quaternion::rotation_x(0.15 + (handhorir * -1.2).max(-0.3))
* Quaternion::rotation_y(handhorir * 0.1);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_l.ori =
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.ori =
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril * 8.5,
skeleton_attr.foot.2 + ((footvertl * 6.5).max(0.0)),
) / 8.0;
next.foot_l.ori =
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl * 0.85) * Quaternion::rotation_y(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir * 8.5,
skeleton_attr.foot.2 + ((footvertr * 6.5).max(0.0)),
) / 8.0;
next.foot_r.ori =
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr * 0.85) * Quaternion::rotation_y(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.scale = Vec3::one() / 8.0;
next
}

View File

@ -73,196 +73,199 @@ impl Animation for WieldAnimation {
let shortalt = (anim_time as f32 * lab as f32 * 16.0 + PI / 2.0).sin();
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.0);
next.main.scale = Vec3::one() * 1.02;
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0 - 7.0,
skeleton_attr.hand.1 - 7.0,
skeleton_attr.hand.2 + 10.0,
);
next.hand_l.ori = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_l.orientation = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0 - 7.0,
skeleton_attr.hand.1 - 7.0,
skeleton_attr.hand.2 + 10.0,
);
next.hand_r.ori = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_r.orientation = Quaternion::rotation_x(0.57) * Quaternion::rotation_z(1.57);
next.hand_r.scale = Vec3::one() * 1.02;
if velocity < 0.5 {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
skeleton_attr.head.1 + breathe * 0.2,
) * 1.02;
next.head.ori =
next.head.orientation =
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + breathe * 0.5,
);
next.upper_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one();
next.lower_torso.offset = Vec3::new(
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1 + breathe * 0.15,
);
next.lower_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.lower_torso.scale = Vec3::one() * 1.02;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + breathe * 0.2,
) * 1.02;
next.leg_l.ori = Quaternion::rotation_z(0.0);
next.leg_l.orientation = Quaternion::rotation_z(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2 + breathe * 0.2,
) * 1.02;
next.leg_r.ori = Quaternion::rotation_z(0.0);
next.leg_r.orientation = Quaternion::rotation_z(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_l.ori = Quaternion::rotation_z(0.0);
next.foot_l.orientation = Quaternion::rotation_z(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_r.ori = Quaternion::rotation_z(0.0);
next.foot_r.orientation = Quaternion::rotation_z(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.ori = Quaternion::rotation_z(test * 0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(test * 0.0);
next.torso.scale = Vec3::one() / 8.0;
next.control.offset = Vec3::new(7.0, 9.0, -10.0);
next.control.ori = Quaternion::rotation_x(test * 0.02)
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
* Quaternion::rotation_z(test * 0.02);
next.control.scale = Vec3::one();
} else {
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.ori = Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation =
Quaternion::rotation_z(short * -0.18) * Quaternion::rotation_x(-0.05);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + shortalt * -1.5,
);
next.upper_torso.ori = Quaternion::rotation_z(short * 0.18);
next.upper_torso.orientation = Quaternion::rotation_z(short * 0.18);
next.upper_torso.scale = Vec3::one();
next.lower_torso.offset = Vec3::new(
next.lower_torso.position = Vec3::new(
0.0,
skeleton_attr.lower_torso.0,
skeleton_attr.lower_torso.1,
);
next.lower_torso.ori =
next.lower_torso.orientation =
Quaternion::rotation_z(short * 0.15) * Quaternion::rotation_x(0.14);
next.lower_torso.scale = Vec3::one() * 1.02;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothoril * -1.0,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_x(0.5 + footrotl * -0.16)
next.shoulder_l.orientation = Quaternion::rotation_x(0.5 + footrotl * -0.16)
* Quaternion::rotation_y(0.1)
* Quaternion::rotation_z(footrotl * 0.1);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + foothorir * -1.0,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_x(0.5 + footrotr * -0.16)
next.shoulder_r.orientation = Quaternion::rotation_x(0.5 + footrotr * -0.16)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(footrotr * -0.1);
next.shoulder_r.scale = Vec3::one();
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_l.ori =
next.leg_l.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothoril * 0.3);
next.leg_l.scale = Vec3::one() * 0.98;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 0.98;
next.leg_r.ori =
next.leg_r.orientation =
Quaternion::rotation_z(short * 0.18) * Quaternion::rotation_x(foothorir * 0.3);
next.leg_r.scale = Vec3::one() * 0.98;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothoril * 8.5,
skeleton_attr.foot.2 + ((footvertl * 6.5).max(0.0)),
) / 8.0;
next.foot_l.ori =
next.foot_l.orientation =
Quaternion::rotation_x(-0.5 + footrotl * 0.85) * Quaternion::rotation_y(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1 + foothorir * 8.5,
skeleton_attr.foot.2 + ((footvertr * 6.5).max(0.0)),
) / 8.0;
next.foot_r.ori =
next.foot_r.orientation =
Quaternion::rotation_x(-0.5 + footrotr * 0.85) * Quaternion::rotation_y(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.25);
next.torso.scale = Vec3::one() / 8.0;
next.control.offset = Vec3::new(7.0, 9.0, -10.0);
next.control.ori = Quaternion::rotation_x(test * 0.02)
next.control.position = Vec3::new(7.0, 9.0, -10.0);
next.control.orientation = Quaternion::rotation_x(test * 0.02)
* Quaternion::rotation_y(test * 0.02)
* Quaternion::rotation_z(test * 0.02);
next.control.scale = Vec3::one();

View File

@ -42,54 +42,55 @@ impl Animation for FeedAnimation {
* 0.25,
);
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0 + 1.0, -2.0 + skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(duck_head_look.x)
next.head.position =
Vec3::new(0.0, skeleton_attr.head.0 + 1.0, -2.0 + skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(duck_head_look.x)
* Quaternion::rotation_x(-0.3 / skeleton_attr.feed + wave_slow_cos * 0.03 + wave * 0.1);
next.head.scale = Vec3::one();
next.torso.offset = Vec3::new(
next.torso.position = Vec3::new(
0.0,
skeleton_attr.chest.0 + skeleton_attr.feed,
-1.0 - 5.0 * (skeleton_attr.feed - 1.0) + wave_slow * 0.3 + skeleton_attr.chest.1,
) / 11.0;
next.torso.ori = Quaternion::rotation_x(-0.5 * skeleton_attr.feed)
next.torso.orientation = Quaternion::rotation_x(-0.5 * skeleton_attr.feed)
* Quaternion::rotation_y(wave_slow * 0.03);
next.torso.scale = Vec3::one() / 11.0;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_x(wave_slow_cos * 0.03);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_x(wave_slow_cos * 0.03);
next.tail.scale = Vec3::one();
next.wing_l.offset = Vec3::new(
next.wing_l.position = Vec3::new(
-skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_l.ori = Quaternion::rotation_y(0.4 - wave_slow * 0.1);
next.wing_l.orientation = Quaternion::rotation_y(0.4 - wave_slow * 0.1);
next.wing_l.scale = Vec3::one() * 1.05;
next.wing_r.offset = Vec3::new(
next.wing_r.position = Vec3::new(
skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_r.ori = Quaternion::rotation_y(-0.4 + wave_slow * 0.1);
next.wing_r.orientation = Quaternion::rotation_y(-0.4 + wave_slow * 0.1);
next.wing_r.scale = Vec3::one() * 1.05;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 11.0;
next.leg_l.ori = Quaternion::rotation_y(0.0);
next.leg_l.orientation = Quaternion::rotation_y(0.0);
next.leg_l.scale = Vec3::one() / 11.0;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 11.0;
next.leg_r.ori = Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() / 11.0;
next
}

View File

@ -30,60 +30,61 @@ impl Animation for FlyAnimation {
let center = (anim_time as f32 * lab as f32 + PI / 2.0).sin();
let centeroffset = (anim_time as f32 * lab as f32 + PI * 1.5).sin();
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0 + 0.5,
skeleton_attr.head.1 + center * 0.5 - 1.0,
);
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0 + center * 0.03);
next.head.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0 + center * 0.03);
next.head.scale = Vec3::one();
next.torso.offset = Vec3::new(
next.torso.position = Vec3::new(
0.0,
skeleton_attr.chest.0 + centeroffset * 0.6,
center * 0.6 + skeleton_attr.chest.1,
) / 11.0;
next.torso.ori = Quaternion::rotation_y(center * 0.05);
next.torso.orientation = Quaternion::rotation_y(center * 0.05);
next.torso.scale = Vec3::one() / 11.0;
next.tail.offset = Vec3::new(
next.tail.position = Vec3::new(
0.0,
skeleton_attr.tail.0,
skeleton_attr.tail.1 + centeroffset * 0.6,
);
next.tail.ori = Quaternion::rotation_x(center * 0.03);
next.tail.orientation = Quaternion::rotation_x(center * 0.03);
next.tail.scale = Vec3::one();
next.wing_l.offset = Vec3::new(
next.wing_l.position = Vec3::new(
-skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_l.ori = Quaternion::rotation_y((0.57 + footl * 1.2).max(0.0));
next.wing_l.orientation = Quaternion::rotation_y((0.57 + footl * 1.2).max(0.0));
next.wing_l.scale = Vec3::one() * 1.05;
next.wing_r.offset = Vec3::new(
next.wing_r.position = Vec3::new(
skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_r.ori = Quaternion::rotation_y((-0.57 + footr * 1.2).min(0.0));
next.wing_r.orientation = Quaternion::rotation_y((-0.57 + footr * 1.2).min(0.0));
next.wing_r.scale = Vec3::one() * 1.05;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 11.0;
next.leg_l.ori = Quaternion::rotation_x(-1.3 + footl * 0.06);
next.leg_l.orientation = Quaternion::rotation_x(-1.3 + footl * 0.06);
next.leg_l.scale = Vec3::one() / 11.0;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 11.0;
next.leg_r.ori = Quaternion::rotation_x(-1.3 + footr * 0.06);
next.leg_r.orientation = Quaternion::rotation_x(-1.3 + footr * 0.06);
next.leg_r.scale = Vec3::one() / 11.0;
next
}

View File

@ -40,53 +40,53 @@ impl Animation for IdleAnimation {
* 0.25,
);
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(duck_head_look.x)
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(duck_head_look.x)
* Quaternion::rotation_x(-duck_head_look.y.abs() + wave_slow_cos * 0.03);
next.head.scale = Vec3::one();
next.torso.offset = Vec3::new(
next.torso.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
wave_slow * 0.3 + skeleton_attr.chest.1,
) / 11.0;
next.torso.ori = Quaternion::rotation_y(wave_slow * 0.03);
next.torso.orientation = Quaternion::rotation_y(wave_slow * 0.03);
next.torso.scale = Vec3::one() / 11.0;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_x(wave_slow_cos * 0.03);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_x(wave_slow_cos * 0.03);
next.tail.scale = Vec3::one();
next.wing_l.offset = Vec3::new(
next.wing_l.position = Vec3::new(
-skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_l.ori = Quaternion::rotation_z(0.0);
next.wing_l.orientation = Quaternion::rotation_z(0.0);
next.wing_l.scale = Vec3::one() * 1.05;
next.wing_r.offset = Vec3::new(
next.wing_r.position = Vec3::new(
skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_r.ori = Quaternion::rotation_y(0.0);
next.wing_r.orientation = Quaternion::rotation_y(0.0);
next.wing_r.scale = Vec3::one() * 1.05;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 11.0;
next.leg_l.ori = Quaternion::rotation_y(0.0);
next.leg_l.orientation = Quaternion::rotation_y(0.0);
next.leg_l.scale = Vec3::one() / 11.0;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 11.0;
next.leg_r.ori = Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() / 11.0;
next
}

View File

@ -6,68 +6,46 @@ pub mod run;
// Reexports
pub use self::{feed::FeedAnimation, fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct BirdMediumSkeleton {
head: Bone,
torso: Bone,
tail: Bone,
wing_l: Bone,
wing_r: Bone,
leg_l: Bone,
leg_r: Bone,
}
impl BirdMediumSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct BirdMediumSkeleton {
+ head,
+ torso,
+ tail,
+ wing_l,
+ wing_r,
+ leg_l,
+ leg_r,
});
impl Skeleton for BirdMediumSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 7;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"bird_medium_compute_mats\0";
fn bone_count(&self) -> usize { 7 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_medium_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let torso_mat = self.torso.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
(
[
FigureBoneData::new(torso_mat * self.head.compute_base_matrix()),
FigureBoneData::new(torso_mat),
FigureBoneData::new(torso_mat * self.tail.compute_base_matrix()),
FigureBoneData::new(torso_mat * self.wing_l.compute_base_matrix()),
FigureBoneData::new(torso_mat * self.wing_r.compute_base_matrix()),
FigureBoneData::new(self.leg_l.compute_base_matrix()),
FigureBoneData::new(self.leg_r.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.torso.interpolate(&target.torso, dt);
self.tail.interpolate(&target.tail, dt);
self.wing_l.interpolate(&target.wing_l, dt);
self.wing_r.interpolate(&target.wing_r, dt);
self.leg_l.interpolate(&target.leg_l, dt);
self.leg_r.interpolate(&target.leg_r, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(torso_mat * Mat4::<f32>::from(self.head)),
make_bone(torso_mat),
make_bone(torso_mat * Mat4::<f32>::from(self.tail)),
make_bone(torso_mat * Mat4::<f32>::from(self.wing_l)),
make_bone(torso_mat * Mat4::<f32>::from(self.wing_r)),
make_bone(base_mat * Mat4::<f32>::from(self.leg_l)),
make_bone(base_mat * Mat4::<f32>::from(self.leg_r)),
];
Vec3::default()
}
}

View File

@ -30,60 +30,61 @@ impl Animation for RunAnimation {
let center = (anim_time as f32 * lab as f32 + PI / 2.0).sin();
let centeroffset = (anim_time as f32 * lab as f32 + PI * 1.5).sin();
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
skeleton_attr.head.1 + center * 0.5,
);
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0 + center * 0.03);
next.head.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0 + center * 0.03);
next.head.scale = Vec3::one();
next.torso.offset = Vec3::new(
next.torso.position = Vec3::new(
0.0,
skeleton_attr.chest.0 + centeroffset * 0.6,
center * 0.6 + skeleton_attr.chest.1,
) / 11.0;
next.torso.ori = Quaternion::rotation_y(center * 0.05);
next.torso.orientation = Quaternion::rotation_y(center * 0.05);
next.torso.scale = Vec3::one() / 11.0;
next.tail.offset = Vec3::new(
next.tail.position = Vec3::new(
0.0,
skeleton_attr.tail.0,
skeleton_attr.tail.1 + centeroffset * 0.6,
);
next.tail.ori = Quaternion::rotation_x(center * 0.03);
next.tail.orientation = Quaternion::rotation_x(center * 0.03);
next.tail.scale = Vec3::one();
next.wing_l.offset = Vec3::new(
next.wing_l.position = Vec3::new(
-skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_l.ori = Quaternion::rotation_y((footl * 0.35).max(0.0));
next.wing_l.orientation = Quaternion::rotation_y((footl * 0.35).max(0.0));
next.wing_l.scale = Vec3::one() * 1.05;
next.wing_r.offset = Vec3::new(
next.wing_r.position = Vec3::new(
skeleton_attr.wing.0,
skeleton_attr.wing.1,
skeleton_attr.wing.2,
);
next.wing_r.ori = Quaternion::rotation_y((footr * 0.35).min(0.0));
next.wing_r.orientation = Quaternion::rotation_y((footr * 0.35).min(0.0));
next.wing_r.scale = Vec3::one() * 1.05;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + footl * 1.0,
skeleton_attr.foot.2,
) / 11.0;
next.leg_l.ori = Quaternion::rotation_x(footl * 0.5);
next.leg_l.orientation = Quaternion::rotation_x(footl * 0.5);
next.leg_l.scale = Vec3::one() / 11.0;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + footr * 1.0,
skeleton_attr.foot.2,
) / 11.0;
next.leg_r.ori = Quaternion::rotation_x(footr * 0.5);
next.leg_r.orientation = Quaternion::rotation_x(footr * 0.5);
next.leg_r.scale = Vec3::one() / 11.0;
next
}

View File

@ -21,20 +21,20 @@ impl Animation for IdleAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.wing_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.scale = Vec3::one() / 10.88;
next.wing_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.scale = Vec3::one() / 10.88;
next

View File

@ -21,20 +21,20 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.wing_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.scale = Vec3::one() / 10.88;
next.wing_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.scale = Vec3::one() / 10.88;
next

View File

@ -5,70 +5,40 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone)]
pub struct BirdSmallSkeleton {
head: Bone,
torso: Bone,
wing_l: Bone,
wing_r: Bone,
}
impl BirdSmallSkeleton {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self {
Self {
head: Bone::default(),
torso: Bone::default(),
wing_l: Bone::default(),
wing_r: Bone::default(),
}
}
}
skeleton_impls!(struct BirdSmallSkeleton {
+ head,
+ torso,
+ wing_l,
+ wing_r,
});
impl Skeleton for BirdSmallSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 4;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"bird_small_compute_mats\0";
fn bone_count(&self) -> usize { 4 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let torso_mat = self.torso.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
(
[
FigureBoneData::new(self.head.compute_base_matrix() * torso_mat),
FigureBoneData::new(torso_mat),
FigureBoneData::new(self.wing_l.compute_base_matrix() * torso_mat),
FigureBoneData::new(self.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(),
],
Vec3::default(),
)
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.torso.interpolate(&target.torso, dt);
self.wing_l.interpolate(&target.wing_l, dt);
self.wing_r.interpolate(&target.wing_r, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(torso_mat * Mat4::<f32>::from(self.head)),
make_bone(torso_mat),
make_bone(torso_mat * Mat4::<f32>::from(self.wing_l)),
make_bone(torso_mat * Mat4::<f32>::from(self.wing_r)),
];
Vec3::default()
}
}

View File

@ -21,20 +21,20 @@ impl Animation for RunAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.wing_l.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.scale = Vec3::one() / 10.88;
next.wing_r.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.scale = Vec3::one() / 10.88;
next

View File

@ -60,436 +60,445 @@ impl Animation for AlphaAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.head.offset =
next.head.position =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(slow * -0.25)
next.head.orientation = Quaternion::rotation_z(slow * -0.25)
* Quaternion::rotation_x(0.0 + slow * 0.15)
* Quaternion::rotation_y(slow * -0.15);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_z(slow * 0.4)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_z(slow * 0.4)
* Quaternion::rotation_x(0.0 + slow * -0.2)
* Quaternion::rotation_y(slow * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = next.chest.ori * -0.3;
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = next.chest.orientation * -0.3;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = next.chest.ori * -0.45;
next.shorts.position =
Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = next.chest.orientation * -0.45;
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
next.control.ori = Quaternion::rotation_x(-1.4 + slow * 0.4)
next.control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
next.control.orientation = Quaternion::rotation_x(-1.4 + slow * 0.4)
* Quaternion::rotation_y(slow * -1.3)
* Quaternion::rotation_z(1.4 + slow * -0.5);
next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
slow * -3.0 + quick * 3.0 - 4.0,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(slow * 0.6)
next.l_foot.orientation = Quaternion::rotation_x(slow * 0.6)
* Quaternion::rotation_y((slow * -0.2).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
slow * 3.0 + quick * -3.0 + 5.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slow * -0.6)
next.r_foot.orientation = Quaternion::rotation_x(slow * -0.6)
* Quaternion::rotation_y((slow * 0.2).min(0.0));
next.r_foot.scale = Vec3::one();
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Dagger(_)) => {
next.head.offset =
next.head.position =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(slow * -0.25)
next.head.orientation = Quaternion::rotation_z(slow * -0.25)
* Quaternion::rotation_x(0.0 + slow * 0.15)
* Quaternion::rotation_y(slow * -0.15);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_z(slow * 0.4)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_z(slow * 0.4)
* Quaternion::rotation_x(0.0 + slow * -0.2)
* Quaternion::rotation_y(slow * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = next.chest.ori * -0.3;
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = next.chest.orientation * -0.3;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = next.chest.ori * -0.45;
next.shorts.position =
Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = next.chest.orientation * -0.45;
// TODO: Fix animation
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0);
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0);
next.l_hand.scale = Vec3::one() * 1.12;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.l_control.offset = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
next.l_control.ori = Quaternion::rotation_x(-1.4 + slow * 0.4)
next.l_control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
next.l_control.orientation = Quaternion::rotation_x(-1.4 + slow * 0.4)
* Quaternion::rotation_y(slow * -1.3)
* Quaternion::rotation_z(1.4 + slow * -0.5);
next.l_control.scale = Vec3::one();
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0);
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0);
next.r_hand.scale = Vec3::one() * 1.12;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0);
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0);
next.r_control.offset = Vec3::new(8.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(8.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
// next.r_control.offset = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
// next.r_control.ori = Quaternion::rotation_x(-1.4 + slow * 0.4)
// next.r_control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0,
// 2.0); next.r_control.orientation =
// Quaternion::rotation_x(-1.4 + slow * 0.4)
// * Quaternion::rotation_y(slow * -1.3)
// * Quaternion::rotation_z(1.4 + slow * -0.5);
// next.r_control.scale = Vec3::one();
// next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
// next.r_hand.ori = Quaternion::rotation_x(1.27);
// next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
// next.r_hand.orientation = Quaternion::rotation_x(1.27);
// next.r_hand.scale = Vec3::one() * 1.05;
// next.control.offset = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
// next.control.ori = Quaternion::rotation_x(-1.4 + slow * 0.4)
// next.control.position = Vec3::new(-10.0 + push * 5.0, 6.0 + push * 5.0, 2.0);
// next.control.orientation = Quaternion::rotation_x(-1.4 + slow * 0.4)
// * Quaternion::rotation_y(slow * -1.3)
// * Quaternion::rotation_z(1.4 + slow * -0.5);
// next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
slow * -3.0 + quick * 3.0 - 4.0,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(slow * 0.6)
next.l_foot.orientation = Quaternion::rotation_x(slow * 0.6)
* Quaternion::rotation_y((slow * -0.2).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
slow * 3.0 + quick * -3.0 + 5.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slow * -0.6)
next.r_foot.orientation = Quaternion::rotation_x(slow * -0.6)
* Quaternion::rotation_y((slow * 0.2).min(0.0));
next.r_foot.scale = Vec3::one();
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Axe(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0 + slowax * 2.0,
0.0 + skeleton_attr.head.0 + slowax * -2.0,
skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(slowax * 0.25)
next.head.orientation = Quaternion::rotation_z(slowax * 0.25)
* Quaternion::rotation_x(0.0 + slowax * 0.2)
* Quaternion::rotation_y(slowax * 0.2);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(slowax * 0.2)
next.chest.position = Vec3::new(0.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slowax * 0.2)
* Quaternion::rotation_x(0.0 + slowax * 0.2)
* Quaternion::rotation_y(slowax * 0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = next.chest.ori * -0.2;
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = next.chest.orientation * -0.2;
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = next.chest.ori * -0.15;
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = next.chest.orientation * -0.15;
next.l_hand.offset = Vec3::new(-4.0, 3.0, 2.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3)
next.l_hand.position = Vec3::new(-4.0, 3.0, 2.0);
next.l_hand.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(-2.5, 9.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3)
next.r_hand.position = Vec3::new(-2.5, 9.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(-6.0, 10.0, -5.0);
next.main.ori = Quaternion::rotation_x(1.27)
next.main.position = Vec3::new(-6.0, 10.0, -5.0);
next.main.orientation = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.8);
next.lantern.ori = Quaternion::rotation_x(slowax * -0.7 + 0.4)
next.lantern.orientation = Quaternion::rotation_x(slowax * -0.7 + 0.4)
* Quaternion::rotation_y(slowax * 0.4);
next.control.offset = Vec3::new(0.0, 0.0 + slowax * 8.2, 6.0);
next.control.ori = Quaternion::rotation_x(0.8)
next.control.position = Vec3::new(0.0, 0.0 + slowax * 8.2, 6.0);
next.control.orientation = Quaternion::rotation_x(0.8)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.7 + slowax * -1.9);
next.control.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0)
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-12.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.l_hand.position = Vec3::new(-12.0, 0.0, 0.0);
next.l_hand.orientation =
Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(3.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.position = Vec3::new(3.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.57);
next.head.offset =
next.head.position =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(slower * 0.03)
next.head.orientation = Quaternion::rotation_z(slower * 0.03)
* Quaternion::rotation_x(slowersmooth * 0.1)
* Quaternion::rotation_y(slower * 0.05 + slowersmooth * 0.06)
* Quaternion::rotation_z((slowersmooth * -0.4).max(0.0));
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(slower * 0.18 + slowersmooth * 0.15)
* Quaternion::rotation_x(0.0 + slower * 0.18 + slowersmooth * 0.15)
* Quaternion::rotation_y(slower * 0.18 + slowersmooth * 0.15);
next.chest.position = Vec3::new(0.0, 0.0, 7.0);
next.chest.orientation =
Quaternion::rotation_z(slower * 0.18 + slowersmooth * 0.15)
* Quaternion::rotation_x(0.0 + slower * 0.18 + slowersmooth * 0.15)
* Quaternion::rotation_y(slower * 0.18 + slowersmooth * 0.15);
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(slower * -0.1 + slowersmooth * -0.075)
* Quaternion::rotation_x(0.0 + slower * -0.1)
* Quaternion::rotation_y(slower * -0.1);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation =
Quaternion::rotation_z(slower * -0.1 + slowersmooth * -0.075)
* Quaternion::rotation_x(0.0 + slower * -0.1)
* Quaternion::rotation_y(slower * -0.1);
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(slower * -0.1 + slowersmooth * -0.075)
* Quaternion::rotation_x(0.0 + slower * -0.1)
* Quaternion::rotation_y(slower * -0.1);
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation =
Quaternion::rotation_z(slower * -0.1 + slowersmooth * -0.075)
* Quaternion::rotation_x(0.0 + slower * -0.1)
* Quaternion::rotation_y(slower * -0.1);
next.lantern.ori = Quaternion::rotation_x(slower * -0.7 + 0.4)
next.lantern.orientation = Quaternion::rotation_x(slower * -0.7 + 0.4)
* Quaternion::rotation_y(slower * 0.4);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
if velocity > 0.5 {
next.l_foot.offset =
next.l_foot.position =
Vec3::new(-skeleton_attr.foot.0, foot * -6.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4)
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4)
* Quaternion::rotation_z((slower * 0.3).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset =
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, foot * 6.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4)
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4)
* Quaternion::rotation_z((slower * 0.3).max(0.0));
next.r_foot.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.15);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.15);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
-2.5,
skeleton_attr.foot.2 + (slower * 2.5).max(0.0),
);
next.l_foot.ori = Quaternion::rotation_x(slower * -0.2 - 0.2)
next.l_foot.orientation = Quaternion::rotation_x(slower * -0.2 - 0.2)
* Quaternion::rotation_z((slower * 1.0).max(0.0));
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
3.5 - slower * 2.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slower * 0.1)
next.r_foot.orientation = Quaternion::rotation_x(slower * 0.1)
* Quaternion::rotation_z((slower * 0.5).max(0.0));
next.r_foot.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
//next.control.offset = Vec3::new(-4.0, 3.0 + slower * 2.0, 5.0 + slower *
// 5.0); next.control.ori = Quaternion::rotation_x()
//next.control.position = Vec3::new(-4.0, 3.0 + slower * 2.0, 5.0 + slower *
// 5.0); next.control.orientation = Quaternion::rotation_x()
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(1.4);
next.control.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0, 7.0, 1.0);
next.control.ori = Quaternion::rotation_x(-1.5 + slower * 1.5)
next.control.position = Vec3::new(-8.0, 7.0, 1.0);
next.control.orientation = Quaternion::rotation_x(-1.5 + slower * 1.5)
* Quaternion::rotation_y(slowersmooth * 0.35 - 0.3)
* Quaternion::rotation_z(1.4 + slowersmooth * 0.2);
next.control.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Staff(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
0.0 + skeleton_attr.head.0, /* + decel * 0.8 */
// Had some clipping issues
skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(decel * 0.25)
next.head.orientation = Quaternion::rotation_z(decel * 0.25)
* Quaternion::rotation_x(0.0 + decel * 0.1)
* Quaternion::rotation_y(decel * -0.1);
next.chest.ori = Quaternion::rotation_z(decel * -0.2)
next.chest.orientation = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.belt.ori = Quaternion::rotation_z(decel * -0.1)
next.belt.orientation = Quaternion::rotation_z(decel * -0.1)
* Quaternion::rotation_x(0.0 + decel * -0.1)
* Quaternion::rotation_y(decel * 0.1);
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(decel * -0.08)
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(decel * -0.08)
* Quaternion::rotation_x(0.0 + decel * -0.08)
* Quaternion::rotation_y(decel * 0.08);
next.l_hand.offset = Vec3::new(0.0, 1.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(0.0, 1.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(0.0, 0.0, 10.0);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.0, 0.0, 10.0);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -4.0);
next.main.ori = Quaternion::rotation_x(-0.3);
next.main.position = Vec3::new(0.0, 6.0, -4.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.control.offset = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0);
next.control.ori = Quaternion::rotation_x(-1.2)
next.control.position = Vec3::new(-8.0 - slow * 1.0, 3.0 - slow * 5.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.2)
* Quaternion::rotation_y(slow * 1.5)
* Quaternion::rotation_z(1.4 + slow * 0.5);
next.control.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
Some(ToolKind::Shield(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
0.0 + skeleton_attr.head.0 + decel * 0.8,
skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(decel * 0.25)
next.head.orientation = Quaternion::rotation_z(decel * 0.25)
* Quaternion::rotation_x(0.0 + decel * 0.1)
* Quaternion::rotation_y(decel * -0.1);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(decel * -0.2)
next.chest.position = Vec3::new(0.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.belt.offset = Vec3::new(0.0, 0.0, 0.0);
next.belt.ori = Quaternion::rotation_z(decel * -0.1)
next.belt.position = Vec3::new(0.0, 0.0, 0.0);
next.belt.orientation = Quaternion::rotation_z(decel * -0.1)
* Quaternion::rotation_x(0.0 + decel * -0.1)
* Quaternion::rotation_y(decel * 0.1);
next.shorts.offset = Vec3::new(0.0, 0.0, 0.0);
next.belt.ori = Quaternion::rotation_z(decel * -0.08)
next.shorts.position = Vec3::new(0.0, 0.0, 0.0);
next.belt.orientation = Quaternion::rotation_z(decel * -0.08)
* Quaternion::rotation_x(0.0 + decel * -0.08)
* Quaternion::rotation_y(decel * 0.08);
next.l_control.offset =
next.l_control.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_control.ori = Quaternion::rotation_z(-0.8)
next.l_control.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0);
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_z(0.0);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_z(0.0);
next.r_control.offset = Vec3::new(8.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(8.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0);
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0);
next.r_hand.scale = Vec3::one() * 1.01;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0);
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0);
},
Some(ToolKind::Debug(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0 + decel * 0.8,
skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_x(0.0);
next.head.orientation = Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(decel * -0.2)
next.chest.position = Vec3::new(0.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(decel * -0.2)
* Quaternion::rotation_x(0.0 + decel * -0.2)
* Quaternion::rotation_y(decel * 0.2);
next.l_hand.offset =
next.l_hand.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.l_hand.ori = Quaternion::rotation_z(-0.8)
next.l_hand.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(accel_med * -0.8)
* Quaternion::rotation_y(accel_med * -0.4);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset =
next.r_hand.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_z(-0.8)
next.r_hand.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(accel_med * -0.8)
* Quaternion::rotation_y(accel_med * -0.4);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.main.ori = Quaternion::rotation_z(-0.8)
next.main.position =
Vec3::new(-8.0 + accel_slow * 10.0, 8.0 + accel_fast * 3.0, 0.0);
next.main.orientation = Quaternion::rotation_z(-0.8)
* Quaternion::rotation_x(0.0 + accel_med * -0.8)
* Quaternion::rotation_y(0.0 + accel_med * -0.4);
next.main.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
_ => {},
}
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
@ -497,7 +506,7 @@ impl Animation for AlphaAnimation {
next.lantern.scale = Vec3::one() * 0.65;
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.l_control.scale = Vec3::one();
next.r_control.scale = Vec3::one();

View File

@ -51,85 +51,85 @@ impl Animation for BetaAnimation {
| Some(ToolKind::Sword(_))
| Some(ToolKind::Dagger(_)) => {
//INTENTION: SWORD
next.head.offset =
next.head.position =
Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(slow * -0.18)
next.head.orientation = Quaternion::rotation_z(slow * -0.18)
* Quaternion::rotation_x(-0.1 + slow * -0.28)
* Quaternion::rotation_y(0.2 + slow * 0.18);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(slow * 0.2)
next.chest.position = Vec3::new(0.0 + foot * 2.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slow * 0.2)
* Quaternion::rotation_x(slow * 0.2)
* Quaternion::rotation_y(slow * -0.1);
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(slow * 0.1)
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.04);
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.shorts.ori = Quaternion::rotation_z(slow * 0.1)
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.shorts.orientation = Quaternion::rotation_z(slow * 0.1)
* Quaternion::rotation_x(slow * 0.1)
* Quaternion::rotation_y(slow * -0.05);
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
next.main.ori = Quaternion::rotation_x(-0.3);
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.control.offset = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.ori = Quaternion::rotation_x(-1.4)
next.control.position = Vec3::new(-8.0 + slow * 1.5, 1.5 + slow * 1.0, 0.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(slow * 2.0 + 0.7)
* Quaternion::rotation_z(1.7 - slow * 0.4 + fast * 0.6);
next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
footquick * -9.5,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(footquick * 0.3)
next.l_foot.orientation = Quaternion::rotation_x(footquick * 0.3)
* Quaternion::rotation_y(footquick * -0.6);
next.r_foot.offset =
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, footquick * 9.5, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(footquick * -0.3)
next.r_foot.orientation = Quaternion::rotation_x(footquick * -0.3)
* Quaternion::rotation_y(footquick * 0.2);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
},
_ => {},
}
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.lantern.scale = Vec3::one() * 0.65;

View File

@ -44,133 +44,135 @@ impl Animation for BlockAnimation {
.sin()
* 0.15,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0 + wave_slow_cos * 0.2,
-1.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + 19.5 + wave_ultra_slow * 0.2,
);
next.head.ori = Quaternion::rotation_x(-0.25);
next.head.orientation = Quaternion::rotation_x(-0.25);
next.head.scale = Vec3::one() * 1.01 * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0 + wave_slow_cos * 0.2, 0.0, 5.0 + wave_ultra_slow * 0.2);
next.chest.ori =
next.chest.position =
Vec3::new(0.0 + wave_slow_cos * 0.2, 0.0, 5.0 + wave_ultra_slow * 0.2);
next.chest.orientation =
Quaternion::rotation_x(-0.15) * Quaternion::rotation_y(wave_ultra_slow_cos * 0.01);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0 + wave_slow_cos * 0.2, 0.0, 3.0 + wave_ultra_slow * 0.2);
next.belt.ori =
next.belt.position = Vec3::new(0.0 + wave_slow_cos * 0.2, 0.0, 3.0 + wave_ultra_slow * 0.2);
next.belt.orientation =
Quaternion::rotation_x(0.0) * Quaternion::rotation_y(wave_ultra_slow_cos * 0.008);
next.belt.scale = Vec3::one() * 1.01;
next.shorts.offset = Vec3::new(0.0 + wave_slow_cos * 0.2, 0.0, 1.0 + wave_ultra_slow * 0.2);
next.shorts.ori = Quaternion::rotation_x(0.1);
next.shorts.position =
Vec3::new(0.0 + wave_slow_cos * 0.2, 0.0, 1.0 + wave_ultra_slow * 0.2);
next.shorts.orientation = Quaternion::rotation_x(0.1);
next.shorts.scale = Vec3::one();
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.0, -6.0, -8.0);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.0, -6.0, -8.0);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -6.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(0.0, 0.0, -6.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0, 13.0, 8.0);
next.control.ori = Quaternion::rotation_x(0.2)
next.control.position = Vec3::new(-8.0, 13.0, 8.0);
next.control.orientation = Quaternion::rotation_x(0.2)
* Quaternion::rotation_y(0.4)
* Quaternion::rotation_z(-1.57);
next.control.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.orientation = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.0 + wave_ultra_slow_cos * 0.5,
-2.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.orientation = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(-6.0, 4.5, 0.0 + wave_ultra_slow * 1.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(-6.0, 4.5, 0.0 + wave_ultra_slow * 1.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
next.l_hand.position = Vec3::new(-7.0, 3.5, 6.5);
next.l_hand.orientation = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, 3.75);
next.r_hand.ori = Quaternion::rotation_x(2.07)
next.r_hand.position = Vec3::new(7.0, 2.5, 3.75);
next.r_hand.orientation = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(5.0, 8.75, 5.5);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(5.0, 8.75, 5.5);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(-0.85);
next.main.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.orientation = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.0 + wave_ultra_slow_cos * 0.5,
-2.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.orientation = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
next.main.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
4.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Shield(_)) => {
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.orientation = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.0 + wave_ultra_slow_cos * 0.5,
-2.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.orientation = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(
next.main.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
4.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
@ -178,34 +180,34 @@ impl Animation for BlockAnimation {
_ => {},
}
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.position = Vec3::new(0.0, 5.0, 0.0);
next.glider.orientation = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.orientation = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.l_control.scale = Vec3::one();

View File

@ -43,94 +43,94 @@ impl Animation for BlockIdleAnimation {
.sin()
* 0.15,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0 + wave_slow_cos * 0.2,
-1.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + wave_ultra_slow * 0.2,
);
next.head.ori = Quaternion::rotation_x(0.0);
next.head.orientation = Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * 1.01 * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0 + wave_slow_cos * 0.2,
0.0,
skeleton_attr.chest.1 + wave_ultra_slow * 0.2,
);
next.chest.ori = Quaternion::rotation_y(wave_ultra_slow_cos * 0.01);
next.chest.orientation = Quaternion::rotation_y(wave_ultra_slow_cos * 0.01);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(
next.belt.position = Vec3::new(
0.0 + wave_slow_cos * 0.2,
0.0,
skeleton_attr.belt.1 + wave_ultra_slow * 0.2,
);
next.belt.ori =
next.belt.orientation =
Quaternion::rotation_x(0.0) * Quaternion::rotation_y(wave_ultra_slow_cos * 0.008);
next.belt.scale = Vec3::one() * 1.01;
next.shorts.offset = Vec3::new(
next.shorts.position = Vec3::new(
0.0 + wave_slow_cos * 0.2,
0.0,
skeleton_attr.shorts.1 + wave_ultra_slow * 0.2,
);
next.shorts.ori = Quaternion::rotation_x(0.1);
next.shorts.orientation = Quaternion::rotation_x(0.1);
next.shorts.scale = Vec3::one();
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(0.0, -5.0, -5.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.0, -6.0, -8.0);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.0, -6.0, -8.0);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -6.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(0.0, 0.0, -6.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0, 13.0, 8.0);
next.control.ori = Quaternion::rotation_x(0.2)
next.control.position = Vec3::new(-8.0, 13.0, 8.0);
next.control.orientation = Quaternion::rotation_x(0.2)
* Quaternion::rotation_y(0.4)
* Quaternion::rotation_z(-1.57);
next.control.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.5 + wave_ultra_slow_cos * 0.5,
0.0 + wave_ultra_slow * 1.0,
);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.orientation = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
-6.0 + wave_ultra_slow_cos * 1.0,
3.0 + wave_ultra_slow_cos * 0.5,
-2.0 + wave_ultra_slow * 1.0,
);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.orientation = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(-6.0, 4.5, 0.0 + wave_ultra_slow * 1.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(-6.0, 4.5, 0.0 + wave_ultra_slow * 1.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
next.l_hand.position = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5);
next.l_hand.orientation = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5 + wave_ultra_slow * 2.0, 3.75);
next.r_hand.ori = Quaternion::rotation_x(2.07)
next.r_hand.position = Vec3::new(7.0, 2.5 + wave_ultra_slow * 2.0, 3.75);
next.r_hand.orientation = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(5.0, 8.75 + wave_ultra_slow * 2.0, 5.5);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(5.0, 8.75 + wave_ultra_slow * 2.0, 5.5);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(-0.85);
next.main.scale = Vec3::one();
@ -140,44 +140,44 @@ impl Animation for BlockIdleAnimation {
// also reduce flicker with overlapping polygons
let hand_scale = 1.12;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
// next.control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.control.position = Vec3::new(0.0, 0.0, 0.0);
// next.control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_hand.scale = Vec3::one() * hand_scale;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0 * PI)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.main.scale = Vec3::one();
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.r_hand.scale = Vec3::one() * hand_scale;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0 * PI)
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.second.scale = Vec3::one();
next.r_control.offset = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.ori = Quaternion::rotation_x(0.0 * PI)
next.r_control.position = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.orientation = Quaternion::rotation_x(0.0 * PI)
// * Quaternion::rotation_y(0.0 * PI)
// * Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
@ -187,60 +187,60 @@ impl Animation for BlockIdleAnimation {
// also reduce flicker with overlapping polygons
let hand_scale = 1.12;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
// next.control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.control.position = Vec3::new(0.0, 0.0, 0.0);
// next.control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_hand.scale = Vec3::one() * hand_scale;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0 * PI)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.r_hand.scale = Vec3::one() * hand_scale;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0 * PI)
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.second.scale = Vec3::one();
next.r_control.offset = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.ori = Quaternion::rotation_x(0.0 * PI)
next.r_control.position = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.orientation = Quaternion::rotation_x(0.0 * PI)
// * Quaternion::rotation_y(0.0 * PI)
// * Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
},
Some(ToolKind::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5);
next.l_hand.ori = Quaternion::rotation_x(2.07)
next.l_hand.position = Vec3::new(-7.0, 3.5 + wave_ultra_slow * 2.0, 6.5);
next.l_hand.orientation = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5 + wave_ultra_slow * 2.0, 3.75);
next.r_hand.ori = Quaternion::rotation_x(2.07)
next.r_hand.position = Vec3::new(7.0, 2.5 + wave_ultra_slow * 2.0, 3.75);
next.r_hand.orientation = Quaternion::rotation_x(2.07)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.2);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(5.0, 8.75 + wave_ultra_slow * 2.0, 5.5);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(5.0, 8.75 + wave_ultra_slow * 2.0, 5.5);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.35)
* Quaternion::rotation_z(-0.85);
next.main.scale = Vec3::one();
@ -254,44 +254,44 @@ impl Animation for BlockIdleAnimation {
// also reduce flicker with overlapping polygons
let hand_scale = 1.12;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
// next.control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.control.position = Vec3::new(0.0, 0.0, 0.0);
// next.control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_hand.scale = Vec3::one() * hand_scale;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0 * PI)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.main.scale = Vec3::one();
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.r_hand.scale = Vec3::one() * hand_scale;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0 * PI)
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.second.scale = Vec3::one();
next.r_control.offset = Vec3::new(3.0, 7.0, 5.0);
next.r_control.ori = Quaternion::rotation_x(0.5 * PI)
next.r_control.position = Vec3::new(3.0, 7.0, 5.0);
next.r_control.orientation = Quaternion::rotation_x(0.5 * PI)
* Quaternion::rotation_y(0.5 * PI)
* Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
@ -300,41 +300,42 @@ impl Animation for BlockIdleAnimation {
_ => {},
}
next.l_foot.offset = Vec3::new(-3.4, 0.3, skeleton_attr.foot.1 + wave_ultra_slow_cos * 0.1);
next.l_foot.ori = Quaternion::rotation_x(-0.3);
next.l_foot.position =
Vec3::new(-3.4, 0.3, skeleton_attr.foot.1 + wave_ultra_slow_cos * 0.1);
next.l_foot.orientation = Quaternion::rotation_x(-0.3);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(3.4, 1.2, skeleton_attr.foot.1 + wave_ultra_slow * 0.1);
next.r_foot.ori = Quaternion::rotation_x(0.3);
next.r_foot.position = Vec3::new(3.4, 1.2, skeleton_attr.foot.1 + wave_ultra_slow * 0.1);
next.r_foot.orientation = Quaternion::rotation_x(0.3);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.orientation = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one();

View File

@ -76,73 +76,75 @@ impl Animation for ChargeAnimation {
0.0
} * 1.3;
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
stop * -2.0,
-3.5 + stop * 2.5 + skeleton_attr.head.0,
skeleton_attr.head.1,
);
next.head.ori =
next.head.orientation =
Quaternion::rotation_z(stop * -1.0 + tilt * -2.0) * Quaternion::rotation_y(stop * -0.3);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_z(stop * 1.2 + stress * stop * 0.02 + tilt * -2.0);
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation =
Quaternion::rotation_z(stop * 1.2 + stress * stop * 0.02 + tilt * -2.0);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(stop * -0.5 + tilt * 2.0);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(stop * -0.5 + tilt * 2.0);
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(stop * -0.7 + tilt * 4.0);
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.position = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(1.8)
next.r_hand.position = Vec3::new(9.0, 1.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(9.2, 8.4, 13.2);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(9.2, 8.4, 13.2);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.control.offset = Vec3::new(
next.control.position = Vec3::new(
-7.0 + quick * 3.5 * (1.0 / (stopa + 0.1)),
6.0 + quicka * 3.5 * (1.0 / (stopa + 0.1)),
6.0 - stop * 3.0,
);
next.control.ori =
next.control.orientation =
Quaternion::rotation_x(stop * -0.2) * Quaternion::rotation_z(stop * 0.2);
next.control.scale = Vec3::one();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0 + stop * -1.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.20)
next.l_hand.position = Vec3::new(1.0, -2.0 + stop * -1.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(4.9, 1.0, -5.0);
next.r_hand.ori = Quaternion::rotation_x(1.20)
next.r_hand.position = Vec3::new(4.9, 1.0, -5.0);
next.r_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(3.0, -1.0, -14.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(3.0, -1.0, -14.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.hold.offset = Vec3::new(0.4, -0.3, -5.8);
next.hold.ori = Quaternion::rotation_x(-1.6)
next.hold.position = Vec3::new(0.4, -0.3, -5.8);
next.hold.orientation = Quaternion::rotation_x(-1.6)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(0.0);
next.hold.scale = Vec3::one() * 1.0;
next.control.offset = Vec3::new(-10.0 + stop * 13.0, 6.0 + stop * 4.0, 8.0);
next.control.ori = Quaternion::rotation_x(0.0)
next.control.position = Vec3::new(-10.0 + stop * 13.0, 6.0 + stop * 4.0, 8.0);
next.control.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(stop * -0.4)
* Quaternion::rotation_z(stop * -0.6);
next.control.scale = Vec3::one();
@ -151,76 +153,77 @@ impl Animation for ChargeAnimation {
}
if velocity > 0.2 {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0 - foot * 1.5,
skeleton_attr.foot.1 + foote * 2.0,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(foote * -0.1)
next.l_foot.orientation = Quaternion::rotation_x(foote * -0.1)
* Quaternion::rotation_z(0.4)
* Quaternion::rotation_y(0.15);
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0 + foot * 1.5,
skeleton_attr.foot.1 + foote * -1.5,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(0.0)
next.r_foot.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_z(0.4)
* Quaternion::rotation_y(0.0);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
-2.5 + stop * -1.3,
skeleton_attr.foot.2 + tilt * -4.0 * foot,
);
next.l_foot.ori = Quaternion::rotation_x(stop * -0.2 - 0.2 + stop * stress * 0.02)
* Quaternion::rotation_z(stop * 0.1)
* Quaternion::rotation_y(stop * 0.08);
next.l_foot.orientation =
Quaternion::rotation_x(stop * -0.2 - 0.2 + stop * stress * 0.02)
* Quaternion::rotation_z(stop * 0.1)
* Quaternion::rotation_y(stop * 0.08);
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
3.5 + stop * 1.5,
skeleton_attr.foot.2 + tilt * 4.0 * foot,
);
next.r_foot.ori =
next.r_foot.orientation =
Quaternion::rotation_x(stop * 0.1) * Quaternion::rotation_z(stop * 0.1);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(-0.3);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation = Quaternion::rotation_x(-0.3);
next.back.scale = Vec3::one() * 1.02;
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.scale = Vec3::one() * 0.65;
next.l_control.scale = Vec3::one();

View File

@ -49,138 +49,139 @@ impl Animation for ClimbAnimation {
.sqrt())
* ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin());
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-4.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + smootha * 0.2,
);
next.head.ori = Quaternion::rotation_z(smooth * 0.1)
next.head.orientation = Quaternion::rotation_z(smooth * 0.1)
* Quaternion::rotation_x(0.6)
* Quaternion::rotation_y(quick * 0.1);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0 + 1.0,
skeleton_attr.chest.1 + smootha * 1.1,
);
next.chest.ori = Quaternion::rotation_z(quick * 0.25)
next.chest.orientation = Quaternion::rotation_z(quick * 0.25)
* Quaternion::rotation_x(-0.15)
* Quaternion::rotation_y(quick * -0.12);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(-0.2);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation = Quaternion::rotation_x(-0.2);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(quick * 0.0)
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(quick * 0.0)
* Quaternion::rotation_x(0.1)
* Quaternion::rotation_y(quick * 0.10);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + quicka * 1.5,
5.0 + skeleton_attr.hand.2 - quick * 4.0,
);
next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5);
next.l_hand.orientation = Quaternion::rotation_x(2.2 + quicka * 0.5);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 - quicka * 1.5,
5.0 + skeleton_attr.hand.2 + quick * 4.0,
);
next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5);
next.r_hand.orientation = Quaternion::rotation_x(2.2 - quicka * 0.5);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
1.0 + skeleton_attr.foot.1,
skeleton_attr.foot.2 + quick * 2.5,
);
next.l_foot.ori = Quaternion::rotation_x(0.2 - quicka * 0.5);
next.l_foot.orientation = Quaternion::rotation_x(0.2 - quicka * 0.5);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
1.0 + skeleton_attr.foot.1,
skeleton_attr.foot.2 - quick * 2.5,
);
next.r_foot.ori = Quaternion::rotation_x(0.2 + quicka * 0.5);
next.r_foot.orientation = Quaternion::rotation_x(0.2 + quicka * 0.5);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(smootha * 0.15);
next.l_shoulder.orientation = Quaternion::rotation_x(smootha * 0.15);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(smooth * 0.15);
next.r_shoulder.orientation = Quaternion::rotation_x(smooth * 0.15);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(smooth * -0.3) * Quaternion::rotation_y(smooth * -0.3);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.torso.position = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one();

View File

@ -56,136 +56,141 @@ impl Animation for DanceAnimation {
* 0.15,
);
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(short * -0.6)
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(short * -0.6)
* Quaternion::rotation_x(0.2 + head_look.y.max(0.0) + shorte.abs() * -0.2);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + shortealt * 1.5,
);
next.chest.ori = Quaternion::rotation_z(short * 0.35)
next.chest.orientation = Quaternion::rotation_z(short * 0.35)
* Quaternion::rotation_y(shorte * 0.08)
* Quaternion::rotation_x(foot * 0.07);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(shorte * 0.25);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(shorte * 0.25);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(-0.25 + shorte * 0.1 + noisea * 0.1 + noiseb * 0.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation =
Quaternion::rotation_x(-0.25 + shorte * 0.1 + noisea * 0.1 + noiseb * 0.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(foot * 0.35);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(foot * 0.35);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
1.0 - skeleton_attr.hand.0,
2.0 + skeleton_attr.hand.1 + shortealt * -3.0,
skeleton_attr.hand.2 + shortealt * -0.75,
);
next.l_hand.ori = Quaternion::rotation_x(1.4 + foot * 0.15) * Quaternion::rotation_y(0.2);
next.l_hand.orientation =
Quaternion::rotation_x(1.4 + foot * 0.15) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
-1.0 + skeleton_attr.hand.0,
2.0 + skeleton_attr.hand.1 + shortealt * 3.0,
skeleton_attr.hand.2 + shortealt * 0.75,
);
next.r_hand.ori = Quaternion::rotation_x(1.4 + foot * -0.15) * Quaternion::rotation_y(-0.2);
next.r_hand.orientation =
Quaternion::rotation_x(1.4 + foot * -0.15) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0 + foot * 0.8,
1.5 + -skeleton_attr.foot.1 + foot * -4.0,
skeleton_attr.foot.2 + 2.0,
);
next.l_foot.ori =
next.l_foot.orientation =
Quaternion::rotation_x(foot * -0.3) * Quaternion::rotation_z(short * -0.15);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0 + foot * 0.8,
1.5 + -skeleton_attr.foot.1 + foot * 4.0,
skeleton_attr.foot.2 + 2.0,
);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.3) * Quaternion::rotation_z(short * 0.15);
next.r_foot.orientation =
Quaternion::rotation_x(foot * 0.3) * Quaternion::rotation_z(short * 0.15);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(shorte * 0.15);
next.l_shoulder.orientation = Quaternion::rotation_x(shorte * 0.15);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(shorte * -0.15);
next.r_shoulder.orientation = Quaternion::rotation_x(shorte * -0.15);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(shorte * 0.7 + 0.4) * Quaternion::rotation_y(shorte * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.3, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(short * -0.2);
next.torso.position = Vec3::new(0.0, -0.3, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(short * -0.2);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.scale = Vec3::one();

View File

@ -42,84 +42,86 @@ impl Animation for DashAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(0.0)
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7);
next.chest.position = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.orientation =
Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7);
next.belt.offset = Vec3::new(0.0, 1.0, -1.0);
next.belt.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2);
next.belt.position = Vec3::new(0.0, 1.0, -1.0);
next.belt.orientation = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2);
next.shorts.offset = Vec3::new(0.0, 3.0, -3.0);
next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.shorts.position = Vec3::new(0.0, 3.0, -3.0);
next.shorts.orientation = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
next.main.ori = Quaternion::rotation_x(-0.3);
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.ori =
next.control.position = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2);
next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.l_foot.position = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8);
next.r_foot.position = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4 - 0.8);
},
Some(ToolKind::Dagger(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(0.0)
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.ori = Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7);
next.chest.position = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.orientation =
Quaternion::rotation_x(-0.5) * Quaternion::rotation_z(-0.7);
next.belt.offset = Vec3::new(0.0, 1.0, -1.0);
next.belt.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2);
next.belt.position = Vec3::new(0.0, 1.0, -1.0);
next.belt.orientation = Quaternion::rotation_x(0.2) * Quaternion::rotation_z(0.2);
next.shorts.offset = Vec3::new(0.0, 3.0, -3.0);
next.shorts.ori = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.shorts.position = Vec3::new(0.0, 3.0, -3.0);
next.shorts.orientation = Quaternion::rotation_x(0.4) * Quaternion::rotation_z(0.3);
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
next.main.ori = Quaternion::rotation_x(-0.3);
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.ori =
next.control.position = Vec3::new(-8.0 - slow * 0.5, 3.0 - foot * 0.6, 3.0);
next.control.orientation =
Quaternion::rotation_x(-0.3) * Quaternion::rotation_z(1.1 + slow * 0.2);
next.control.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.l_foot.position = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8);
next.r_foot.position = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4 - 0.8);
},
_ => {},
}
@ -127,68 +129,68 @@ impl Animation for DashAnimation {
match second_tool_kind {
//TODO: Inventory
Some(ToolKind::Dagger(_)) => {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
-2.0 + skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(0.0)
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.ori = Quaternion::rotation_x(0.0);
next.chest.position = Vec3::new(0.0, 0.0, 7.0 + slow * 2.0);
next.chest.orientation = Quaternion::rotation_x(0.0);
next.belt.offset = Vec3::new(0.0, 1.0, -1.0);
next.belt.ori = Quaternion::rotation_x(0.0);
next.belt.position = Vec3::new(0.0, 1.0, -1.0);
next.belt.orientation = Quaternion::rotation_x(0.0);
next.shorts.offset = Vec3::new(0.0, 3.0, -3.0);
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.position = Vec3::new(0.0, 3.0, -3.0);
next.shorts.orientation = Quaternion::rotation_x(0.0);
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.offset = Vec3::new(-8.0, -10.0, 0.0);
next.l_control.position = Vec3::new(-8.0, -10.0, 0.0);
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0);
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0);
next.l_hand.scale = Vec3::one() * 1.04;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.main.scale = Vec3::one();
next.r_control.offset = Vec3::new(8.0, 10.0, 0.0);
next.r_control.position = Vec3::new(8.0, 10.0, 0.0);
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0);
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0);
next.r_hand.scale = Vec3::one() * 1.05;
next.second.offset = Vec3::new(0.0, 6.0, -1.0);
next.second.ori = Quaternion::rotation_x(-0.3);
next.second.position = Vec3::new(0.0, 6.0, -1.0);
next.second.orientation = Quaternion::rotation_x(-0.3);
next.second.scale = Vec3::one();
next.l_foot.offset = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.l_foot.position = Vec3::new(-1.4, foot * 3.0 + 2.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -0.4 - 0.8);
next.r_foot.offset = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 0.4 - 0.8);
next.r_foot.position = Vec3::new(5.4, foot * -3.0 - 1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 0.4 - 0.8);
},
_ => {},
}
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(slow * -0.7 + 0.4) * Quaternion::rotation_y(slow * 0.4);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori =
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;

View File

@ -41,141 +41,150 @@ impl Animation for EquipAnimation {
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -6.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(0.0, 0.0, -6.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset =
next.control.position =
Vec3::new(-3.0 + equip_slowa * -1.5, -5.0, 12.0 + equip_slow * 1.5);
next.control.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.control.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.control.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
next.l_hand.offset = Vec3::new(-4.0, 3.0, 6.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3)
next.l_hand.position = Vec3::new(-4.0, 3.0, 6.0);
next.l_hand.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(-2.5, 9.0, 4.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3)
next.r_hand.position = Vec3::new(-2.5, 9.0, 4.0);
next.r_hand.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_z(3.14 - 0.3)
* Quaternion::rotation_y(-0.8);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(-6.0, 10.0, -1.0);
next.main.ori = Quaternion::rotation_x(1.27)
next.main.position = Vec3::new(-6.0, 10.0, -1.0);
next.main.orientation = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(-0.3)
* Quaternion::rotation_z(-0.8);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.2) * Quaternion::rotation_y(-0.3);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation =
Quaternion::rotation_x(0.2) * Quaternion::rotation_y(-0.3);
next.control.scale = Vec3::one();
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 5.5, 3.5);
next.l_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32);
next.l_hand.position = Vec3::new(-7.0, 5.5, 3.5);
next.l_hand.orientation =
Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.32);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(8.0, 7.75, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22);
next.r_hand.position = Vec3::new(8.0, 7.75, 0.0);
next.r_hand.orientation =
Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.22);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(6.0, 7.0, 0.0);
next.main.ori = Quaternion::rotation_y(-1.35) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(6.0, 7.0, 0.0);
next.main.orientation =
Quaternion::rotation_y(-1.35) * Quaternion::rotation_z(1.57);
next.main.scale = Vec3::one();
next.control.offset =
next.control.position =
Vec3::new(-3.0 + equip_slowa * -1.5, -12.0, 12.0 + equip_slow * 1.5);
next.control.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(1.35 + 2.5);
next.control.orientation =
Quaternion::rotation_x(0.0) * Quaternion::rotation_y(1.35 + 2.5);
next.control.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.position = Vec3::new(1.0, -2.0, -5.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(9.0, 1.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(1.8)
next.r_hand.position = Vec3::new(9.0, 1.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(11.0, 9.0, 10.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(11.0, 9.0, 10.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2)
next.control.position = Vec3::new(-7.0, 6.0, 6.0);
next.control.orientation = Quaternion::rotation_x(wave_ultra_slow * 0.2)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(wave_ultra_slow_cos * 0.1);
next.control.scale = Vec3::one();
},
Some(ToolKind::Shield(_)) => {
next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.3);
next.l_hand.position = Vec3::new(-6.0, 3.5, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(-0.3);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.ori = Quaternion::rotation_x(-0.3);
next.r_hand.position = Vec3::new(-6.0, 3.0, -2.0);
next.r_hand.orientation = Quaternion::rotation_x(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(-6.0, 4.5, 0.0);
next.main.ori = Quaternion::rotation_x(-0.3);
next.main.position = Vec3::new(-6.0, 4.5, 0.0);
next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.scale = Vec3::one();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(2.0, 1.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.20)
next.l_hand.position = Vec3::new(2.0, 1.5, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(5.9, 4.5, -5.0);
next.r_hand.ori = Quaternion::rotation_x(1.20)
next.r_hand.position = Vec3::new(5.9, 4.5, -5.0);
next.r_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(3.0, 2.0, -13.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(3.0, 2.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(wave_ultra_slow * 0.2)
next.control.position = Vec3::new(-7.0, 6.0, 6.0);
next.control.orientation = Quaternion::rotation_x(wave_ultra_slow * 0.2)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(wave_ultra_slow_cos * 0.1);
next.control.scale = Vec3::one();
},
Some(ToolKind::Dagger(_)) => {
// TODO: Fix animation
// next.l_hand.offset = Vec3::new(-6.0, 3.5, 0.0);
// next.l_hand.ori = Quaternion::rotation_x(-0.3);
// next.l_hand.position = Vec3::new(-6.0, 3.5, 0.0);
// next.l_hand.orientation = Quaternion::rotation_x(-0.3);
// next.l_hand.scale = Vec3::one() * 1.01;
// next.main.offset = Vec3::new(-6.0, 4.5, 0.0);
// next.main.ori = Quaternion::rotation_x(-0.3);
// next.main.position = Vec3::new(-6.0, 4.5, 0.0);
// next.main.orientation = Quaternion::rotation_x(-0.3);
next.main.scale = Vec3::one();
// next.r_hand.offset = Vec3::new(-6.0, 3.0, -2.0);
// next.r_hand.ori = Quaternion::rotation_x(-0.3);
// next.r_hand.position = Vec3::new(-6.0, 3.0, -2.0);
// next.r_hand.orientation = Quaternion::rotation_x(-0.3);
// next.r_hand.scale = Vec3::one() * 1.01;
},
Some(ToolKind::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.ori = Quaternion::rotation_x(1.27 + wave * 0.25)
next.l_hand.position = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27 + wave * 0.25)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.ori =
next.r_hand.position = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.orientation =
Quaternion::rotation_x(1.27 + wave * 0.25) * Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(5.0, 8.75, -2.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(5.0, 8.75, -2.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(wave * -0.25);
next.main.scale = Vec3::one();
@ -196,38 +205,38 @@ impl Animation for EquipAnimation {
);
if velocity > 0.5 {
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(-0.2);
} else {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + short * 0.2,
);
next.head.ori =
next.head.orientation =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y);
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2);
next.l_foot.orientation = Quaternion::rotation_x(wave_ultra_slow_cos * 0.035 - 0.2);
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(wave_ultra_slow * 0.035);
next.r_foot.orientation = Quaternion::rotation_x(wave_ultra_slow * 0.035);
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
}
next.second.scale = match (

View File

@ -110,208 +110,214 @@ impl Animation for GlideWieldAnimation {
0.0
} * 1.3;
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-2.0 - skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 + 15.0,
);
next.l_hand.ori = Quaternion::rotation_x(3.35);
next.l_hand.orientation = Quaternion::rotation_x(3.35);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
2.0 + skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 + 15.0,
);
next.r_hand.ori = Quaternion::rotation_x(3.35);
next.r_hand.orientation = Quaternion::rotation_x(3.35);
next.r_hand.scale = Vec3::one();
if speed > 0.5 {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + short * 0.1,
);
next.head.ori = Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.1)
* Quaternion::rotation_x(head_look.y + 0.45 - lower * 0.35);
next.head.orientation =
Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.1)
* Quaternion::rotation_x(head_look.y + 0.45 - lower * 0.35);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + 2.0 + shortalt * -1.5 - lower,
);
next.chest.ori = Quaternion::rotation_z(short * 0.10 * walkintensity + tilt * -1.0)
* Quaternion::rotation_y(tilt * 2.2)
* Quaternion::rotation_x(
shortalter * 0.035 + wave_stop * speed * -0.1 + (tilt.abs()),
);
next.chest.orientation =
Quaternion::rotation_z(short * 0.10 * walkintensity + tilt * -1.0)
* Quaternion::rotation_y(tilt * 2.2)
* Quaternion::rotation_x(
shortalter * 0.035 + wave_stop * speed * -0.1 + (tilt.abs()),
);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(short * 0.1 + tilt * -1.1)
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(short * 0.1 + tilt * -1.1)
* Quaternion::rotation_y(tilt * 0.5);
next.belt.scale = Vec3::one();
next.glider.ori = Quaternion::rotation_x(0.8);
next.glider.offset = Vec3::new(0.0, -10.0, 15.0);
next.glider.orientation = Quaternion::rotation_x(0.8);
next.glider.position = Vec3::new(0.0, -10.0, 15.0);
next.glider.scale = Vec3::one() * 1.0;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori =
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation =
Quaternion::rotation_x(-0.25 + short * 0.1 + noisea * 0.1 + noiseb * 0.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(short * 0.25 + tilt * -1.5)
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(short * 0.25 + tilt * -1.5)
* Quaternion::rotation_y(tilt * 0.7);
next.shorts.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
-1.5 + skeleton_attr.foot.1 + foothoril * -8.5 * walkintensity - lower * 1.0,
2.0 + skeleton_attr.foot.2 + ((footvertl * -2.7).max(-1.0)) * walkintensity,
);
next.l_foot.ori = Quaternion::rotation_x(-0.2 + footrotl * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.l_foot.orientation =
Quaternion::rotation_x(-0.2 + footrotl * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
-1.5 + skeleton_attr.foot.1 + foothorir * -8.5 * walkintensity - lower * 1.0,
2.0 + skeleton_attr.foot.2 + ((footvertr * -2.7).max(-1.0)) * walkintensity,
);
next.r_foot.ori = Quaternion::rotation_x(-0.2 + footrotr * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.r_foot.orientation =
Quaternion::rotation_x(-0.2 + footrotr * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15 * walkintensity);
next.l_shoulder.orientation = Quaternion::rotation_x(short * 0.15 * walkintensity);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15 * walkintensity);
next.r_shoulder.orientation = Quaternion::rotation_x(short * -0.15 * walkintensity);
next.r_shoulder.scale = Vec3::one() * 1.1;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(shorte * 0.7 + 0.4) * Quaternion::rotation_y(shorte * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_y(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.scale = Vec3::one();
next.r_control.scale = Vec3::one();
} else {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + slow * 0.3 + breathe * -0.05,
);
next.head.ori =
next.head.orientation =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale + breathe * -0.05;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + slow * 0.3,
);
next.chest.ori = Quaternion::rotation_z(head_look.x * 0.6);
next.chest.orientation = Quaternion::rotation_z(head_look.x * 0.6);
next.chest.scale = Vec3::one() * 1.01 + breathe * 0.03;
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(head_look.x * -0.1);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(head_look.x * -0.1);
next.belt.scale = Vec3::one() + breathe * -0.03;
next.glider.ori = Quaternion::rotation_x(0.35);
next.glider.offset = Vec3::new(0.0, -9.0, 17.0);
next.glider.orientation = Quaternion::rotation_x(0.35);
next.glider.position = Vec3::new(0.0, -9.0, 17.0);
next.glider.scale = Vec3::one() * 1.0;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(head_look.x * -0.2);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(head_look.x * -0.2);
next.shorts.scale = Vec3::one() + breathe * -0.03;
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
@ -320,50 +326,52 @@ impl Animation for GlideWieldAnimation {
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one();

View File

@ -76,77 +76,78 @@ impl Animation for GlidingAnimation {
anim_time as f32
};
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_x(0.35 - slow * 0.10 + head_look.y)
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_x(0.35 - slow * 0.10 + head_look.y)
* Quaternion::rotation_z(head_look.x + slowa * 0.15);
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_z(slowa * 0.02);
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_z(slowa * 0.02);
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = Quaternion::rotation_z(slowa * 0.1 + tilt * tiltcancel * 12.0);
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = Quaternion::rotation_z(slowa * 0.1 + tilt * tiltcancel * 12.0);
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(slowa * 0.12 + tilt * tiltcancel * 16.0);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(slowa * 0.12 + tilt * tiltcancel * 16.0);
next.l_hand.offset = Vec3::new(-9.5, -3.0, 10.0);
next.l_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.1);
next.l_hand.position = Vec3::new(-9.5, -3.0, 10.0);
next.l_hand.orientation = Quaternion::rotation_x(-2.7 + slowa * -0.1);
next.r_hand.offset = Vec3::new(9.5, -3.0, 10.0);
next.r_hand.ori = Quaternion::rotation_x(-2.7 + slowa * -0.10);
next.r_hand.position = Vec3::new(9.5, -3.0, 10.0);
next.r_hand.orientation = Quaternion::rotation_x(-2.7 + slowa * -0.10);
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + slowa * -1.0 + tilt * tiltcancel * -35.0,
-1.0 + skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(
next.l_foot.orientation = Quaternion::rotation_x(
(wave_stop * -0.7 - quicka * -0.21 + slow * 0.19) * speed * 0.04,
) * Quaternion::rotation_z(tilt * tiltcancel * 20.0);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + slowa * 1.0 + tilt * tiltcancel * 35.0,
-1.0 + skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(
next.r_foot.orientation = Quaternion::rotation_x(
(wave_stop * -0.8 + quick * -0.25 + slowb * 0.13) * speed * 0.04,
) * Quaternion::rotation_z(tilt * tiltcancel * 20.0);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, -13.0 + slow * 0.10, 8.0);
next.glider.ori = Quaternion::rotation_x(0.8) * Quaternion::rotation_y(slowa * 0.04);
next.glider.position = Vec3::new(0.0, -13.0 + slow * 0.10, 8.0);
next.glider.orientation =
Quaternion::rotation_x(0.8) * Quaternion::rotation_y(slowa * 0.04);
next.glider.scale = Vec3::one();
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
@ -154,15 +155,15 @@ impl Animation for GlidingAnimation {
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -4.0, 10.0) / 11.0 * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.06 * speed.max(12.0) + slow * 0.04)
next.torso.position = Vec3::new(0.0, -4.0, 10.0) / 11.0 * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(-0.06 * speed.max(12.0) + slow * 0.04)
* Quaternion::rotation_y(tilt * tiltcancel * 32.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;

View File

@ -28,7 +28,7 @@ impl Animation for IdleAnimation {
let wave_ultra_slow_cos = (anim_time as f32 * 1.0 + PI / 2.0).sin();
let head_abs = ((anim_time as f32 * 0.5 + PI).sin()) + 1.0;
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + wave_ultra_slow * 0.1 + head_abs * -0.5,
@ -36,139 +36,140 @@ impl Animation for IdleAnimation {
next.head.scale = Vec3::one() * skeleton_attr.head_scale - head_abs * 0.05;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + wave_ultra_slow * 0.1,
);
next.chest.scale = Vec3::one() + head_abs * 0.05;
next.belt.offset = Vec3::new(
next.belt.position = Vec3::new(
0.0,
skeleton_attr.belt.0,
skeleton_attr.belt.1 + wave_ultra_slow * 0.1,
);
next.belt.ori = Quaternion::rotation_x(0.0);
next.belt.orientation = Quaternion::rotation_x(0.0);
next.belt.scale = Vec3::one() - head_abs * 0.05;
next.shorts.offset = Vec3::new(
next.shorts.position = Vec3::new(
0.0,
skeleton_attr.shorts.0,
skeleton_attr.shorts.1 + wave_ultra_slow * 0.1,
);
next.shorts.ori = Quaternion::rotation_x(0.0);
next.shorts.orientation = Quaternion::rotation_x(0.0);
next.shorts.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.scale = Vec3::one() * 1.02;
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + wave_ultra_slow_cos * 0.15,
skeleton_attr.hand.2 + wave_ultra_slow * 0.5,
);
next.l_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06);
next.l_hand.orientation = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 + wave_ultra_slow_cos * 0.15,
skeleton_attr.hand.2 + wave_ultra_slow * 0.5 + head_abs * -0.05,
);
next.r_hand.ori = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06);
next.r_hand.orientation = Quaternion::rotation_x(0.0 + wave_ultra_slow * -0.06);
next.r_hand.scale = Vec3::one() + head_abs * -0.05;
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = (Vec3::one() + head_abs * -0.05) * 1.15;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = (Vec3::one() + head_abs * -0.05) * 1.15;
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.0);
next.lantern.orientation = Quaternion::rotation_x(0.0);
next.lantern.scale = Vec3::one() * 0.0;
next.torso.offset = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, -0.2, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next.second.scale = match (

View File

@ -55,163 +55,164 @@ impl Animation for JumpAnimation {
0.0
} * 1.3;
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
-1.0 + skeleton_attr.head.1,
);
next.head.ori =
next.head.orientation =
Quaternion::rotation_x(0.25 + slow * 0.04) * Quaternion::rotation_z(tilt * -2.5);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 + 1.0);
next.chest.ori = Quaternion::rotation_z(tilt * -2.0);
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1 + 1.0);
next.chest.orientation = Quaternion::rotation_z(tilt * -2.0);
next.chest.scale = Vec3::one() * 1.01;
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(tilt * 2.0);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(tilt * 2.0);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_z(0.0);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation = Quaternion::rotation_z(0.0);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(tilt * 3.0);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(tilt * 3.0);
next.shorts.scale = Vec3::one();
if random > 0.5 {
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
1.0 + skeleton_attr.hand.1 + 4.0,
2.0 + skeleton_attr.hand.2 + slow * 1.5,
);
next.l_hand.ori =
next.l_hand.orientation =
Quaternion::rotation_x(1.9 + slow * 0.4) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 - 3.0,
skeleton_attr.hand.2 + slow * 1.5,
);
next.r_hand.ori =
next.r_hand.orientation =
Quaternion::rotation_x(-0.5 + slow * -0.4) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one();
} else {
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 - 3.0,
skeleton_attr.hand.2 + slow * 1.5,
);
next.l_hand.ori =
next.l_hand.orientation =
Quaternion::rotation_x(-0.5 + slow * -0.4) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
1.0 + skeleton_attr.hand.1 + 4.0,
2.0 + skeleton_attr.hand.2 + slow * 1.5,
);
next.r_hand.ori =
next.r_hand.orientation =
Quaternion::rotation_x(1.9 + slow * 0.4) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one();
};
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 - 6.0 * switch,
1.0 + skeleton_attr.foot.2 + slow * 1.5,
);
next.l_foot.ori = Quaternion::rotation_x(-1.2 * switch + slow * -0.2 * switch);
next.l_foot.orientation = Quaternion::rotation_x(-1.2 * switch + slow * -0.2 * switch);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + 6.0 * switch,
1.0 + skeleton_attr.foot.2 + slow * 1.5,
);
next.r_foot.ori = Quaternion::rotation_x(1.2 * switch + slow * 0.2 * switch);
next.r_foot.orientation = Quaternion::rotation_x(1.2 * switch + slow * 0.2 * switch);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(0.4 * switch);
next.l_shoulder.orientation = Quaternion::rotation_x(0.4 * switch);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(-0.4 * switch);
next.r_shoulder.orientation = Quaternion::rotation_x(-0.4 * switch);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(1.0 * switch + slow * 0.3 * switch)
next.lantern.orientation = Quaternion::rotation_x(1.0 * switch + slow * 0.3 * switch)
* Quaternion::rotation_y(0.6 * switch + slow * 0.3 * switch);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next.second.scale = match (

View File

@ -32,72 +32,74 @@ impl Animation for LeapAnimation {
* ((anim_time as f32 * lab as f32 * 4.0).sin());
if let Some(ToolKind::Hammer(_)) = active_tool_kind {
next.l_hand.offset = Vec3::new(-12.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.l_hand.position = Vec3::new(-12.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(3.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.position = Vec3::new(3.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.57);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0 + slower * -1.0,
skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(slower * 0.05)
next.head.orientation = Quaternion::rotation_z(slower * 0.05)
* Quaternion::rotation_x((slowersmooth * -0.25 + slower * 0.55).max(-0.2))
* Quaternion::rotation_y(slower * 0.05);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(0.0, 0.0, 7.0);
next.chest.ori = Quaternion::rotation_z(slower * 0.08 + slowersmooth * 0.15)
next.chest.position = Vec3::new(0.0, 0.0, 7.0);
next.chest.orientation = Quaternion::rotation_z(slower * 0.08 + slowersmooth * 0.15)
* Quaternion::rotation_x(-0.3 + slower * 0.45 + slowersmooth * 0.26)
* Quaternion::rotation_y(slower * 0.18 + slowersmooth * 0.15);
next.belt.offset = Vec3::new(0.0, 0.0, -2.0 + slower * -0.7);
next.belt.ori = Quaternion::rotation_z(slower * -0.16 + slowersmooth * -0.12)
next.belt.position = Vec3::new(0.0, 0.0, -2.0 + slower * -0.7);
next.belt.orientation = Quaternion::rotation_z(slower * -0.16 + slowersmooth * -0.12)
* Quaternion::rotation_x(0.0 + slower * -0.06)
* Quaternion::rotation_y(slower * -0.05);
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0 + slower * -0.7);
next.shorts.ori = Quaternion::rotation_z(slower * -0.08 + slowersmooth * -0.08)
next.shorts.position = Vec3::new(0.0, 0.0, -5.0 + slower * -0.7);
next.shorts.orientation = Quaternion::rotation_z(slower * -0.08 + slowersmooth * -0.08)
* Quaternion::rotation_x(0.0 + slower * -0.08 + slowersmooth * -0.08)
* Quaternion::rotation_y(slower * -0.07);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(slower * -0.7 + 0.4) * Quaternion::rotation_y(slower * 0.4);
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
slower * 3.0 + slowersmooth * -6.0 - 2.0,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(slower * -0.2 + slowersmooth * -0.3 - 0.2);
next.l_foot.orientation =
Quaternion::rotation_x(slower * -0.2 + slowersmooth * -0.3 - 0.2);
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
slower * 2.0 + slowersmooth * -4.0 - 1.0,
-2.0 + skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slower * -0.4 + slowersmooth * -0.6 - 1.0);
next.r_foot.orientation =
Quaternion::rotation_x(slower * -0.4 + slowersmooth * -0.6 - 1.0);
next.control.scale = Vec3::one();
next.control.offset = Vec3::new(-7.0, 7.0, 1.0);
next.control.ori = Quaternion::rotation_x(-0.7 + slower * 1.5)
next.control.position = Vec3::new(-7.0, 7.0, 1.0);
next.control.orientation = Quaternion::rotation_x(-0.7 + slower * 1.5)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.4 + slowersmooth * -0.4 + slower * 0.2);
next.control.scale = Vec3::one();
}
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.l_control.scale = Vec3::one();
next.r_control.scale = Vec3::one();
@ -110,8 +112,8 @@ impl Animation for LeapAnimation {
(_, _) => Vec3::zero(),
};
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next
}

View File

@ -33,122 +33,79 @@ pub use self::{
stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation,
};
use super::{
vek::{Vec3, Vec4},
Bone, FigureBoneData, Skeleton,
};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp;
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct CharacterSkeleton {
head: Bone,
chest: Bone,
belt: Bone,
back: Bone,
shorts: Bone,
l_hand: Bone,
r_hand: Bone,
l_foot: Bone,
r_foot: Bone,
l_shoulder: Bone,
r_shoulder: Bone,
glider: Bone,
main: Bone,
second: Bone,
lantern: Bone,
hold: Bone,
torso: Bone,
control: Bone,
l_control: Bone,
r_control: Bone,
}
impl CharacterSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct CharacterSkeleton {
+ head,
+ chest,
+ belt,
+ back,
+ shorts,
+ l_hand,
+ r_hand,
+ l_foot,
+ r_foot,
+ l_shoulder,
+ r_shoulder,
+ glider,
+ main,
+ second,
+ lantern,
+ hold,
torso,
control,
l_control,
r_control,
});
impl Skeleton for CharacterSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 16;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"character_compute_mats\0";
fn bone_count(&self) -> usize { 16 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let chest_mat = self.chest.compute_base_matrix();
let torso_mat = self.torso.compute_base_matrix();
let l_hand_mat = self.l_hand.compute_base_matrix();
let r_hand_mat = self.r_hand.compute_base_matrix();
let control_mat = self.control.compute_base_matrix();
let l_control_mat = self.l_control.compute_base_matrix();
let r_control_mat = self.r_control.compute_base_matrix();
let main_mat = self.main.compute_base_matrix();
let second_mat = self.second.compute_base_matrix();
let shorts_mat = self.shorts.compute_base_matrix();
let head_mat = self.head.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let chest_mat = torso_mat * Mat4::<f32>::from(self.chest);
let head_mat = chest_mat * Mat4::<f32>::from(self.head);
let shorts_mat = chest_mat * Mat4::<f32>::from(self.shorts);
let control_mat = chest_mat * Mat4::<f32>::from(self.control);
let l_control_mat = control_mat * Mat4::<f32>::from(self.l_control);
let r_control_mat = control_mat * Mat4::<f32>::from(self.r_control);
let lantern_final_mat =
torso_mat * chest_mat * shorts_mat * self.lantern.compute_base_matrix();
let l_hand_mat = Mat4::<f32>::from(self.l_hand);
let lantern_mat = Mat4::<f32>::from(self.lantern);
(
[
FigureBoneData::new(torso_mat * chest_mat * head_mat),
FigureBoneData::new(torso_mat * chest_mat),
FigureBoneData::new(torso_mat * chest_mat * self.belt.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat * self.back.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat * shorts_mat),
FigureBoneData::new(
torso_mat * chest_mat * control_mat * l_control_mat * l_hand_mat,
),
FigureBoneData::new(
torso_mat * chest_mat * control_mat * r_control_mat * r_hand_mat,
),
FigureBoneData::new(torso_mat * self.l_foot.compute_base_matrix()),
FigureBoneData::new(torso_mat * self.r_foot.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat * self.l_shoulder.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat * self.r_shoulder.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat * self.glider.compute_base_matrix()),
FigureBoneData::new(torso_mat * chest_mat * control_mat * l_control_mat * main_mat),
FigureBoneData::new(
torso_mat * chest_mat * control_mat * r_control_mat * second_mat,
),
FigureBoneData::new(lantern_final_mat),
FigureBoneData::new(
torso_mat
* chest_mat
* control_mat
* l_hand_mat
* self.hold.compute_base_matrix(),
),
],
(lantern_final_mat * Vec4::new(0.0, 0.0, 0.0, 1.0)).xyz(),
)
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.chest.interpolate(&target.chest, dt);
self.belt.interpolate(&target.belt, dt);
self.back.interpolate(&target.back, dt);
self.shorts.interpolate(&target.shorts, dt);
self.l_hand.interpolate(&target.l_hand, dt);
self.r_hand.interpolate(&target.r_hand, dt);
self.l_foot.interpolate(&target.l_foot, dt);
self.r_foot.interpolate(&target.r_foot, dt);
self.l_shoulder.interpolate(&target.l_shoulder, dt);
self.r_shoulder.interpolate(&target.r_shoulder, dt);
self.glider.interpolate(&target.glider, dt);
self.main.interpolate(&target.main, dt);
self.second.interpolate(&target.second, dt);
self.lantern.interpolate(&target.lantern, dt);
self.hold.interpolate(&target.hold, dt);
self.torso.interpolate(&target.torso, dt);
self.control.interpolate(&target.control, dt);
self.l_control.interpolate(&target.l_control, dt);
self.r_control.interpolate(&target.r_control, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_mat),
make_bone(chest_mat),
make_bone(chest_mat * Mat4::<f32>::from(self.belt)),
make_bone(chest_mat * Mat4::<f32>::from(self.back)),
make_bone(shorts_mat),
make_bone(l_control_mat * l_hand_mat),
make_bone(r_control_mat * Mat4::<f32>::from(self.r_hand)),
make_bone(torso_mat * Mat4::<f32>::from(self.l_foot)),
make_bone(torso_mat * Mat4::<f32>::from(self.r_foot)),
make_bone(chest_mat * Mat4::<f32>::from(self.l_shoulder)),
make_bone(chest_mat * Mat4::<f32>::from(self.r_shoulder)),
make_bone(chest_mat * Mat4::<f32>::from(self.glider)),
make_bone(l_control_mat * Mat4::<f32>::from(self.main)),
make_bone(r_control_mat * Mat4::<f32>::from(self.second)),
make_bone(shorts_mat * lantern_mat),
// FIXME: Should this be l_control_mat?
make_bone(control_mat * l_hand_mat * Mat4::<f32>::from(self.hold)),
];
// NOTE: lantern_mat.cols.w = lantern_mat * Vec4::unit_w()
(head_mat * lantern_mat.cols.w).xyz()
}
}

View File

@ -47,141 +47,142 @@ impl Animation for RollAnimation {
0.0
};
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0 + 3.0,
skeleton_attr.head.1 - 1.0,
);
next.head.ori = Quaternion::rotation_x(-0.75);
next.head.orientation = Quaternion::rotation_x(-0.75);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, -9.5 + skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_x(-0.2);
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, -9.5 + skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_x(-0.2);
next.chest.scale = Vec3::one() * 1.01;
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1 + 1.0);
next.belt.ori = Quaternion::rotation_x(0.55);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1 + 1.0);
next.belt.orientation = Quaternion::rotation_x(0.55);
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(
next.shorts.position = Vec3::new(
0.0,
skeleton_attr.shorts.0 + 4.5,
skeleton_attr.shorts.1 + 2.5,
);
next.shorts.ori = Quaternion::rotation_x(0.8);
next.shorts.orientation = Quaternion::rotation_x(0.8);
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + 1.0,
skeleton_attr.hand.2 + 2.0,
);
next.l_hand.ori = Quaternion::rotation_x(0.6);
next.l_hand.orientation = Quaternion::rotation_x(0.6);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
-1.0 + skeleton_attr.hand.0,
skeleton_attr.hand.1 + 1.0,
skeleton_attr.hand.2 + 2.0,
);
next.r_hand.ori = Quaternion::rotation_x(0.6);
next.r_hand.orientation = Quaternion::rotation_x(0.6);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
1.0 - skeleton_attr.foot.0,
skeleton_attr.foot.1 + 5.5,
skeleton_attr.foot.2 - 5.0,
);
next.l_foot.ori = Quaternion::rotation_x(0.9);
next.l_foot.orientation = Quaternion::rotation_x(0.9);
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + 5.5,
skeleton_attr.foot.2 - 5.0,
);
next.r_foot.ori = Quaternion::rotation_x(0.9);
next.r_foot.orientation = Quaternion::rotation_x(0.9);
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1 + 2.0,
skeleton_attr.shoulder.2 + 1.0,
);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, 0.0, 8.0) / 11.0 * skeleton_attr.scaler;
next.torso.ori =
next.torso.position = Vec3::new(0.0, 0.0, 8.0) / 11.0 * skeleton_attr.scaler;
next.torso.orientation =
Quaternion::rotation_x(spin * -10.0) * Quaternion::rotation_z(tilt * -10.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next.second.scale = match (

View File

@ -112,147 +112,150 @@ impl Animation for RunAnimation {
0.0
} * 1.3;
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + short * 0.1,
);
next.head.ori = Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.1)
* Quaternion::rotation_x(head_look.y + 0.45 - lower * 0.35);
next.head.orientation =
Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.1)
* Quaternion::rotation_x(head_look.y + 0.45 - lower * 0.35);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + 2.0 + shortalt * -1.5 - lower,
);
next.chest.ori = Quaternion::rotation_z(short * 0.18 * walkintensity + tilt * -0.6)
next.chest.orientation = Quaternion::rotation_z(short * 0.18 * walkintensity + tilt * -0.6)
* Quaternion::rotation_y(tilt * 1.6)
* Quaternion::rotation_x(
impact * 0.06 + shortalter * 0.035 + wave_stop * speed * -0.07 + (tilt.abs()),
);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori =
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation =
Quaternion::rotation_z(short * 0.1 + tilt * -1.1) * Quaternion::rotation_y(tilt * 0.5);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(-0.25 + short * 0.1 + noisea * 0.1 + noiseb * 0.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation =
Quaternion::rotation_x(-0.25 + short * 0.1 + noisea * 0.1 + noiseb * 0.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori =
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation =
Quaternion::rotation_z(short * 0.25 + tilt * -1.5) * Quaternion::rotation_y(tilt * 0.7);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0 + foothorir * -1.3,
3.0 + skeleton_attr.hand.1 + foothorir * -7.0 * walkintensity,
1.5 + skeleton_attr.hand.2 - foothorir * 5.5 * walkintensity,
);
next.l_hand.ori = Quaternion::rotation_x(0.6 + footrotr * -1.2 * walkintensity)
next.l_hand.orientation = Quaternion::rotation_x(0.6 + footrotr * -1.2 * walkintensity)
* Quaternion::rotation_y(footrotr * 0.4 * walkintensity);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0 + foothoril * 1.3,
3.0 + skeleton_attr.hand.1 + foothoril * -6.5 * walkintensity,
1.5 + skeleton_attr.hand.2 - foothoril * 7.0 * walkintensity,
);
next.r_hand.ori = Quaternion::rotation_x(0.6 + footrotl * -1.2 * walkintensity)
next.r_hand.orientation = Quaternion::rotation_x(0.6 + footrotl * -1.2 * walkintensity)
* Quaternion::rotation_y(footrotl * -0.4 * walkintensity);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
-1.5 + skeleton_attr.foot.1 + foothoril * -8.5 * walkintensity - lower * 1.0,
2.0 + skeleton_attr.foot.2 + ((footvertl * -2.7).max(-1.0)) * walkintensity,
);
next.l_foot.ori = Quaternion::rotation_x(-0.2 + footrotl * -1.2 * walkintensity)
next.l_foot.orientation = Quaternion::rotation_x(-0.2 + footrotl * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
-1.5 + skeleton_attr.foot.1 + foothorir * -8.5 * walkintensity - lower * 1.0,
2.0 + skeleton_attr.foot.2 + ((footvertr * -2.7).max(-1.0)) * walkintensity,
);
next.r_foot.ori = Quaternion::rotation_x(-0.2 + footrotr * -1.2 * walkintensity)
next.r_foot.orientation = Quaternion::rotation_x(-0.2 + footrotr * -1.2 * walkintensity)
* Quaternion::rotation_y(tilt * 1.8);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15 * walkintensity);
next.l_shoulder.orientation = Quaternion::rotation_x(short * 0.15 * walkintensity);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15 * walkintensity);
next.r_shoulder.orientation = Quaternion::rotation_x(short * -0.15 * walkintensity);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(shorte * 0.7 + 0.4) * Quaternion::rotation_y(shorte * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.3, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_y(0.0);
next.torso.position = Vec3::new(0.0, -0.3, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
next.control.ori = Quaternion::rotation_x(0.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
next.control.orientation = Quaternion::rotation_x(0.0);
next.control.scale = Vec3::one();
next.l_control.scale = Vec3::one();

View File

@ -38,71 +38,73 @@ impl Animation for ShootAnimation {
let exp = ((anim_time as f32).powf(0.3 as f32)).min(1.2);
next.head.offset = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(exp * -0.4)
next.head.position = Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(exp * -0.4)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(exp * 0.1);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0 - exp * 1.5,
skeleton_attr.chest.1,
);
next.chest.ori = Quaternion::rotation_z(0.4 + exp * 1.0)
next.chest.orientation = Quaternion::rotation_z(0.4 + exp * 1.0)
* Quaternion::rotation_x(0.0 + exp * 0.2)
* Quaternion::rotation_y(exp * -0.08);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + exp * 1.0, skeleton_attr.belt.1);
next.belt.ori = next.chest.ori * -0.1;
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0 + exp * 1.0, skeleton_attr.belt.1);
next.belt.orientation = next.chest.orientation * -0.1;
next.shorts.offset = Vec3::new(
next.shorts.position = Vec3::new(
0.0,
skeleton_attr.shorts.0 + exp * 1.0,
skeleton_attr.shorts.1,
);
next.shorts.ori = next.chest.ori * -0.08;
next.shorts.orientation = next.chest.orientation * -0.08;
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.position = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.ori = Quaternion::rotation_x(1.8)
next.r_hand.position = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(9.2, 8.4, 13.2);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(9.2, 8.4, 13.2);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.control.offset = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0);
next.control.ori = Quaternion::rotation_x(exp * 1.3)
next.control.position = Vec3::new(-7.0, 6.0, 6.0 - exp * 5.0);
next.control.orientation = Quaternion::rotation_x(exp * 1.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(exp * 1.5);
next.control.scale = Vec3::one();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(1.0 - exp * 2.0, -4.0 - exp * 4.0, -1.0 + exp * 6.0);
next.l_hand.ori = Quaternion::rotation_x(1.20)
next.l_hand.position =
Vec3::new(1.0 - exp * 2.0, -4.0 - exp * 4.0, -1.0 + exp * 6.0);
next.l_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6 + exp * 0.8)
* Quaternion::rotation_z(-0.3 + exp * 0.9);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(4.9, 3.0, -4.0);
next.r_hand.ori = Quaternion::rotation_x(1.20)
next.r_hand.position = Vec3::new(4.9, 3.0, -4.0);
next.r_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(3.0, 2.0, -13.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(3.0, 2.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.control.offset = Vec3::new(-9.0, 6.0, 8.0);
next.control.ori = Quaternion::rotation_x(exp * 0.4)
next.control.position = Vec3::new(-9.0, 6.0, 8.0);
next.control.orientation = Quaternion::rotation_x(exp * 0.4)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.scale = Vec3::one();
@ -110,81 +112,82 @@ impl Animation for ShootAnimation {
_ => {},
}
if velocity > 0.5 {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0 - foot * 1.0 + exp * -1.0,
foote * 0.8 + exp * 1.5,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(exp * 0.5)
next.l_foot.orientation = Quaternion::rotation_x(exp * 0.5)
* Quaternion::rotation_z(exp * 0.4)
* Quaternion::rotation_y(0.15);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0 + foot * 1.0 + exp * 1.0,
foote * -0.8 + exp * -1.0,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(exp * -0.5)
next.r_foot.orientation = Quaternion::rotation_x(exp * -0.5)
* Quaternion::rotation_z(exp * 0.4)
* Quaternion::rotation_y(0.0);
next.r_foot.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.15);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(-0.15);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
} else {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
-2.5,
skeleton_attr.foot.2 + exp * 2.5,
);
next.l_foot.ori =
next.l_foot.orientation =
Quaternion::rotation_x(exp * -0.2 - 0.2) * Quaternion::rotation_z(exp * 1.0);
next.r_foot.offset =
next.r_foot.position =
Vec3::new(skeleton_attr.foot.0, 3.5 - exp * 2.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(exp * 0.1) * Quaternion::rotation_z(exp * 0.5);
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(0.0);
next.r_foot.orientation =
Quaternion::rotation_x(exp * 0.1) * Quaternion::rotation_z(exp * 0.5);
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
next.back.offset = Vec3::new(0.0, -2.8, 7.25);
next.back.ori = Quaternion::rotation_x(-0.3);
next.back.position = Vec3::new(0.0, -2.8, 7.25);
next.back.orientation = Quaternion::rotation_x(-0.3);
next.back.scale = Vec3::one() * 1.02;
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.position = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
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(0.0);
next.r_shoulder.position = Vec3::new(5.0, 0.0, 4.7);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.position = Vec3::new(0.0, 5.0, 0.0);
next.glider.orientation = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(exp * -0.7 + 0.4) * Quaternion::rotation_y(exp * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.hold.offset = Vec3::new(17.5, -25.0, -10.5);
next.hold.ori = Quaternion::rotation_x(-1.6)
next.hold.position = Vec3::new(17.5, -25.0, -10.5);
next.hold.orientation = Quaternion::rotation_x(-1.6)
* Quaternion::rotation_y(-0.1)
* Quaternion::rotation_z(0.0);
next.hold.scale = Vec3::one() * 0.0;
next.l_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next.second.scale = match (

View File

@ -41,133 +41,135 @@ impl Animation for SitAnimation {
.sin()
* 0.125,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + slow * 0.1 + stop * -0.8,
);
next.head.ori = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1)
next.head.orientation = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1)
* Quaternion::rotation_x((slowa * -0.1 + slow * 0.1 + head_look.y).abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0 + stop * -0.4,
skeleton_attr.chest.1 + slow * 0.1 + stop * -0.8,
);
next.chest.ori = Quaternion::rotation_x(stop * 0.15);
next.chest.orientation = Quaternion::rotation_x(stop * 0.15);
next.chest.scale = Vec3::one() + slow_abs * 0.05;
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + stop * 1.2, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_x(stop * 0.3);
next.belt.position =
Vec3::new(0.0, skeleton_attr.belt.0 + stop * 1.2, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_x(stop * 0.3);
next.belt.scale = (Vec3::one() + slow_abs * 0.05) * 1.02;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(
next.shorts.position = Vec3::new(
0.0,
skeleton_attr.shorts.0 + stop * 2.5,
skeleton_attr.shorts.1 + stop * 0.6,
);
next.shorts.ori = Quaternion::rotation_x(stop * 0.6);
next.shorts.orientation = Quaternion::rotation_x(stop * 0.6);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + slowa * 0.15,
skeleton_attr.hand.2 + slow * 0.7 + stop * -2.0,
);
next.l_hand.ori = Quaternion::rotation_x(slowa * -0.1 + slow * 0.1);
next.l_hand.orientation = Quaternion::rotation_x(slowa * -0.1 + slow * 0.1);
next.l_hand.scale = Vec3::one() + slow_abs * -0.05;
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 + slowa * 0.15,
skeleton_attr.hand.2 + slow * 0.7 + stop * -2.0,
);
next.r_hand.ori = Quaternion::rotation_x(slow * -0.1 + slowa * 0.1);
next.r_hand.orientation = Quaternion::rotation_x(slow * -0.1 + slowa * 0.1);
next.r_hand.scale = Vec3::one() + slow_abs * -0.05;
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1,
3.0 + skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1);
next.l_foot.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 1.2 + slow * 0.1);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
4.0 + skeleton_attr.foot.1,
3.0 + skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1);
next.r_foot.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 1.2 + slowa * 0.1);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
next.l_shoulder.scale = (Vec3::one() + slow_abs * -0.05) * 1.15;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(0.0);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = (Vec3::one() + slow_abs * -0.05) * 1.15;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -0.2, stop * -0.16) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, -0.2, stop * -0.16) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one();

View File

@ -48,46 +48,46 @@ impl Animation for SpinAnimation {
| Some(ToolKind::Sword(_))
| Some(ToolKind::Dagger(_)) => {
//INTENTION: SWORD
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.27);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation = Quaternion::rotation_x(1.27);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.27);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation = Quaternion::rotation_x(1.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 6.0, -1.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(0.0, 6.0, -1.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0);
next.control.ori = Quaternion::rotation_x(-1.7)
next.control.position = Vec3::new(-4.5 + spinhalf * 4.0, 11.0, 8.0);
next.control.orientation = Quaternion::rotation_x(-1.7)
* Quaternion::rotation_y(0.2 + spin * -2.0)
* Quaternion::rotation_z(1.4 + spin * 0.1);
next.control.scale = Vec3::one();
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0 + spin * -0.8,
skeleton_attr.head.1,
);
next.head.ori = Quaternion::rotation_z(spin * -0.25)
next.head.orientation = Quaternion::rotation_z(spin * -0.25)
* Quaternion::rotation_x(0.0 + spin * -0.1)
* Quaternion::rotation_y(spin * -0.2);
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.ori = Quaternion::rotation_z(spin * 0.1)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1);
next.chest.orientation = Quaternion::rotation_z(spin * 0.1)
* Quaternion::rotation_x(0.0 + spin * 0.1)
* Quaternion::rotation_y(decel * -0.2);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 0.0, -2.0);
next.belt.ori = next.chest.ori * -0.1;
next.belt.position = Vec3::new(0.0, 0.0, -2.0);
next.belt.orientation = next.chest.orientation * -0.1;
next.belt.scale = Vec3::one();
next.shorts.offset = Vec3::new(0.0, 0.0, -5.0);
next.belt.ori = next.chest.ori * -0.08;
next.shorts.position = Vec3::new(0.0, 0.0, -5.0);
next.belt.orientation = next.chest.orientation * -0.08;
next.shorts.scale = Vec3::one();
next.torso.offset = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z((spin * 7.0).max(0.3))
next.torso.position = Vec3::new(0.0, 0.0, 0.1) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_z((spin * 7.0).max(0.3))
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
@ -95,41 +95,41 @@ impl Animation for SpinAnimation {
_ => {},
}
next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
next.l_foot.ori = Quaternion::rotation_x(foot * -1.2);
next.l_foot.position = Vec3::new(-skeleton_attr.foot.0, foot * 1.0, skeleton_attr.foot.2);
next.l_foot.orientation = Quaternion::rotation_x(foot * -1.2);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(skeleton_attr.foot.0, foot * -1.0, skeleton_attr.foot.2);
next.r_foot.ori = Quaternion::rotation_x(foot * 1.2);
next.r_foot.position = Vec3::new(skeleton_attr.foot.0, foot * -1.0, skeleton_attr.foot.2);
next.r_foot.orientation = Quaternion::rotation_x(foot * 1.2);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.ori = Quaternion::rotation_x(0.0);
next.l_shoulder.position = Vec3::new(-5.0, 0.0, 4.7);
next.l_shoulder.orientation = Quaternion::rotation_x(0.0);
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(0.0);
next.r_shoulder.position = Vec3::new(5.0, 0.0, 4.7);
next.r_shoulder.orientation = Quaternion::rotation_x(0.0);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 5.0, 0.0);
next.glider.ori = Quaternion::rotation_y(0.0);
next.glider.position = Vec3::new(0.0, 5.0, 0.0);
next.glider.orientation = Quaternion::rotation_y(0.0);
next.glider.scale = Vec3::one() * 0.0;
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori =
next.lantern.orientation =
Quaternion::rotation_x(spin * -0.7 + 0.4) * Quaternion::rotation_y(spin * 0.4);
next.lantern.scale = Vec3::one() * 0.65;
next.l_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_control.ori = Quaternion::rotation_x(0.0);
next.l_control.position = Vec3::new(0.0, 0.0, 0.0);
next.l_control.orientation = Quaternion::rotation_x(0.0);
next.l_control.scale = Vec3::one();
next.r_control.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_control.ori = Quaternion::rotation_x(0.0);
next.r_control.position = Vec3::new(0.0, 0.0, 0.0);
next.r_control.orientation = Quaternion::rotation_x(0.0);
next.r_control.scale = Vec3::one();
next.second.scale = match (

View File

@ -50,111 +50,112 @@ impl Animation for SpinMeleeAnimation {
let quick = (anim_time as f32 * lab as f32 * 8.0).sin();
if let Some(ToolKind::Axe(_)) = active_tool_kind {
next.l_hand.offset = Vec3::new(-0.5, 0.0, 4.0);
next.l_hand.ori = Quaternion::rotation_x(PI / 2.0)
next.l_hand.position = Vec3::new(-0.5, 0.0, 4.0);
next.l_hand.orientation = Quaternion::rotation_x(PI / 2.0)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_y(PI);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(0.5, 0.0, -2.5);
next.r_hand.ori = Quaternion::rotation_x(PI / 2.0)
next.r_hand.position = Vec3::new(0.5, 0.0, -2.5);
next.r_hand.orientation = Quaternion::rotation_x(PI / 2.0)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_y(0.0);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(-0.0, -2.0, -1.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(-0.0, -2.0, -1.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(0.0, 16.0, 3.0);
next.control.ori = Quaternion::rotation_x(-1.4)
next.control.position = Vec3::new(0.0, 16.0, 3.0);
next.control.orientation = Quaternion::rotation_x(-1.4)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(1.4);
next.control.scale = Vec3::one();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(0.0)
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(-0.15)
* Quaternion::rotation_y(0.08);
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0 - 3.0,
skeleton_attr.chest.1 - 2.0,
);
next.chest.ori = Quaternion::rotation_z(0.0)
next.chest.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.3);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, 1.0, -1.0);
next.belt.ori = Quaternion::rotation_z(0.0)
next.belt.position = Vec3::new(0.0, 1.0, -1.0);
next.belt.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.4)
* Quaternion::rotation_y(0.0);
next.belt.scale = Vec3::one() * 0.98;
next.shorts.offset = Vec3::new(0.0, 3.0, -2.5);
next.shorts.ori = Quaternion::rotation_z(0.0)
next.shorts.position = Vec3::new(0.0, 3.0, -2.5);
next.shorts.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.7)
* Quaternion::rotation_y(0.0);
next.shorts.scale = Vec3::one();
next.torso.offset = Vec3::new(
next.torso.position = Vec3::new(
-xshift * (anim_time as f32).min(0.6),
-yshift * (anim_time as f32).min(0.6),
0.0,
) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_z(spin * -16.0)
next.torso.orientation = Quaternion::rotation_z(spin * -16.0)
* Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
}
if velocity.z.abs() > 0.1 {
next.l_foot.offset = Vec3::new(-skeleton_attr.foot.0, 8.0, skeleton_attr.foot.2 + 2.0);
next.l_foot.ori = Quaternion::rotation_x(1.0) * Quaternion::rotation_z(0.0);
next.l_foot.position =
Vec3::new(-skeleton_attr.foot.0, 8.0, skeleton_attr.foot.2 + 2.0);
next.l_foot.orientation = Quaternion::rotation_x(1.0) * Quaternion::rotation_z(0.0);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(skeleton_attr.foot.0, 8.0, skeleton_attr.foot.2 + 2.0);
next.r_foot.ori = Quaternion::rotation_x(1.0);
next.r_foot.position = Vec3::new(skeleton_attr.foot.0, 8.0, skeleton_attr.foot.2 + 2.0);
next.r_foot.orientation = Quaternion::rotation_x(1.0);
next.r_foot.scale = Vec3::one();
} else if speed < 0.5 {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
2.0 + quick * -6.0,
skeleton_attr.foot.2,
);
next.l_foot.ori =
next.l_foot.orientation =
Quaternion::rotation_x(0.5 + slowersmooth * 0.2) * Quaternion::rotation_z(0.0);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(skeleton_attr.foot.0, 4.0, skeleton_attr.foot.2);
next.r_foot.ori =
next.r_foot.position = Vec3::new(skeleton_attr.foot.0, 4.0, skeleton_attr.foot.2);
next.r_foot.orientation =
Quaternion::rotation_x(0.5 - slowersmooth * 0.2) * Quaternion::rotation_y(-0.4);
next.r_foot.scale = Vec3::one();
} else {
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
2.0 + quick * -6.0,
skeleton_attr.foot.2,
);
next.l_foot.ori =
next.l_foot.orientation =
Quaternion::rotation_x(0.5 + slowersmooth * 0.2) * Quaternion::rotation_z(0.0);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
2.0 + quick * 6.0,
skeleton_attr.foot.2,
);
next.r_foot.ori =
next.r_foot.orientation =
Quaternion::rotation_x(0.5 - slowersmooth * 0.2) * Quaternion::rotation_z(0.0);
next.r_foot.scale = Vec3::one();
};
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_z(0.0)
next.lantern.orientation = Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.7)
* Quaternion::rotation_y(-0.8);
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
next.l_control.scale = Vec3::one();
next.r_control.scale = Vec3::one();

View File

@ -39,141 +39,142 @@ impl Animation for StandAnimation {
.sin()
* 0.15,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + slow * 0.3 + breathe * -0.05,
);
next.head.ori = Quaternion::rotation_z(head_look.x)
next.head.orientation = Quaternion::rotation_z(head_look.x)
* Quaternion::rotation_x(impact * -0.02 + head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale + breathe * -0.05;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + slow * 0.3 + impact * 0.2,
);
next.chest.ori =
next.chest.orientation =
Quaternion::rotation_z(head_look.x * 0.6) * Quaternion::rotation_x(impact * 0.04);
next.chest.scale = Vec3::one() * 1.01 + breathe * 0.03;
next.belt.offset = Vec3::new(
next.belt.position = Vec3::new(
0.0,
skeleton_attr.belt.0 + impact * 0.005,
skeleton_attr.belt.1,
);
next.belt.ori =
next.belt.orientation =
Quaternion::rotation_z(head_look.x * -0.1) * Quaternion::rotation_x(impact * -0.03);
next.belt.scale = Vec3::one() + breathe * -0.03;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(
next.shorts.position = Vec3::new(
0.0,
skeleton_attr.shorts.0 + impact * -0.2,
skeleton_attr.shorts.1,
);
next.shorts.ori =
next.shorts.orientation =
Quaternion::rotation_z(head_look.x * -0.2) * Quaternion::rotation_x(impact * -0.04);
next.shorts.scale = Vec3::one() + breathe * -0.03;
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1 + slow * 0.15 - impact * 0.2,
skeleton_attr.hand.2 + slow * 0.5 + impact * -0.1,
);
next.l_hand.ori = Quaternion::rotation_x(slow * -0.06 + impact * -0.1);
next.l_hand.orientation = Quaternion::rotation_x(slow * -0.06 + impact * -0.1);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1 + slow * 0.15 - impact * 0.2,
skeleton_attr.hand.2 + slow * 0.5 + impact * -0.1,
);
next.r_hand.ori = Quaternion::rotation_x(slow * -0.06 + impact * -0.1);
next.r_hand.orientation = Quaternion::rotation_x(slow * -0.06 + impact * -0.1);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 - impact * 0.15,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(impact * 0.02);
next.l_foot.orientation = Quaternion::rotation_x(impact * 0.02);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + impact * 0.15,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(impact * -0.02);
next.r_foot.orientation = Quaternion::rotation_x(impact * -0.02);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, 0.0, 0.) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.control.scale = Vec3::one();

View File

@ -72,132 +72,135 @@ impl Animation for SwimAnimation {
} else {
0.0
} * 1.3;
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.0 + skeleton_attr.head.0,
skeleton_attr.head.1 - 1.0 + short * 0.3,
);
next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.4)
next.head.orientation = Quaternion::rotation_z(head_look.x - short * 0.4)
* Quaternion::rotation_x(head_look.y + 0.35 + speed * 0.045);
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + short * 1.3,
);
next.chest.ori = Quaternion::rotation_z(short * 0.4);
next.chest.orientation = Quaternion::rotation_z(short * 0.4);
next.chest.scale = Vec3::one();
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_z(short * 0.30);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation = Quaternion::rotation_z(short * 0.30);
next.belt.scale = Vec3::one();
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_z(0.0);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation = Quaternion::rotation_z(0.0);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(short * 0.5);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(short * 0.5);
next.shorts.scale = Vec3::one();
next.l_hand.offset = Vec3::new(
next.l_hand.position = Vec3::new(
-skeleton_attr.hand.0,
1.5 + skeleton_attr.hand.1 - foot * 1.2,
2.0 + skeleton_attr.hand.2 + foot * -3.0,
);
next.l_hand.ori = Quaternion::rotation_x(0.8 + foot * -0.6) * Quaternion::rotation_y(0.2);
next.l_hand.orientation =
Quaternion::rotation_x(0.8 + foot * -0.6) * Quaternion::rotation_y(0.2);
next.l_hand.scale = Vec3::one();
next.r_hand.offset = Vec3::new(
next.r_hand.position = Vec3::new(
skeleton_attr.hand.0,
1.5 + skeleton_attr.hand.1 + foot * 1.2,
2.0 + skeleton_attr.hand.2 + foot * 3.0,
);
next.r_hand.ori = Quaternion::rotation_x(0.8 + foot * 0.6) * Quaternion::rotation_y(-0.2);
next.r_hand.orientation =
Quaternion::rotation_x(0.8 + foot * 0.6) * Quaternion::rotation_y(-0.2);
next.r_hand.scale = Vec3::one();
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + foot * 1.2,
-3.0 + skeleton_attr.foot.2 + foot * 3.5,
);
next.l_foot.ori = Quaternion::rotation_x(-1.1 + foot * 0.6);
next.l_foot.orientation = Quaternion::rotation_x(-1.1 + foot * 0.6);
next.l_foot.scale = Vec3::one();
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 - foot * 1.2,
-3.0 + skeleton_attr.foot.2 + foot * -3.5,
);
next.r_foot.ori = Quaternion::rotation_x(-1.1 + foot * -0.6);
next.r_foot.orientation = Quaternion::rotation_x(-1.1 + foot * -0.6);
next.r_foot.scale = Vec3::one();
next.l_shoulder.offset = Vec3::new(
next.l_shoulder.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15);
next.l_shoulder.orientation = Quaternion::rotation_x(short * 0.15);
next.l_shoulder.scale = Vec3::one() * 1.1;
next.r_shoulder.offset = Vec3::new(
next.r_shoulder.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15);
next.r_shoulder.orientation = Quaternion::rotation_x(short * -0.15);
next.r_shoulder.scale = Vec3::one() * 1.1;
next.glider.offset = Vec3::new(0.0, 0.0, 10.0);
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.main.offset = Vec3::new(-4.0, -5.0, 7.0);
next.main.ori =
next.main.position = Vec3::new(-4.0, -5.0, 7.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.main.offset = Vec3::new(-0.0, -5.0, 3.0);
next.main.ori =
next.main.position = Vec3::new(-0.0, -5.0, 3.0);
next.main.orientation =
Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
_ => {
next.main.offset = Vec3::new(-7.0, -5.0, 15.0);
next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.main.position = Vec3::new(-7.0, -5.0, 15.0);
next.main.orientation = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.main.scale = Vec3::one();
match second_tool_kind {
Some(ToolKind::Dagger(_)) => {
next.second.offset = Vec3::new(4.0, -6.0, 7.0);
next.second.ori =
next.second.position = Vec3::new(4.0, -6.0, 7.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI);
},
Some(ToolKind::Shield(_)) => {
next.second.offset = Vec3::new(0.0, -4.0, 3.0);
next.second.ori =
next.second.position = Vec3::new(0.0, -4.0, 3.0);
next.second.orientation =
Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI);
},
_ => {
next.second.offset = Vec3::new(-7.0, -5.0, 15.0);
next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
next.second.position = Vec3::new(-7.0, -5.0, 15.0);
next.second.orientation =
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
}
next.second.scale = Vec3::one();
next.lantern.offset = Vec3::new(
next.lantern.position = Vec3::new(
skeleton_attr.lantern.0,
skeleton_attr.lantern.1,
skeleton_attr.lantern.2,
);
next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.lantern.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.lantern.scale = Vec3::one() * 0.65;
next.torso.offset = Vec3::new(0.0, -1.2 + shortalt * -0.065, 0.4) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.05)
next.torso.position = Vec3::new(0.0, -1.2 + shortalt * -0.065, 0.4) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.05)
* Quaternion::rotation_z(tilt * 12.0);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;

View File

@ -53,76 +53,79 @@ impl Animation for WieldAnimation {
let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin();
if velocity > 0.5 {
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.ori = Quaternion::rotation_x(-0.2);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.orientation = Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation = Quaternion::rotation_x(
(-0.5 + short * 0.3 + noisea * 0.3 + noiseb * 0.3).min(-0.1),
);
next.back.scale = Vec3::one() * 1.02;
} else {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-2.0 + skeleton_attr.head.0,
skeleton_attr.head.1 + u_slow * 0.1,
);
next.head.ori =
next.head.orientation =
Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0 + slowalt * 0.5,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + u_slow * 0.5,
);
next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler;
next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.l_foot.offset = Vec3::new(
next.l_foot.position = Vec3::new(
-skeleton_attr.foot.0,
-2.0 + skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.l_foot.ori = Quaternion::rotation_x(u_slowalt * 0.035 - 0.2);
next.l_foot.orientation = Quaternion::rotation_x(u_slowalt * 0.035 - 0.2);
next.r_foot.offset = Vec3::new(
next.r_foot.position = Vec3::new(
skeleton_attr.foot.0,
2.0 + skeleton_attr.foot.1,
skeleton_attr.foot.2,
);
next.r_foot.ori = Quaternion::rotation_x(u_slow * 0.035);
next.r_foot.orientation = Quaternion::rotation_x(u_slow * 0.035);
next.chest.ori =
next.chest.orientation =
Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.15);
next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22);
next.belt.position = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.orientation =
Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22);
next.belt.scale = Vec3::one() * 1.02;
next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.ori = Quaternion::rotation_x(-0.2);
next.back.position = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1);
next.back.orientation = Quaternion::rotation_x(-0.2);
next.back.scale = Vec3::one() * 1.02;
next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_z(0.3);
next.shorts.position = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(0.3);
}
match active_tool_kind {
//TODO: Inventory
Some(ToolKind::Sword(_)) => {
next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.position = Vec3::new(-0.75, -1.0, -2.5);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2);
next.l_hand.scale = Vec3::one() * 1.04;
next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.position = Vec3::new(0.75, -1.5, -5.5);
next.r_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(0.0, 0.0, -3.0);
next.main.ori = Quaternion::rotation_x(-0.1)
next.main.position = Vec3::new(0.0, 0.0, -3.0);
next.main.orientation = Quaternion::rotation_x(-0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori = Quaternion::rotation_x(u_slow * 0.15)
next.control.position = Vec3::new(-7.0, 6.0, 6.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.15)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one();
@ -132,129 +135,132 @@ impl Animation for WieldAnimation {
// also reduce flicker with overlapping polygons
let hand_scale = 1.12;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
//next.control.ori = Quaternion::rotation_x(slow * 1.0);
next.control.position = Vec3::new(0.0, 0.0, 0.0);
//next.control.orientation = Quaternion::rotation_x(slow * 1.0);
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_hand.scale = Vec3::one() * hand_scale;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0 * PI)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.r_hand.scale = Vec3::one() * hand_scale;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0 * PI)
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.second.scale = Vec3::one();
next.r_control.offset = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.ori = Quaternion::rotation_x(0.0 * PI)
next.r_control.position = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.orientation = Quaternion::rotation_x(0.0 * PI)
// * Quaternion::rotation_y(0.0 * PI)
// * Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
},
Some(ToolKind::Axe(_)) => {
if velocity < 0.5 {
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
-3.5 + skeleton_attr.head.0,
skeleton_attr.head.1 + u_slow * 0.1,
);
next.head.ori = Quaternion::rotation_z(head_look.x)
next.head.orientation = Quaternion::rotation_z(head_look.x)
* Quaternion::rotation_x(0.35 + head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
next.chest.ori = Quaternion::rotation_x(-0.35)
next.chest.orientation = Quaternion::rotation_x(-0.35)
* Quaternion::rotation_y(u_slowalt * 0.04)
* Quaternion::rotation_z(0.15);
next.belt.offset =
next.belt.position =
Vec3::new(0.0, 1.0 + skeleton_attr.belt.0, skeleton_attr.belt.1);
next.belt.ori = Quaternion::rotation_x(0.15)
next.belt.orientation = Quaternion::rotation_x(0.15)
* Quaternion::rotation_y(u_slowalt * 0.03)
* Quaternion::rotation_z(0.15);
next.shorts.offset =
next.shorts.position =
Vec3::new(0.0, 1.0 + skeleton_attr.shorts.0, skeleton_attr.shorts.1);
next.shorts.ori = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
next.control.ori = Quaternion::rotation_x(1.8)
next.shorts.orientation =
Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25);
next.control.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(-0.5)
* Quaternion::rotation_z(PI - 0.2);
next.control.scale = Vec3::one();
} else {
next.control.ori = Quaternion::rotation_x(2.1)
next.control.orientation = Quaternion::rotation_x(2.1)
* Quaternion::rotation_y(-0.4)
* Quaternion::rotation_z(PI - 0.2);
next.control.scale = Vec3::one();
}
next.l_hand.offset = Vec3::new(-0.5, 0.0, 4.0);
next.l_hand.ori = Quaternion::rotation_x(PI / 2.0)
next.l_hand.position = Vec3::new(-0.5, 0.0, 4.0);
next.l_hand.orientation = Quaternion::rotation_x(PI / 2.0)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(0.5, 0.0, -2.5);
next.r_hand.ori = Quaternion::rotation_x(PI / 2.0)
next.r_hand.position = Vec3::new(0.5, 0.0, -2.5);
next.r_hand.orientation = Quaternion::rotation_x(PI / 2.0)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_y(0.0);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(-0.0, -2.0, -1.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(-0.0, -2.0, -1.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(-3.0, 11.0, 3.0);
next.control.position = Vec3::new(-3.0, 11.0, 3.0);
},
Some(ToolKind::Hammer(_)) => {
next.l_hand.offset = Vec3::new(-12.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.l_hand.position = Vec3::new(-12.0, 0.0, 0.0);
next.l_hand.orientation =
Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.08;
next.r_hand.offset = Vec3::new(2.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.position = Vec3::new(2.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
next.r_hand.scale = Vec3::one() * 1.06;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(-1.57)
* Quaternion::rotation_z(1.57);
next.control.offset = Vec3::new(6.0, 7.0, 1.0);
next.control.ori = Quaternion::rotation_x(0.3 + u_slow * 0.15)
next.control.position = Vec3::new(6.0, 7.0, 1.0);
next.control.orientation = Quaternion::rotation_x(0.3 + u_slow * 0.15)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(u_slowalt * 0.08);
next.control.scale = Vec3::one();
},
Some(ToolKind::Staff(_)) => {
next.l_hand.offset = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.position = Vec3::new(1.5, 0.5, -4.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.ori = Quaternion::rotation_x(1.8)
next.r_hand.position = Vec3::new(8.0, 4.0, 2.0);
next.r_hand.orientation = Quaternion::rotation_x(1.8)
* Quaternion::rotation_y(0.5)
* Quaternion::rotation_z(-0.27);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(12.0, 8.4, 13.2);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(12.0, 8.4, 13.2);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(3.14 + 0.3)
* Quaternion::rotation_z(0.9);
next.control.offset = Vec3::new(-14.0, 1.8, 3.0);
next.control.ori = Quaternion::rotation_x(u_slow * 0.2)
next.control.position = Vec3::new(-14.0, 1.8, 3.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.2)
* Quaternion::rotation_y(-0.2)
* Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one();
@ -264,116 +270,117 @@ impl Animation for WieldAnimation {
// also reduce flicker with overlapping polygons
let hand_scale = 1.12;
next.control.offset = Vec3::new(0.0, 0.0, 0.0);
// next.control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.control.position = Vec3::new(0.0, 0.0, 0.0);
// next.control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.control.scale = Vec3::one();
next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.l_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_hand.scale = Vec3::one() * hand_scale;
next.main.offset = Vec3::new(0.0, 0.0, 0.0);
next.main.ori = Quaternion::rotation_x(0.0 * PI)
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
next.l_control.position = Vec3::new(-7.0, 0.0, 0.0);
// next.l_control.orientation = Quaternion::rotation_x(u_slow * 0.15 + 1.0)
// * Quaternion::rotation_y(0.0)
// * Quaternion::rotation_z(u_slowalt * 0.08);
// next.l_control.scale = Vec3::one();
next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.ori = Quaternion::rotation_x(0.0 * PI)
next.r_hand.position = Vec3::new(0.0, 0.0, 0.0);
next.r_hand.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.r_hand.scale = Vec3::one() * hand_scale;
next.second.offset = Vec3::new(0.0, 0.0, 0.0);
next.second.ori = Quaternion::rotation_x(0.0 * PI)
next.second.position = Vec3::new(0.0, 0.0, 0.0);
next.second.orientation = Quaternion::rotation_x(0.0 * PI)
* Quaternion::rotation_y(0.0 * PI)
* Quaternion::rotation_z(0.0 * PI);
next.second.scale = Vec3::one();
next.r_control.offset = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.ori = Quaternion::rotation_x(0.0 * PI)
next.r_control.position = Vec3::new(7.0, 0.0, 0.0);
// next.r_control.orientation = Quaternion::rotation_x(0.0 * PI)
// * Quaternion::rotation_y(0.0 * PI)
// * Quaternion::rotation_z(0.0 * PI);
// next.r_control.scale = Vec3::one();
},
Some(ToolKind::Bow(_)) => {
next.l_hand.offset = Vec3::new(2.0, 1.5, 0.0);
next.l_hand.ori = Quaternion::rotation_x(1.20)
next.l_hand.position = Vec3::new(2.0, 1.5, 0.0);
next.l_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(5.9, 4.5, -5.0);
next.r_hand.ori = Quaternion::rotation_x(1.20)
next.r_hand.position = Vec3::new(5.9, 4.5, -5.0);
next.r_hand.orientation = Quaternion::rotation_x(1.20)
* Quaternion::rotation_y(-0.6)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(3.0, 2.0, -13.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(3.0, 2.0, -13.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(0.3)
* Quaternion::rotation_z(-0.6);
next.hold.offset = Vec3::new(1.2, -1.0, -5.2);
next.hold.ori = Quaternion::rotation_x(-1.7)
next.hold.position = Vec3::new(1.2, -1.0, -5.2);
next.hold.orientation = Quaternion::rotation_x(-1.7)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.1);
next.hold.scale = Vec3::one() * 1.0;
next.control.offset = Vec3::new(-7.0, 6.0, 6.0);
next.control.ori =
next.control.position = Vec3::new(-7.0, 6.0, 6.0);
next.control.orientation =
Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one();
},
Some(ToolKind::Debug(_)) => {
next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.ori = Quaternion::rotation_x(1.27)
next.l_hand.position = Vec3::new(-7.0, 4.0, 3.0);
next.l_hand.orientation = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.l_hand.scale = Vec3::one() * 1.01;
next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.ori = Quaternion::rotation_x(1.27)
next.r_hand.position = Vec3::new(7.0, 2.5, -1.25);
next.r_hand.orientation = Quaternion::rotation_x(1.27)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(-0.3);
next.r_hand.scale = Vec3::one() * 1.01;
next.main.offset = Vec3::new(5.0, 8.75, -2.0);
next.main.ori = Quaternion::rotation_x(-0.3)
next.main.position = Vec3::new(5.0, 8.75, -2.0);
next.main.orientation = Quaternion::rotation_x(-0.3)
* Quaternion::rotation_y(-1.27)
* Quaternion::rotation_z(0.0);
next.main.scale = Vec3::one();
next.control.offset = Vec3::new(0.0, 6.0, 6.0);
next.control.ori =
next.control.position = Vec3::new(0.0, 6.0, 6.0);
next.control.orientation =
Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one();
},
Some(ToolKind::Farming(_)) => {
if velocity < 0.5 {
next.head.ori = Quaternion::rotation_z(head_look.x)
next.head.orientation = Quaternion::rotation_z(head_look.x)
* Quaternion::rotation_x(-0.2 + head_look.y.abs());
next.head.scale = Vec3::one() * skeleton_attr.head_scale;
}
next.l_hand.offset = Vec3::new(9.0, 1.0, 1.0);
next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.0);
next.l_hand.position = Vec3::new(9.0, 1.0, 1.0);
next.l_hand.orientation =
Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.0);
next.l_hand.scale = Vec3::one() * 1.05;
next.r_hand.offset = Vec3::new(9.0, 1.0, 11.0);
next.r_hand.ori = Quaternion::rotation_x(1.57)
next.r_hand.position = Vec3::new(9.0, 1.0, 11.0);
next.r_hand.orientation = Quaternion::rotation_x(1.57)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(0.0);
next.r_hand.scale = Vec3::one() * 1.05;
next.main.offset = Vec3::new(7.5, 7.5, 13.2);
next.main.ori = Quaternion::rotation_x(0.0)
next.main.position = Vec3::new(7.5, 7.5, 13.2);
next.main.orientation = Quaternion::rotation_x(0.0)
* Quaternion::rotation_y(3.14)
* Quaternion::rotation_z(0.0);
next.control.offset = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
next.control.ori = Quaternion::rotation_x(u_slow * 0.1)
next.control.position = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0);
next.control.orientation = Quaternion::rotation_x(u_slow * 0.1)
* Quaternion::rotation_y(0.6 + u_slow * 0.1)
* Quaternion::rotation_z(u_slowalt * 0.1);
next.control.scale = Vec3::one();

View File

@ -37,29 +37,30 @@ impl Animation for IdleAnimation {
.sin()
* 0.25,
);
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(rat_head_look.x)
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(rat_head_look.x)
* Quaternion::rotation_x(rat_head_look.y + wave * 0.03);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1 + wave * 0.3,
) / 18.0;
next.chest.ori = Quaternion::rotation_y(wave_slow * 0.06);
next.chest.orientation = Quaternion::rotation_y(wave_slow * 0.06);
next.chest.scale = Vec3::one() / 18.0;
next.feet_f.offset = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1);
next.feet_f.ori = Quaternion::rotation_z(0.0);
next.feet_f.position = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1);
next.feet_f.orientation = Quaternion::rotation_z(0.0);
next.feet_f.scale = Vec3::one();
next.feet_b.offset = Vec3::new(0.0, skeleton_attr.feet_b.0, skeleton_attr.feet_b.1);
next.feet_b.ori = Quaternion::rotation_x(0.0);
next.feet_b.position = Vec3::new(0.0, skeleton_attr.feet_b.0, skeleton_attr.feet_b.1);
next.feet_b.orientation = Quaternion::rotation_x(0.0);
next.feet_b.scale = Vec3::one();
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0 + wave * 0.2, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_y(wave_slow * 0.05);
next.tail.position =
Vec3::new(0.0, skeleton_attr.tail.0 + wave * 0.2, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_y(wave_slow * 0.05);
next.tail.scale = Vec3::one();
next

View File

@ -21,24 +21,24 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(0.8) * Quaternion::rotation_x(0.5);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(0.8) * Quaternion::rotation_x(0.5);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1) / 18.0;
next.chest.ori = Quaternion::rotation_y(0.0);
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1) / 18.0;
next.chest.orientation = Quaternion::rotation_y(0.0);
next.chest.scale = Vec3::one() / 18.0;
next.feet_f.offset = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1);
next.feet_f.ori = Quaternion::rotation_z(0.0);
next.feet_f.position = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1);
next.feet_f.orientation = Quaternion::rotation_z(0.0);
next.feet_f.scale = Vec3::one();
next.feet_b.offset = Vec3::new(0.0, skeleton_attr.feet_b.0, skeleton_attr.feet_b.1);
next.feet_b.ori = Quaternion::rotation_x(0.0);
next.feet_b.position = Vec3::new(0.0, skeleton_attr.feet_b.0, skeleton_attr.feet_b.1);
next.feet_b.orientation = Quaternion::rotation_x(0.0);
next.feet_b.scale = Vec3::one();
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_y(0.0);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_y(0.0);
next.tail.scale = Vec3::one();
next

View File

@ -5,17 +5,18 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
skeleton_impls!(struct CritterSkeleton {
+ head,
+ chest,
+ feet_f,
+ feet_b,
+ tail,
});
#[derive(Clone, Default)]
pub struct CritterSkeleton {
head: Bone,
chest: Bone,
feet_f: Bone,
feet_b: Bone,
tail: Bone,
}
pub struct CritterAttr {
head: (f32, f32),
chest: (f32, f32),
@ -24,51 +25,30 @@ pub struct CritterAttr {
tail: (f32, f32),
}
impl CritterSkeleton {
pub fn new() -> Self { Self::default() }
}
impl Skeleton for CritterSkeleton {
type Attr = CritterAttr;
const BONE_COUNT: usize = 5;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"critter_compute_mats\0";
fn bone_count(&self) -> usize { 5 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "critter_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let chest_mat = self.chest.compute_base_matrix();
(
[
FigureBoneData::new(chest_mat * self.head.compute_base_matrix()),
FigureBoneData::new(chest_mat),
FigureBoneData::new(chest_mat * self.feet_f.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.feet_b.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.tail.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.chest.interpolate(&target.chest, dt);
self.feet_f.interpolate(&target.feet_f, dt);
self.feet_b.interpolate(&target.feet_b, dt);
self.tail.interpolate(&target.tail, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(chest_mat * Mat4::<f32>::from(self.head)),
make_bone(chest_mat),
make_bone(chest_mat * Mat4::<f32>::from(self.feet_f)),
make_bone(chest_mat * Mat4::<f32>::from(self.feet_b)),
make_bone(chest_mat * Mat4::<f32>::from(self.tail)),
];
Vec3::default()
}
}

View File

@ -26,28 +26,30 @@ impl Animation for RunAnimation {
let wave_cos = (anim_time as f32 * 13.0).sin();
let wave_slow = (anim_time as f32 * 6.5 + PI).sin();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0 + wave * 0.03);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0 + wave * 0.03);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0 + wave * 1.0,
skeleton_attr.chest.1,
) / 18.0;
next.chest.ori = Quaternion::rotation_y(0.0);
next.chest.orientation = Quaternion::rotation_y(0.0);
next.chest.scale = Vec3::one() / 18.0;
next.feet_f.offset = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1);
next.feet_f.ori = Quaternion::rotation_x(wave * 1.0);
next.feet_f.position = Vec3::new(0.0, skeleton_attr.feet_f.0, skeleton_attr.feet_f.1);
next.feet_f.orientation = Quaternion::rotation_x(wave * 1.0);
next.feet_f.scale = Vec3::one();
next.feet_b.offset = Vec3::new(0.0, skeleton_attr.feet_b.0, skeleton_attr.feet_b.1);
next.feet_b.ori = Quaternion::rotation_x(wave_cos * 1.0);
next.feet_b.position = Vec3::new(0.0, skeleton_attr.feet_b.0, skeleton_attr.feet_b.1);
next.feet_b.orientation = Quaternion::rotation_x(wave_cos * 1.0);
next.feet_b.scale = Vec3::one();
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0 + wave * 1.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_y(wave_slow * 0.08);
next.tail.position =
Vec3::new(0.0, skeleton_attr.tail.0 + wave * 1.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_y(wave_slow * 0.08);
next.tail.scale = Vec3::one();
next

View File

@ -38,123 +38,123 @@ impl Animation for FlyAnimation {
let center = (anim_time as f32 * lab as f32 + PI / 2.0).sin();
let centeroffset = (anim_time as f32 * lab as f32 + PI * 1.5).sin();
next.head_upper.offset = Vec3::new(
next.head_upper.position = Vec3::new(
0.0,
skeleton_attr.head_upper.0,
skeleton_attr.head_upper.1 + wave_ultra_slow * 0.20,
);
next.head_upper.ori =
next.head_upper.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(wave_ultra_slow * -0.10);
next.head_upper.scale = Vec3::one() * 1.05;
next.head_lower.offset = Vec3::new(
next.head_lower.position = Vec3::new(
0.0,
skeleton_attr.head_lower.0,
skeleton_attr.head_lower.1 + wave_ultra_slow * 0.20,
);
next.head_lower.ori =
next.head_lower.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(wave_ultra_slow * -0.10);
next.head_lower.scale = Vec3::one() * 1.05;
next.jaw.offset = Vec3::new(
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - wave_ultra_slow_cos * 0.12,
skeleton_attr.jaw.1 + wave_slow * 0.2,
);
next.jaw.ori = Quaternion::rotation_x(wave_slow * 0.03);
next.jaw.orientation = Quaternion::rotation_x(wave_slow * 0.03);
next.jaw.scale = Vec3::one() * 1.05;
next.tail_front.offset = Vec3::new(
next.tail_front.position = Vec3::new(
0.0,
skeleton_attr.tail_front.0,
skeleton_attr.tail_front.1 + centeroffset * 0.6,
);
next.tail_front.ori = Quaternion::rotation_x(center * 0.03);
next.tail_front.orientation = Quaternion::rotation_x(center * 0.03);
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.offset = Vec3::new(
next.tail_rear.position = Vec3::new(
0.0,
skeleton_attr.tail_rear.0,
skeleton_attr.tail_rear.1 + centeroffset * 0.6,
);
next.tail_rear.ori = Quaternion::rotation_x(center * 0.03);
next.tail_rear.orientation = Quaternion::rotation_x(center * 0.03);
next.tail_rear.scale = Vec3::one() * 0.98;
next.chest_front.offset = Vec3::new(
next.chest_front.position = Vec3::new(
0.0,
skeleton_attr.chest_front.0,
skeleton_attr.chest_front.1,
);
next.chest_front.ori = Quaternion::rotation_y(center * 0.05);
next.chest_front.orientation = Quaternion::rotation_y(center * 0.05);
next.chest_front.scale = Vec3::one();
next.chest_rear.offset =
next.chest_rear.position =
Vec3::new(0.0, skeleton_attr.chest_rear.0, skeleton_attr.chest_rear.1);
next.chest_rear.ori = Quaternion::rotation_y(center * 0.05);
next.chest_rear.orientation = Quaternion::rotation_y(center * 0.05);
next.chest_rear.scale = Vec3::one();
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fl.ori = Quaternion::rotation_x(-1.3 + footl * 0.06);
next.foot_fl.orientation = Quaternion::rotation_x(-1.3 + footl * 0.06);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori = Quaternion::rotation_x(-1.3 + footr * 0.06);
next.foot_fr.orientation = Quaternion::rotation_x(-1.3 + footr * 0.06);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_bl.ori = Quaternion::rotation_x(-1.3 + footl * 0.06);
next.foot_bl.orientation = Quaternion::rotation_x(-1.3 + footl * 0.06);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori = Quaternion::rotation_x(-1.3 + footr * 0.06);
next.foot_br.orientation = Quaternion::rotation_x(-1.3 + footr * 0.06);
next.foot_br.scale = Vec3::one();
next.wing_in_l.offset = Vec3::new(
next.wing_in_l.position = Vec3::new(
-skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_l.ori = Quaternion::rotation_y(0.4 + wingl * 0.6);
next.wing_in_l.orientation = Quaternion::rotation_y(0.4 + wingl * 0.6);
next.wing_in_l.scale = Vec3::one();
next.wing_in_r.offset = Vec3::new(
next.wing_in_r.position = Vec3::new(
skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_r.ori = Quaternion::rotation_y(-0.4 + wingr * 0.6);
next.wing_in_r.orientation = Quaternion::rotation_y(-0.4 + wingr * 0.6);
next.wing_in_r.scale = Vec3::one();
next.wing_out_l.offset = Vec3::new(
next.wing_out_l.position = Vec3::new(
-skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_l.ori = Quaternion::rotation_y((0.35 + wingl * 0.6).max(0.2));
next.wing_out_l.orientation = Quaternion::rotation_y((0.35 + wingl * 0.6).max(0.2));
next.wing_out_l.scale = Vec3::one();
next.wing_out_r.offset = Vec3::new(
next.wing_out_r.position = Vec3::new(
skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_r.ori = Quaternion::rotation_y((-0.35 + wingr * 0.6).min(-0.2));
next.wing_out_r.orientation = Quaternion::rotation_y((-0.35 + wingr * 0.6).min(-0.2));
next.wing_out_r.scale = Vec3::one();
next

View File

@ -40,113 +40,115 @@ impl Animation for IdleAnimation {
* 0.25,
);
next.head_upper.offset = Vec3::new(
next.head_upper.position = Vec3::new(
0.0,
skeleton_attr.head_upper.0,
skeleton_attr.head_upper.1 + ultra_slow * 0.20,
);
next.head_upper.ori = Quaternion::rotation_z(0.8 * dragon_look.x)
next.head_upper.orientation = Quaternion::rotation_z(0.8 * dragon_look.x)
* Quaternion::rotation_x(0.8 * dragon_look.y);
next.head_upper.scale = Vec3::one();
next.head_lower.offset = Vec3::new(
next.head_lower.position = Vec3::new(
0.0,
skeleton_attr.head_lower.0,
skeleton_attr.head_lower.1 + ultra_slow * 0.20,
);
next.head_lower.ori = Quaternion::rotation_z(0.8 * dragon_look.x)
next.head_lower.orientation = Quaternion::rotation_z(0.8 * dragon_look.x)
* Quaternion::rotation_x(-0.2 + 0.8 * dragon_look.y);
next.head_lower.scale = Vec3::one() * 1.05;
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(slow * 0.04);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.04);
next.jaw.scale = Vec3::one() * 1.05;
next.chest_front.offset = Vec3::new(
next.chest_front.position = Vec3::new(
0.0,
skeleton_attr.chest_front.0,
skeleton_attr.chest_front.1,
);
next.chest_front.ori = Quaternion::rotation_y(0.0);
next.chest_front.orientation = Quaternion::rotation_y(0.0);
next.chest_front.scale = Vec3::one() * 1.05;
next.chest_rear.offset =
next.chest_rear.position =
Vec3::new(0.0, skeleton_attr.chest_rear.0, skeleton_attr.chest_rear.1);
next.chest_rear.ori = Quaternion::rotation_y(0.0);
next.chest_rear.orientation = Quaternion::rotation_y(0.0);
next.chest_rear.scale = Vec3::one() * 1.05;
next.tail_front.offset =
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.ori = Quaternion::rotation_z(slowalt * 0.10) * Quaternion::rotation_x(0.1);
next.tail_front.orientation =
Quaternion::rotation_z(slowalt * 0.10) * Quaternion::rotation_x(0.1);
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.offset =
next.tail_rear.position =
Vec3::new(0.0, skeleton_attr.tail_rear.0, skeleton_attr.tail_rear.1);
next.tail_rear.ori = Quaternion::rotation_z(slowalt * 0.12) * Quaternion::rotation_x(0.05);
next.tail_rear.orientation =
Quaternion::rotation_z(slowalt * 0.12) * Quaternion::rotation_x(0.05);
next.tail_rear.scale = Vec3::one() * 0.98;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fl.ori = Quaternion::rotation_x(0.0);
next.foot_fl.orientation = Quaternion::rotation_x(0.0);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori = Quaternion::rotation_x(0.0);
next.foot_fr.orientation = Quaternion::rotation_x(0.0);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_bl.ori = Quaternion::rotation_x(0.0);
next.foot_bl.orientation = Quaternion::rotation_x(0.0);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori = Quaternion::rotation_x(0.0);
next.foot_br.orientation = Quaternion::rotation_x(0.0);
next.foot_br.scale = Vec3::one();
next.wing_in_l.offset = Vec3::new(
next.wing_in_l.position = Vec3::new(
-skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_l.ori = Quaternion::rotation_y(0.8 + slow * 0.02);
next.wing_in_l.orientation = Quaternion::rotation_y(0.8 + slow * 0.02);
next.wing_in_l.scale = Vec3::one();
next.wing_in_r.offset = Vec3::new(
next.wing_in_r.position = Vec3::new(
skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_r.ori = Quaternion::rotation_y(-0.8 - slow * 0.02);
next.wing_in_r.orientation = Quaternion::rotation_y(-0.8 - slow * 0.02);
next.wing_in_r.scale = Vec3::one();
next.wing_out_l.offset = Vec3::new(
next.wing_out_l.position = Vec3::new(
-skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_l.ori = Quaternion::rotation_y(-2.0 + slow * 0.02);
next.wing_out_l.orientation = Quaternion::rotation_y(-2.0 + slow * 0.02);
next.wing_out_l.scale = Vec3::one();
next.wing_out_r.offset = Vec3::new(
next.wing_out_r.position = Vec3::new(
skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_r.ori = Quaternion::rotation_y(2.0 - slow * 0.02);
next.wing_out_r.orientation = Quaternion::rotation_y(2.0 - slow * 0.02);
next.wing_out_r.scale = Vec3::one();
next

View File

@ -5,111 +5,68 @@ pub mod run;
// Reexports
pub use self::{fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct DragonSkeleton {
head_upper: Bone,
head_lower: Bone,
jaw: Bone,
chest_front: Bone,
chest_rear: Bone,
tail_front: Bone,
tail_rear: Bone,
wing_in_l: Bone,
wing_in_r: Bone,
wing_out_l: Bone,
wing_out_r: Bone,
foot_fl: Bone,
foot_fr: Bone,
foot_bl: Bone,
foot_br: Bone,
}
impl DragonSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct DragonSkeleton {
+ head_upper,
+ head_lower,
+ jaw,
+ chest_front,
+ chest_rear,
+ tail_front,
+ tail_rear,
+ wing_in_l,
+ wing_in_r,
+ wing_out_l,
+ wing_out_r,
+ foot_fl,
+ foot_fr,
+ foot_bl,
+ foot_br,
});
impl Skeleton for DragonSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 15;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"dragon_compute_mats\0";
fn bone_count(&self) -> usize { 15 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "dragon_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let head_upper_mat = self.head_upper.compute_base_matrix();
let head_lower_mat = self.head_lower.compute_base_matrix();
let chest_front_mat = self.chest_front.compute_base_matrix();
let chest_rear_mat = self.chest_rear.compute_base_matrix();
let wing_in_l_mat = self.wing_in_l.compute_base_matrix();
let wing_in_r_mat = self.wing_in_r.compute_base_matrix();
let tail_front_mat = self.tail_front.compute_base_matrix();
(
[
FigureBoneData::new(chest_front_mat * head_lower_mat * head_upper_mat),
FigureBoneData::new(chest_front_mat * head_lower_mat),
FigureBoneData::new(
chest_front_mat
* head_lower_mat
* head_upper_mat
* self.jaw.compute_base_matrix(),
),
FigureBoneData::new(chest_front_mat),
FigureBoneData::new(chest_front_mat * self.chest_rear.compute_base_matrix()),
FigureBoneData::new(chest_front_mat * chest_rear_mat * tail_front_mat),
FigureBoneData::new(
chest_front_mat
* chest_rear_mat
* tail_front_mat
* self.tail_rear.compute_base_matrix(),
),
FigureBoneData::new(chest_front_mat * self.wing_in_l.compute_base_matrix()),
FigureBoneData::new(chest_front_mat * self.wing_in_r.compute_base_matrix()),
FigureBoneData::new(
chest_front_mat * wing_in_l_mat * self.wing_out_l.compute_base_matrix(),
),
FigureBoneData::new(
chest_front_mat * wing_in_r_mat * self.wing_out_r.compute_base_matrix(),
),
FigureBoneData::new(chest_front_mat * self.foot_fl.compute_base_matrix()),
FigureBoneData::new(chest_front_mat * self.foot_fr.compute_base_matrix()),
FigureBoneData::new(
chest_front_mat
* self.chest_rear.compute_base_matrix()
* self.foot_bl.compute_base_matrix(),
),
FigureBoneData::new(
chest_front_mat
* self.chest_rear.compute_base_matrix()
* self.foot_br.compute_base_matrix(),
),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
let chest_rear_mat = chest_front_mat * Mat4::<f32>::from(self.chest_rear);
let head_lower_mat = chest_front_mat * Mat4::<f32>::from(self.head_lower);
let wing_in_l_mat = chest_front_mat * Mat4::<f32>::from(self.wing_in_l);
let wing_in_r_mat = chest_front_mat * Mat4::<f32>::from(self.wing_in_r);
let tail_front_mat = chest_rear_mat * Mat4::<f32>::from(self.tail_front);
let head_upper_mat = head_lower_mat * Mat4::<f32>::from(self.head_upper);
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head_upper.interpolate(&target.head_upper, dt);
self.head_lower.interpolate(&target.head_lower, dt);
self.jaw.interpolate(&target.jaw, dt);
self.chest_front.interpolate(&target.chest_front, dt);
self.chest_rear.interpolate(&target.chest_rear, dt);
self.tail_front.interpolate(&target.tail_front, dt);
self.tail_rear.interpolate(&target.tail_rear, dt);
self.wing_in_l.interpolate(&target.wing_in_l, dt);
self.wing_in_r.interpolate(&target.wing_in_r, dt);
self.wing_out_l.interpolate(&target.wing_out_l, dt);
self.wing_out_r.interpolate(&target.wing_out_r, dt);
self.foot_fl.interpolate(&target.foot_fl, dt);
self.foot_fr.interpolate(&target.foot_fr, dt);
self.foot_bl.interpolate(&target.foot_bl, dt);
self.foot_br.interpolate(&target.foot_br, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_upper_mat),
make_bone(head_lower_mat),
make_bone(head_upper_mat * Mat4::<f32>::from(self.jaw)),
make_bone(chest_front_mat),
make_bone(chest_rear_mat),
make_bone(tail_front_mat),
make_bone(tail_front_mat * Mat4::<f32>::from(self.tail_rear)),
make_bone(wing_in_l_mat),
make_bone(wing_in_r_mat),
make_bone(wing_in_l_mat * Mat4::<f32>::from(self.wing_out_l)),
make_bone(wing_in_r_mat * Mat4::<f32>::from(self.wing_out_r)),
make_bone(chest_front_mat * Mat4::<f32>::from(self.foot_fl)),
make_bone(chest_front_mat * Mat4::<f32>::from(self.foot_fr)),
make_bone(chest_rear_mat * Mat4::<f32>::from(self.foot_bl)),
make_bone(chest_rear_mat * Mat4::<f32>::from(self.foot_br)),
];
Vec3::default()
}
}

View File

@ -70,128 +70,128 @@ impl Animation for RunAnimation {
let center = (anim_time as f32 * lab as f32 + PI / 2.0).sin();
let centeroffset = (anim_time as f32 * lab as f32 + PI * 1.5).sin();
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_x(short * -0.03 - 0.1)
next.head_upper.orientation = Quaternion::rotation_x(short * -0.03 - 0.1)
* Quaternion::rotation_z(tilt * -1.2)
* Quaternion::rotation_y(tilt * 0.8);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_z(tilt * -0.8)
next.head_lower.orientation = Quaternion::rotation_z(tilt * -0.8)
* Quaternion::rotation_x(short * -0.05)
* Quaternion::rotation_y(tilt * 0.3);
next.head_lower.scale = Vec3::one() * 1.02;
next.jaw.offset = Vec3::new(
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - wave_ultra_slow_cos * 0.12,
skeleton_attr.jaw.1 + wave_slow * 0.2,
);
next.jaw.ori = Quaternion::rotation_x(wave_slow * 0.03);
next.jaw.orientation = Quaternion::rotation_x(wave_slow * 0.03);
next.jaw.scale = Vec3::one() * 1.05;
next.tail_front.offset = Vec3::new(
next.tail_front.position = Vec3::new(
0.0,
skeleton_attr.tail_front.0,
skeleton_attr.tail_front.1 + centeroffset * 0.6,
);
next.tail_front.ori =
next.tail_front.orientation =
Quaternion::rotation_x(center * 0.03) * Quaternion::rotation_z(tilt * 1.5);
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.offset = Vec3::new(
next.tail_rear.position = Vec3::new(
0.0,
skeleton_attr.tail_rear.0,
skeleton_attr.tail_rear.1 + centeroffset * 0.6,
);
next.tail_rear.ori =
next.tail_rear.orientation =
Quaternion::rotation_x(center * 0.03) * Quaternion::rotation_z(tilt * 1.5);
next.tail_rear.scale = Vec3::one() * 0.98;
next.chest_front.offset = Vec3::new(
next.chest_front.position = Vec3::new(
0.0,
skeleton_attr.chest_front.0,
skeleton_attr.chest_front.1 + shortalt * 2.5 + x_tilt * 10.0,
);
next.chest_front.ori = Quaternion::rotation_x(short * 0.13 + x_tilt)
next.chest_front.orientation = Quaternion::rotation_x(short * 0.13 + x_tilt)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(tilt * -1.5);
next.chest_front.scale = Vec3::one();
next.chest_rear.offset = Vec3::new(
next.chest_rear.position = Vec3::new(
0.0,
skeleton_attr.chest_rear.0,
skeleton_attr.chest_rear.1 + shortalt * 0.2,
);
next.chest_rear.ori = Quaternion::rotation_x(short * 0.1)
next.chest_rear.orientation = Quaternion::rotation_x(short * 0.1)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(tilt * 1.8);
next.chest_rear.scale = Vec3::one();
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + horilf * 2.5,
skeleton_attr.feet_f.2 + vertlf * 5.0 * skeleton_attr.height - 0.5,
);
next.foot_fl.ori = Quaternion::rotation_x(horilf * 0.6);
next.foot_fl.orientation = Quaternion::rotation_x(horilf * 0.6);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + horirfoffset * 2.5,
skeleton_attr.feet_f.2 + vertrfoffset * 5.0 * skeleton_attr.height - 0.5,
);
next.foot_fr.ori = Quaternion::rotation_x(horirb * 0.6);
next.foot_fr.orientation = Quaternion::rotation_x(horirb * 0.6);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + horilboffset * 3.0,
skeleton_attr.feet_b.2 + vertlboffset * 5.0 * skeleton_attr.height - 0.5,
);
next.foot_bl.ori = Quaternion::rotation_x(horilf * 0.55);
next.foot_bl.orientation = Quaternion::rotation_x(horilf * 0.55);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + horirb * 3.0,
skeleton_attr.feet_b.2 + vertrb * 5.0 * skeleton_attr.height - 0.5,
);
next.foot_br.ori = Quaternion::rotation_x(horirb * 0.55);
next.foot_br.orientation = Quaternion::rotation_x(horirb * 0.55);
next.foot_br.scale = Vec3::one();
next.wing_in_l.offset = Vec3::new(
next.wing_in_l.position = Vec3::new(
-skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_l.ori = Quaternion::rotation_y(0.8 + tilt * 1.0);
next.wing_in_l.orientation = Quaternion::rotation_y(0.8 + tilt * 1.0);
next.wing_in_l.scale = Vec3::one();
next.wing_in_r.offset = Vec3::new(
next.wing_in_r.position = Vec3::new(
skeleton_attr.wing_in.0,
skeleton_attr.wing_in.1,
skeleton_attr.wing_in.2,
);
next.wing_in_r.ori = Quaternion::rotation_y(-0.8 + tilt * 1.0);
next.wing_in_r.orientation = Quaternion::rotation_y(-0.8 + tilt * 1.0);
next.wing_in_r.scale = Vec3::one();
next.wing_out_l.offset = Vec3::new(
next.wing_out_l.position = Vec3::new(
-skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_l.ori = Quaternion::rotation_y(-2.0 + tilt * 1.0);
next.wing_out_l.orientation = Quaternion::rotation_y(-2.0 + tilt * 1.0);
next.wing_out_l.scale = Vec3::one();
next.wing_out_r.offset = Vec3::new(
next.wing_out_r.position = Vec3::new(
skeleton_attr.wing_out.0,
skeleton_attr.wing_out.1,
skeleton_attr.wing_out.2,
);
next.wing_out_r.ori = Quaternion::rotation_y(2.0 + tilt * 1.0);
next.wing_out_r.orientation = Quaternion::rotation_y(2.0 + tilt * 1.0);
next.wing_out_r.scale = Vec3::one();
next

View File

@ -21,28 +21,28 @@ impl Animation for IdleAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.offset = Vec3::new(0.0, 4.5, 2.0);
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 4.5, 2.0);
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() * 1.01;
next.rear.offset = Vec3::new(0.0, 3.1, -4.5);
next.rear.ori = Quaternion::rotation_z(0.0);
next.rear.position = Vec3::new(0.0, 3.1, -4.5);
next.rear.orientation = Quaternion::rotation_z(0.0);
next.rear.scale = Vec3::one() * 0.98;
next.tail.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
next.tail.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, -13.0, 8.0) / 11.0;
next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one() / 11.0;
next.fin_l.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
next.fin_l.ori = Quaternion::rotation_y(0.0);
next.fin_l.position = Vec3::new(0.0, -11.7, 11.0) / 11.0;
next.fin_l.orientation = Quaternion::rotation_y(0.0);
next.fin_l.scale = Vec3::one() / 11.0;
next.fin_r.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
next.fin_r.ori = Quaternion::rotation_y(0.0);
next.fin_r.position = Vec3::new(0.0, 0.0, 12.0) / 11.0;
next.fin_r.orientation = Quaternion::rotation_y(0.0);
next.fin_r.scale = Vec3::one() / 10.5;
next
}

View File

@ -21,28 +21,28 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.offset = Vec3::new(0.0, 4.5, 2.0);
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 4.5, 2.0);
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() * 1.01;
next.rear.offset = Vec3::new(0.0, 3.1, -4.5);
next.rear.ori = Quaternion::rotation_z(0.0);
next.rear.position = Vec3::new(0.0, 3.1, -4.5);
next.rear.orientation = Quaternion::rotation_z(0.0);
next.rear.scale = Vec3::one() * 0.98;
next.tail.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
next.tail.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, -13.0, 8.0) / 11.0;
next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one() / 11.0;
next.fin_l.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
next.fin_l.ori = Quaternion::rotation_y(0.0);
next.fin_l.position = Vec3::new(0.0, -11.7, 11.0) / 11.0;
next.fin_l.orientation = Quaternion::rotation_y(0.0);
next.fin_l.scale = Vec3::one() / 11.0;
next.fin_r.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
next.fin_r.ori = Quaternion::rotation_y(0.0);
next.fin_r.position = Vec3::new(0.0, 0.0, 12.0) / 11.0;
next.fin_r.orientation = Quaternion::rotation_y(0.0);
next.fin_r.scale = Vec3::one() / 10.5;
next
}

View File

@ -5,78 +5,47 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone)]
pub struct FishMediumSkeleton {
head: Bone,
torso: Bone,
rear: Bone,
tail: Bone,
fin_l: Bone,
fin_r: Bone,
}
impl FishMediumSkeleton {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self {
Self {
head: Bone::default(),
torso: Bone::default(),
rear: Bone::default(),
tail: Bone::default(),
fin_l: Bone::default(),
fin_r: Bone::default(),
}
}
}
skeleton_impls!(struct FishMediumSkeleton {
+ head,
+ torso,
+ rear,
+ tail,
+ fin_l,
+ fin_r,
});
impl Skeleton for FishMediumSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 6;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"fish_medium_compute_mats\0";
fn bone_count(&self) -> usize { 6 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "fish_medium_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let torso_mat = self.torso.compute_base_matrix();
let rear_mat = self.rear.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let rear_mat = torso_mat * Mat4::<f32>::from(self.rear);
(
[
FigureBoneData::new(self.head.compute_base_matrix() * torso_mat),
FigureBoneData::new(torso_mat),
FigureBoneData::new(rear_mat * torso_mat),
FigureBoneData::new(self.tail.compute_base_matrix() * rear_mat),
FigureBoneData::new(self.fin_l.compute_base_matrix() * rear_mat),
FigureBoneData::new(self.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(),
],
Vec3::default(),
)
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.torso.interpolate(&target.torso, dt);
self.rear.interpolate(&target.rear, dt);
self.tail.interpolate(&target.tail, dt);
self.fin_l.interpolate(&target.fin_l, dt);
self.fin_r.interpolate(&target.fin_r, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(torso_mat * Mat4::<f32>::from(self.head)),
make_bone(torso_mat),
make_bone(rear_mat),
make_bone(rear_mat * Mat4::<f32>::from(self.tail)),
make_bone(rear_mat * Mat4::<f32>::from(self.fin_l)),
make_bone(rear_mat * Mat4::<f32>::from(self.fin_r)),
];
Vec3::default()
}
}
pub struct SkeletonAttr;
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {

View File

@ -21,28 +21,28 @@ impl Animation for RunAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.offset = Vec3::new(0.0, 4.5, 2.0);
next.torso.ori = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 4.5, 2.0);
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() * 1.01;
next.rear.offset = Vec3::new(0.0, 3.1, -4.5);
next.rear.ori = Quaternion::rotation_z(0.0);
next.rear.position = Vec3::new(0.0, 3.1, -4.5);
next.rear.orientation = Quaternion::rotation_z(0.0);
next.rear.scale = Vec3::one() * 0.98;
next.tail.offset = Vec3::new(0.0, -13.0, 8.0) / 11.0;
next.tail.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, -13.0, 8.0) / 11.0;
next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one() / 11.0;
next.fin_l.offset = Vec3::new(0.0, -11.7, 11.0) / 11.0;
next.fin_l.ori = Quaternion::rotation_y(0.0);
next.fin_l.position = Vec3::new(0.0, -11.7, 11.0) / 11.0;
next.fin_l.orientation = Quaternion::rotation_y(0.0);
next.fin_l.scale = Vec3::one() / 11.0;
next.fin_r.offset = Vec3::new(0.0, 0.0, 12.0) / 11.0;
next.fin_r.ori = Quaternion::rotation_y(0.0);
next.fin_r.position = Vec3::new(0.0, 0.0, 12.0) / 11.0;
next.fin_r.orientation = Quaternion::rotation_y(0.0);
next.fin_r.scale = Vec3::one() / 10.5;
next
}

View File

@ -21,12 +21,12 @@ impl Animation for IdleAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.tail.offset = Vec3::new(0.0, 4.5, 2.0);
next.tail.ori = Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, 4.5, 2.0);
next.tail.orientation = Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one() * 1.01;
next

View File

@ -21,12 +21,12 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.tail.offset = Vec3::new(0.0, 4.5, 2.0);
next.tail.ori = Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, 4.5, 2.0);
next.tail.orientation = Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one() * 1.01;
next

View File

@ -5,64 +5,36 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone)]
pub struct FishSmallSkeleton {
torso: Bone,
tail: Bone,
}
impl FishSmallSkeleton {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self {
Self {
torso: Bone::default(),
tail: Bone::default(),
}
}
}
skeleton_impls!(struct FishSmallSkeleton {
+ torso,
+ tail,
});
impl Skeleton for FishSmallSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 2;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"fish_small_compute_mats\0";
fn bone_count(&self) -> usize { 2 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "fish_small_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let torso_mat = self.torso.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
(
[
FigureBoneData::new(torso_mat),
FigureBoneData::new(self.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(),
],
Vec3::default(),
)
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.torso.interpolate(&target.torso, dt);
self.tail.interpolate(&target.tail, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(torso_mat),
make_bone(torso_mat * Mat4::<f32>::from(self.tail)),
];
Vec3::default()
}
}

View File

@ -21,12 +21,12 @@ impl Animation for RunAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.torso.offset = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.tail.offset = Vec3::new(0.0, 4.5, 2.0);
next.tail.ori = Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, 4.5, 2.0);
next.tail.orientation = Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one() * 1.01;
next

View File

@ -1,51 +1,35 @@
use super::{
vek::{Mat4, Vec3},
FigureBoneData, Skeleton,
};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct FixtureSkeleton;
pub struct SkeletonAttr;
impl FixtureSkeleton {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self { Self {} }
impl<'a, Factor> Lerp<Factor> for &'a FixtureSkeleton {
type Output = FixtureSkeleton;
fn lerp_unclamped_precise(_from: Self, _to: Self, _factor: Factor) -> Self::Output {
FixtureSkeleton
}
fn lerp_unclamped(_from: Self, _to: Self, _factor: Factor) -> Self::Output { FixtureSkeleton }
}
impl Skeleton for FixtureSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 1;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"fixture_compute_mats\0";
fn bone_count(&self) -> usize { 1 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "fixture_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
(
[
FigureBoneData::new(Mat4::identity()), // <-- This is actually a bone!
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
],
Vec3::default(),
)
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
buf[0] = make_bone(base_mat);
Vec3::default()
}
fn interpolate(&mut self, _target: &Self, _dt: f32) {}
}

View File

@ -40,88 +40,89 @@ impl Animation for IdleAnimation {
* 0.25,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0,
skeleton_attr.head.1 + torso * 0.2,
) * 1.02;
next.head.ori = Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.head.orientation =
Quaternion::rotation_z(look.x * 0.6) * Quaternion::rotation_x(look.y * 0.6);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + torso * 0.5,
) / 8.0;
next.upper_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 + torso * 0.6,
);
next.hand_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2 + torso * 0.6,
);
next.hand_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one();
next
}

View File

@ -22,84 +22,84 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1,
) / 8.0;
next.upper_torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.shoulder_r.scale = Vec3::one();
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_l.scale = Vec3::one() / 8.0;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1,
skeleton_attr.foot.2,
) / 8.0;
next.foot_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.foot_r.scale = Vec3::one() / 8.0;
next.torso.offset = Vec3::new(0.0, 0.0, 0.0);
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one();
next
}

View File

@ -5,85 +5,55 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct GolemSkeleton {
head: Bone,
upper_torso: Bone,
shoulder_l: Bone,
shoulder_r: Bone,
hand_l: Bone,
hand_r: Bone,
leg_l: Bone,
leg_r: Bone,
foot_l: Bone,
foot_r: Bone,
torso: Bone,
}
impl GolemSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct GolemSkeleton {
+ head,
+ upper_torso,
+ shoulder_l,
+ shoulder_r,
+ hand_l,
+ hand_r,
+ leg_l,
+ leg_r,
+ foot_l,
+ foot_r,
torso,
});
impl Skeleton for GolemSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 10;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"golem_compute_mats\0";
fn bone_count(&self) -> usize { 15 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "golem_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let upper_torso_mat = self.upper_torso.compute_base_matrix();
let shoulder_l_mat = self.shoulder_l.compute_base_matrix();
let shoulder_r_mat = self.shoulder_r.compute_base_matrix();
let leg_l_mat = self.leg_l.compute_base_matrix();
let leg_r_mat = self.leg_r.compute_base_matrix();
let torso_mat = self.torso.compute_base_matrix();
let foot_l_mat = self.foot_l.compute_base_matrix();
let foot_r_mat = self.foot_r.compute_base_matrix();
(
[
FigureBoneData::new(torso_mat * upper_torso_mat * self.head.compute_base_matrix()),
FigureBoneData::new(torso_mat * upper_torso_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * shoulder_l_mat),
FigureBoneData::new(torso_mat * upper_torso_mat * shoulder_r_mat),
FigureBoneData::new(
torso_mat * upper_torso_mat * self.hand_l.compute_base_matrix(),
),
FigureBoneData::new(
torso_mat * upper_torso_mat * self.hand_r.compute_base_matrix(),
),
FigureBoneData::new(foot_l_mat * leg_l_mat),
FigureBoneData::new(foot_r_mat * leg_r_mat),
FigureBoneData::new(foot_l_mat),
FigureBoneData::new(foot_r_mat),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let foot_l_mat = base_mat * Mat4::<f32>::from(self.foot_l);
let foot_r_mat = base_mat * Mat4::<f32>::from(self.foot_r);
let upper_torso_mat = torso_mat * Mat4::<f32>::from(self.upper_torso);
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.upper_torso.interpolate(&target.upper_torso, dt);
self.shoulder_l.interpolate(&target.shoulder_l, dt);
self.shoulder_r.interpolate(&target.shoulder_r, dt);
self.hand_l.interpolate(&target.hand_l, dt);
self.hand_r.interpolate(&target.hand_r, dt);
self.leg_l.interpolate(&target.leg_l, dt);
self.leg_r.interpolate(&target.leg_r, dt);
self.foot_l.interpolate(&target.foot_l, dt);
self.foot_r.interpolate(&target.foot_r, dt);
self.torso.interpolate(&target.torso, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(upper_torso_mat * Mat4::<f32>::from(self.head)),
make_bone(upper_torso_mat),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_l)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.shoulder_r)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.hand_l)),
make_bone(upper_torso_mat * Mat4::<f32>::from(self.hand_r)),
make_bone(foot_l_mat * Mat4::<f32>::from(self.leg_l)),
make_bone(foot_r_mat * Mat4::<f32>::from(self.leg_r)),
make_bone(foot_l_mat),
make_bone(foot_r_mat),
];
Vec3::default()
}
}

View File

@ -44,89 +44,91 @@ impl Animation for RunAnimation {
.sqrt())
* ((anim_time as f32 * lab as f32 + PI * 0.4).sin());
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.ori = Quaternion::rotation_z(belt * -0.3) * Quaternion::rotation_x(0.3);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1) * 1.02;
next.head.orientation = Quaternion::rotation_z(belt * -0.3) * Quaternion::rotation_x(0.3);
next.head.scale = Vec3::one() * 1.02;
next.upper_torso.offset = Vec3::new(
next.upper_torso.position = Vec3::new(
0.0,
skeleton_attr.upper_torso.0,
skeleton_attr.upper_torso.1 + belt * 1.0,
) / 8.0;
next.upper_torso.ori = Quaternion::rotation_z(belt * 0.40) * Quaternion::rotation_x(0.0);
next.upper_torso.orientation =
Quaternion::rotation_z(belt * 0.40) * Quaternion::rotation_x(0.0);
next.upper_torso.scale = Vec3::one() / 8.0;
next.shoulder_l.offset = Vec3::new(
next.shoulder_l.position = Vec3::new(
-skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_l.ori =
next.shoulder_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(footrotl * -0.15);
next.shoulder_l.scale = Vec3::one();
next.shoulder_r.offset = Vec3::new(
next.shoulder_r.position = Vec3::new(
skeleton_attr.shoulder.0,
skeleton_attr.shoulder.1,
skeleton_attr.shoulder.2,
);
next.shoulder_r.ori =
next.shoulder_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(footrotr * -0.15);
next.shoulder_r.scale = Vec3::one();
next.hand_l.offset = Vec3::new(
next.hand_l.position = Vec3::new(
-skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_l.ori =
next.hand_l.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.3 + footrotl * -0.8);
next.hand_l.scale = Vec3::one() * 1.02;
next.hand_r.offset = Vec3::new(
next.hand_r.position = Vec3::new(
skeleton_attr.hand.0,
skeleton_attr.hand.1,
skeleton_attr.hand.2,
);
next.hand_r.ori =
next.hand_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.3 + footrotr * -0.8);
next.hand_r.scale = Vec3::one() * 1.02;
next.leg_l.offset = Vec3::new(
next.leg_l.position = Vec3::new(
-skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_l.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_l.scale = Vec3::one() * 1.02;
next.leg_r.offset = Vec3::new(
next.leg_r.position = Vec3::new(
skeleton_attr.leg.0,
skeleton_attr.leg.1,
skeleton_attr.leg.2,
) * 1.02;
next.leg_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.leg_r.scale = Vec3::one() * 1.02;
next.foot_l.offset = Vec3::new(
next.foot_l.position = Vec3::new(
-skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothoril * 8.0 + 3.0,
skeleton_attr.foot.2 + footvertl * 4.0,
) / 8.0;
next.foot_l.ori = Quaternion::rotation_x(footrotl * 0.7);
next.foot_l.orientation = Quaternion::rotation_x(footrotl * 0.7);
next.foot_l.scale = Vec3::one() / 8.0 * 0.98;
next.foot_r.offset = Vec3::new(
next.foot_r.position = Vec3::new(
skeleton_attr.foot.0,
skeleton_attr.foot.1 + foothorir * 8.0 + 3.0,
skeleton_attr.foot.2 + footvertr * 4.0,
) / 8.0;
next.foot_r.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(footrotr * 0.7);
next.foot_r.orientation =
Quaternion::rotation_z(0.0) * Quaternion::rotation_x(footrotr * 0.7);
next.foot_r.scale = Vec3::one() / 8.0 * 0.98;
next.torso.offset = Vec3::new(0.0, 0.0, belt * 0.15);
next.torso.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.2);
next.torso.position = Vec3::new(0.0, 0.0, belt * 0.15);
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.2);
next.torso.scale = Vec3::one();
next
}

View File

@ -1,6 +1,43 @@
#![feature(const_generics)]
#![allow(incomplete_features)]
#[cfg(all(feature = "be-dyn-lib", feature = "use-dyn-lib"))]
compile_error!("Can't use both \"be-dyn-lib\" and \"use-dyn-lib\" features at once");
macro_rules! skeleton_impls {
{ struct $Skeleton:ident { $( $(+)? $bone:ident ),* $(,)? } } => {
#[derive(Clone, Default)]
pub struct $Skeleton {
$(
$bone: Bone,
)*
}
impl<'a, Factor> Lerp<Factor> for &'a $Skeleton
where
Factor: Copy,
Bone: Lerp<Factor, Output=Bone>
{
type Output = $Skeleton;
fn lerp_unclamped_precise(from: Self, to: Self, factor: Factor) -> Self::Output {
Self::Output {
$(
$bone: Lerp::lerp_unclamped_precise(from.$bone, to.$bone, factor),
)*
}
}
fn lerp_unclamped(from: Self, to: Self, factor: Factor) -> Self::Output {
Self::Output {
$(
$bone: Lerp::lerp_unclamped(from.$bone, to.$bone, factor),
)*
}
}
}
}
}
pub mod biped_large;
pub mod bird_medium;
pub mod bird_small;
@ -26,86 +63,63 @@ use std::ffi::CStr;
use self::vek::*;
// TODO: replace with inner type everywhere
pub struct FigureBoneData(pub Mat4<f32>);
impl FigureBoneData {
pub fn new(mat: Mat4<f32>) -> Self { Self(mat) }
type MatRaw = [[f32; 4]; 4];
pub fn default() -> Self { Self(Mat4::identity()) }
pub type FigureBoneData = (MatRaw, MatRaw);
pub const MAX_BONE_COUNT: usize = 16;
fn make_bone(mat: Mat4<f32>) -> FigureBoneData {
let normal = mat.map_cols(Vec4::normalized);
(mat.into_col_arrays(), normal.into_col_arrays())
}
#[derive(Copy, Clone, Debug)]
pub struct Bone {
pub offset: Vec3<f32>,
pub ori: Quaternion<f32>,
pub scale: Vec3<f32>,
}
impl Default for Bone {
fn default() -> Self {
Self {
offset: Vec3::zero(),
ori: Quaternion::identity(),
scale: Vec3::broadcast(1.0 / 11.0),
}
}
}
impl Bone {
pub fn compute_base_matrix(&self) -> Mat4<f32> {
Mat4::<f32>::translation_3d(self.offset)
* Mat4::scaling_3d(self.scale)
* Mat4::from(self.ori)
}
/// Change the current bone to be more like `target`.
fn interpolate(&mut self, target: &Bone, dt: f32) {
// TODO: Make configurable.
let factor = (15.0 * dt).min(1.0);
self.offset += (target.offset - self.offset) * factor;
self.ori = vek::Slerp::slerp(self.ori, target.ori, factor);
self.scale += (target.scale - self.scale) * factor;
}
}
pub type Bone = Transform<f32, f32, f32>;
pub trait Skeleton: Send + Sync + 'static {
type Attr;
const BONE_COUNT: usize;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8];
fn bone_count(&self) -> usize { 16 }
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
) -> Vec3<f32>;
}
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>);
fn compute_matrices(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
#[cfg(not(feature = "use-dyn-lib"))]
{
Self::compute_matrices_inner(self)
}
#[cfg(feature = "use-dyn-lib")]
{
let lock = dyn_lib::LIB.lock().unwrap();
let lib = &lock.as_ref().unwrap().lib;
let compute_fn: libloading::Symbol<fn(&Self) -> ([FigureBoneData; 16], Vec3<f32>)> =
unsafe { lib.get(Self::COMPUTE_FN) }.unwrap_or_else(|e| {
panic!(
"Trying to use: {} but had error: {:?}",
CStr::from_bytes_with_nul(Self::COMPUTE_FN)
.map(CStr::to_str)
.unwrap()
.unwrap(),
e
)
});
compute_fn(self)
}
pub fn compute_matrices<S: Skeleton>(
skeleton: &S,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
) -> Vec3<f32> {
#[cfg(not(feature = "use-dyn-lib"))]
{
S::compute_matrices_inner(skeleton, base_mat, buf)
}
#[cfg(feature = "use-dyn-lib")]
{
let lock = dyn_lib::LIB.lock().unwrap();
let lib = &lock.as_ref().unwrap().lib;
/// Change the current skeleton to be more like `target`.
fn interpolate(&mut self, target: &Self, dt: f32);
let compute_fn: libloading::Symbol<
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Vec3<f32>,
> = unsafe { lib.get(Self::COMPUTE_FN) }.unwrap_or_else(|e| {
panic!(
"Trying to use: {} but had error: {:?}",
CStr::from_bytes_with_nul(S::COMPUTE_FN)
.map(CStr::to_str)
.unwrap()
.unwrap(),
e
)
});
compute_fn(skeleton, base_mat, buf)
}
}
pub trait Animation {

View File

@ -1,48 +1,36 @@
use super::{vek::*, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
#[derive(Clone)]
#[derive(Clone, Default)]
pub struct ObjectSkeleton;
pub struct SkeletonAttr;
impl ObjectSkeleton {
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self { Self {} }
impl<'a, Factor> Lerp<Factor> for &'a ObjectSkeleton {
type Output = ObjectSkeleton;
fn lerp_unclamped_precise(_from: Self, _to: Self, _factor: Factor) -> Self::Output {
ObjectSkeleton
}
fn lerp_unclamped(_from: Self, _to: Self, _factor: Factor) -> Self::Output { ObjectSkeleton }
}
pub struct SkeletonAttr;
const SCALE: f32 = 1.0 / 11.0;
impl Skeleton for ObjectSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 1;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"object_compute_mats\0";
fn bone_count(&self) -> usize { 15 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "object_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
(
[
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
],
Vec3::default(),
)
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
buf[0] = make_bone(base_mat * Mat4::scaling_3d(SCALE));
Vec3::default()
}
fn interpolate(&mut self, _target: &Self, _dt: f32) {}
}

View File

@ -31,71 +31,72 @@ impl Animation for AlphaAnimation {
/ (0.001 + 0.9999 * ((anim_time as f32 * 7.0 + PI * 0.0).sin()).powf(2.0 as f32)))
.sqrt())
* ((anim_time as f32 * 7.0 + PI * 0.0).sin());
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_z(short * 0.3) * Quaternion::rotation_x(0.0);
next.head_upper.orientation =
Quaternion::rotation_z(short * 0.3) * Quaternion::rotation_x(0.0);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori =
next.head_lower.orientation =
Quaternion::rotation_z(short * 0.2) * Quaternion::rotation_y(short * -0.4);
next.head_lower.scale = Vec3::one();
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(-0.2 + quick * 0.3);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(-0.2 + quick * 0.3);
next.jaw.scale = Vec3::one() * 0.98;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
* skeleton_attr.scaler
/ 11.0;
next.chest.ori = Quaternion::rotation_y(short * -0.07);
next.chest.orientation = Quaternion::rotation_y(short * -0.07);
next.chest.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.tail_front.offset =
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.ori = Quaternion::rotation_x(0.15)
next.tail_front.orientation = Quaternion::rotation_x(0.15)
* Quaternion::rotation_y(short * 0.2)
* Quaternion::rotation_z(short * 0.3);
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.offset =
next.tail_rear.position =
Vec3::new(0.0, skeleton_attr.tail_rear.0, skeleton_attr.tail_rear.1);
next.tail_rear.ori = Quaternion::rotation_y(short * 0.5)
next.tail_rear.orientation = Quaternion::rotation_y(short * 0.5)
* Quaternion::rotation_x(-0.12)
* Quaternion::rotation_z(short * 0.3);
next.tail_rear.scale = Vec3::one() * 0.98;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fl.ori = Quaternion::rotation_y(short * 0.12);
next.foot_fl.orientation = Quaternion::rotation_y(short * 0.12);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori = Quaternion::rotation_y(short * 0.12);
next.foot_fr.orientation = Quaternion::rotation_y(short * 0.12);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_bl.ori = Quaternion::rotation_y(short * 0.12);
next.foot_bl.orientation = Quaternion::rotation_y(short * 0.12);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori = Quaternion::rotation_y(short * 0.12);
next.foot_br.orientation = Quaternion::rotation_y(short * 0.12);
next.foot_br.scale = Vec3::one();
next

View File

@ -40,74 +40,76 @@ impl Animation for IdleAnimation {
* 0.1,
);
next.head_upper.offset = Vec3::new(
next.head_upper.position = Vec3::new(
0.0,
skeleton_attr.head_upper.0,
skeleton_attr.head_upper.1 + slower * 0.20,
);
next.head_upper.ori = Quaternion::rotation_z(0.8 * dragon_look.x)
next.head_upper.orientation = Quaternion::rotation_z(0.8 * dragon_look.x)
* Quaternion::rotation_x(0.8 * dragon_look.y);
next.head_upper.scale = Vec3::one();
next.head_lower.offset = Vec3::new(
next.head_lower.position = Vec3::new(
0.0,
skeleton_attr.head_lower.0,
skeleton_attr.head_lower.1 + slower * 0.20,
);
next.head_lower.ori = Quaternion::rotation_z(0.8 * dragon_look.x)
next.head_lower.orientation = Quaternion::rotation_z(0.8 * dragon_look.x)
* Quaternion::rotation_x(0.8 * dragon_look.y);
next.head_lower.scale = Vec3::one();
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(slow * 0.04);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.04);
next.jaw.scale = Vec3::one() * 0.98;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
* skeleton_attr.scaler
/ 11.0;
next.chest.ori = Quaternion::rotation_y(slow * 0.03);
next.chest.orientation = Quaternion::rotation_y(slow * 0.03);
next.chest.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.tail_front.offset =
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.ori = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(slowalt * 0.12);
next.tail_front.orientation =
Quaternion::rotation_x(0.15) * Quaternion::rotation_z(slowalt * 0.12);
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.offset =
next.tail_rear.position =
Vec3::new(0.0, skeleton_attr.tail_rear.0, skeleton_attr.tail_rear.1);
next.tail_rear.ori = Quaternion::rotation_z(slowalt * 0.12) * Quaternion::rotation_x(-0.12);
next.tail_rear.orientation =
Quaternion::rotation_z(slowalt * 0.12) * Quaternion::rotation_x(-0.12);
next.tail_rear.scale = Vec3::one() * 0.98;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fl.ori = Quaternion::rotation_y(slow * -0.05);
next.foot_fl.orientation = Quaternion::rotation_y(slow * -0.05);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori = Quaternion::rotation_y(slow * -0.05);
next.foot_fr.orientation = Quaternion::rotation_y(slow * -0.05);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_bl.ori = Quaternion::rotation_y(slow * -0.05);
next.foot_bl.orientation = Quaternion::rotation_y(slow * -0.05);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori = Quaternion::rotation_y(slow * -0.05);
next.foot_br.orientation = Quaternion::rotation_y(slow * -0.05);
next.foot_br.scale = Vec3::one();
next

View File

@ -22,66 +22,66 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.0);
next.head_upper.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.0);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_z(0.2);
next.head_lower.orientation = Quaternion::rotation_z(0.2);
next.head_lower.scale = Vec3::one();
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(-0.3);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(-0.3);
next.jaw.scale = Vec3::one() * 0.98;
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
* skeleton_attr.scaler
/ 11.0;
next.chest.ori = Quaternion::rotation_y(0.0);
next.chest.orientation = Quaternion::rotation_y(0.0);
next.chest.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.tail_front.offset =
next.tail_front.position =
Vec3::new(0.0, skeleton_attr.tail_front.0, skeleton_attr.tail_front.1);
next.tail_front.ori = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(-0.2);
next.tail_front.orientation = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(-0.2);
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.offset =
next.tail_rear.position =
Vec3::new(0.0, skeleton_attr.tail_rear.0, skeleton_attr.tail_rear.1);
next.tail_rear.ori = Quaternion::rotation_z(-0.4) * Quaternion::rotation_x(-0.12);
next.tail_rear.orientation = Quaternion::rotation_z(-0.4) * Quaternion::rotation_x(-0.12);
next.tail_rear.scale = Vec3::one() * 0.98;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fl.ori = Quaternion::rotation_z(0.3);
next.foot_fl.orientation = Quaternion::rotation_z(0.3);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori = Quaternion::rotation_z(0.3);
next.foot_fr.orientation = Quaternion::rotation_z(0.3);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_bl.ori = Quaternion::rotation_y(0.0);
next.foot_bl.orientation = Quaternion::rotation_y(0.0);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori = Quaternion::rotation_y(0.0);
next.foot_br.orientation = Quaternion::rotation_y(0.0);
next.foot_br.scale = Vec3::one();
next

View File

@ -8,80 +8,54 @@ pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct QuadrupedLowSkeleton {
head_upper: Bone,
head_lower: Bone,
jaw: Bone,
chest: Bone,
tail_front: Bone,
tail_rear: Bone,
foot_fl: Bone,
foot_fr: Bone,
foot_bl: Bone,
foot_br: Bone,
}
impl QuadrupedLowSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct QuadrupedLowSkeleton {
+ head_upper,
+ head_lower,
+ jaw,
+ chest,
+ tail_front,
+ tail_rear,
+ foot_fl,
+ foot_fr,
+ foot_bl,
+ foot_br,
});
impl Skeleton for QuadrupedLowSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 10;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"quadruped_low_compute_mats\0";
fn bone_count(&self) -> usize { 10 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let head_upper_mat = self.head_upper.compute_base_matrix();
let head_lower_mat = self.head_lower.compute_base_matrix();
let chest_mat = self.chest.compute_base_matrix();
(
[
FigureBoneData::new(chest_mat * head_lower_mat * head_upper_mat),
FigureBoneData::new(chest_mat * head_lower_mat),
FigureBoneData::new(
chest_mat * head_lower_mat * head_upper_mat * self.jaw.compute_base_matrix(),
),
FigureBoneData::new(chest_mat),
FigureBoneData::new(chest_mat * self.tail_front.compute_base_matrix()),
FigureBoneData::new(
chest_mat
* self.tail_front.compute_base_matrix()
* self.tail_rear.compute_base_matrix(),
),
FigureBoneData::new(chest_mat * self.foot_fl.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.foot_fr.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.foot_bl.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.foot_br.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let tail_front = chest_mat * Mat4::<f32>::from(self.tail_front);
let head_lower_mat = chest_mat * Mat4::<f32>::from(self.head_lower);
let head_upper_mat = head_lower_mat * Mat4::<f32>::from(self.head_upper);
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head_upper.interpolate(&target.head_upper, dt);
self.head_lower.interpolate(&target.head_lower, dt);
self.jaw.interpolate(&target.jaw, dt);
self.chest.interpolate(&target.chest, dt);
self.tail_front.interpolate(&target.tail_front, dt);
self.tail_rear.interpolate(&target.tail_rear, dt);
self.foot_fl.interpolate(&target.foot_fl, dt);
self.foot_fr.interpolate(&target.foot_fr, dt);
self.foot_bl.interpolate(&target.foot_bl, dt);
self.foot_br.interpolate(&target.foot_br, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_upper_mat),
make_bone(head_lower_mat),
make_bone(head_upper_mat * Mat4::<f32>::from(self.jaw)),
make_bone(chest_mat),
make_bone(tail_front),
make_bone(tail_front * Mat4::<f32>::from(self.tail_rear)),
make_bone(chest_mat * Mat4::<f32>::from(self.foot_fl)),
make_bone(chest_mat * Mat4::<f32>::from(self.foot_fr)),
make_bone(chest_mat * Mat4::<f32>::from(self.foot_bl)),
make_bone(chest_mat * Mat4::<f32>::from(self.foot_br)),
];
Vec3::default()
}
}

View File

@ -85,94 +85,96 @@ impl Animation for RunAnimation {
} else {
0.0
} * 1.3;
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_x(-skeleton_attr.lean.0 + x_tilt * -1.0)
next.head_upper.orientation = Quaternion::rotation_x(-skeleton_attr.lean.0 + x_tilt * -1.0)
* Quaternion::rotation_y(tilt * 0.3)
* Quaternion::rotation_z(short * -0.06 + tilt * -1.5);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_y(tilt * 1.0)
next.head_lower.orientation = Quaternion::rotation_y(tilt * 1.0)
* Quaternion::rotation_z(short * -0.15 + tilt * -0.8)
* Quaternion::rotation_x(x_tilt * 0.4);
next.head_lower.scale = Vec3::one();
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(0.0);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(0.0);
next.jaw.scale = Vec3::one() * 0.98;
next.tail_front.offset = Vec3::new(
next.tail_front.position = Vec3::new(
0.0,
skeleton_attr.tail_front.0 + skeleton_attr.lean.0 * 2.0,
skeleton_attr.tail_front.1 + skeleton_attr.lean.0 * 2.0,
);
next.tail_front.ori =
next.tail_front.orientation =
Quaternion::rotation_z(shortalt * 0.18 * skeleton_attr.lean.1 + tilt * 1.8)
* Quaternion::rotation_y(shortalt * 0.1)
* Quaternion::rotation_x(0.06 - skeleton_attr.lean.0 * 1.2 + x_tilt * 0.2);
next.tail_front.scale = Vec3::one();
next.tail_rear.offset = Vec3::new(
next.tail_rear.position = Vec3::new(
0.0,
skeleton_attr.tail_rear.0,
skeleton_attr.tail_rear.1 + shortalt * 0.6,
);
next.tail_rear.ori =
next.tail_rear.orientation =
Quaternion::rotation_z(shortalt * 0.25 * skeleton_attr.lean.1 + tilt * 1.6)
* Quaternion::rotation_y(shortalt * 0.1)
* Quaternion::rotation_x(-0.04 + x_tilt * 0.5);
next.tail_rear.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
* skeleton_attr.scaler
/ 11.0;
next.chest.ori = Quaternion::rotation_z(short * 0.13 + tilt * -1.9)
next.chest.orientation = Quaternion::rotation_z(short * 0.13 + tilt * -1.9)
* Quaternion::rotation_y(short * 0.12 + tilt * 0.7)
* Quaternion::rotation_x(x_tilt + skeleton_attr.lean.0);
next.chest.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + foothoril * -2.0,
skeleton_attr.feet_f.2 + 1.0 + ((footvertl * -1.8).max(-0.0)),
);
next.foot_fl.ori = Quaternion::rotation_x(
next.foot_fl.orientation = Quaternion::rotation_x(
-0.2 + footvertl * -0.45 * skeleton_attr.lean.1 - skeleton_attr.lean.0,
) * Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(foothoril * 0.4 * skeleton_attr.lean.1 + tilt * -2.0);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + foothorir * -2.0,
skeleton_attr.feet_f.2 + 1.0 + ((footvertr * -1.8).max(-0.0)),
);
next.foot_fr.ori = Quaternion::rotation_x(
next.foot_fr.orientation = Quaternion::rotation_x(
-0.2 + footvertr * -0.45 * skeleton_attr.lean.1 - skeleton_attr.lean.0,
) * Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(foothorir * -0.4 * skeleton_attr.lean.1 + tilt * -2.0);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + foothorilb * -1.0,
skeleton_attr.feet_b.2 + ((footvertlb * -1.2).max(-0.0)),
);
next.foot_bl.ori = Quaternion::rotation_x(-0.2 + footvertlb * -0.5 - skeleton_attr.lean.0)
* Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(foothorilb * 0.4 + tilt * -2.0);
next.foot_bl.orientation =
Quaternion::rotation_x(-0.2 + footvertlb * -0.5 - skeleton_attr.lean.0)
* Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(foothorilb * 0.4 + tilt * -2.0);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + foothorirb * -1.0,
skeleton_attr.feet_b.2 + ((footvertrb * -1.2).max(-0.0)),
);
next.foot_br.ori = Quaternion::rotation_x(-0.2 + footvertrb * -0.5 - skeleton_attr.lean.0)
* Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(foothorirb * -0.4 + tilt * -2.0);
next.foot_br.orientation =
Quaternion::rotation_x(-0.2 + footvertrb * -0.5 - skeleton_attr.lean.0)
* Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(foothorirb * -0.4 + tilt * -2.0);
next.foot_br.scale = Vec3::one();
next

View File

@ -32,114 +32,114 @@ impl Animation for AlphaAnimation {
.sqrt())
* ((anim_time as f32 * 4.0 + PI * 0.5).sin());
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori =
next.head_upper.orientation =
Quaternion::rotation_y(short * -0.2) * Quaternion::rotation_x(0.1 + short * 0.2);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head_lower.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head_lower.scale = Vec3::one() * 1.02;
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(-0.3 + quick * 0.4);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(-0.3 + quick * 0.4);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one();
next.torso_front.offset = Vec3::new(
next.torso_front.position = Vec3::new(
0.0,
skeleton_attr.torso_front.0 + short * 2.8,
skeleton_attr.torso_front.1 + short * 1.0,
) * skeleton_attr.scaler
/ 11.0;
next.torso_front.ori = Quaternion::rotation_y(short * -0.1);
next.torso_front.orientation = Quaternion::rotation_y(short * -0.1);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset =
next.torso_back.position =
Vec3::new(0.0, skeleton_attr.torso_back.0, skeleton_attr.torso_back.1);
next.torso_back.ori = Quaternion::rotation_y(short * -0.1)
next.torso_back.orientation = Quaternion::rotation_y(short * -0.1)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0);
next.torso_back.scale = Vec3::one();
next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.ori = Quaternion::rotation_x(0.0);
next.ears.position = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.orientation = Quaternion::rotation_x(0.0);
next.ears.scale = Vec3::one() * 1.02;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1,
skeleton_attr.leg_f.2,
);
next.leg_fl.ori =
next.leg_fl.orientation =
Quaternion::rotation_x(short * -0.1) * Quaternion::rotation_y(short * 0.15);
next.leg_fl.scale = Vec3::one();
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1,
skeleton_attr.leg_f.2,
);
next.leg_fr.ori =
next.leg_fr.orientation =
Quaternion::rotation_x(short * 0.3) * Quaternion::rotation_y(short * -0.2);
next.leg_fr.scale = Vec3::one();
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1,
skeleton_attr.leg_b.2 + 1.0,
);
next.leg_bl.ori =
next.leg_bl.orientation =
Quaternion::rotation_x(-0.1 + short * -0.2) * Quaternion::rotation_y(short * 0.2);
next.leg_bl.scale = Vec3::one();
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1,
skeleton_attr.leg_b.2 + 1.0,
);
next.leg_br.ori =
next.leg_br.orientation =
Quaternion::rotation_x(-0.1 + short * -0.2) * Quaternion::rotation_y(0.1 + short * 0.2);
next.leg_br.scale = Vec3::one();
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + short * -0.2,
);
next.foot_fl.ori = Quaternion::rotation_x(short * -0.05);
next.foot_fl.orientation = Quaternion::rotation_x(short * -0.05);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori =
next.foot_fr.orientation =
Quaternion::rotation_x(short * -0.4) * Quaternion::rotation_y(short * 0.15);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + short * -0.8,
);
next.foot_bl.ori =
next.foot_bl.orientation =
Quaternion::rotation_x(-0.2 + short * 0.2) * Quaternion::rotation_y(short * 0.15);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori =
next.foot_br.orientation =
Quaternion::rotation_x(-0.2 + short * 0.2) * Quaternion::rotation_y(short * 0.15);
next.foot_br.scale = Vec3::one();
next

View File

@ -51,121 +51,121 @@ impl Animation for IdleAnimation {
* 0.125,
);
next.head_upper.offset = Vec3::new(
next.head_upper.position = Vec3::new(
0.0,
skeleton_attr.head_upper.0,
skeleton_attr.head_upper.1 + slower * 0.2,
);
next.head_upper.ori =
next.head_upper.orientation =
Quaternion::rotation_z(0.3 * look.x) * Quaternion::rotation_x(0.3 * look.y);
next.head_upper.scale = Vec3::one();
next.head_lower.offset = Vec3::new(
next.head_lower.position = Vec3::new(
0.0,
skeleton_attr.head_lower.0,
skeleton_attr.head_lower.1 + slower * 0.1,
);
next.head_lower.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head_lower.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head_lower.scale = Vec3::one() * 1.02;
next.jaw.offset = Vec3::new(
next.jaw.position = Vec3::new(
0.0,
skeleton_attr.jaw.0 - slower * 0.12,
skeleton_attr.jaw.1 + slow * 0.2,
);
next.jaw.ori = Quaternion::rotation_x(slow * 0.05);
next.jaw.orientation = Quaternion::rotation_x(slow * 0.05);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori =
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_z(0.0 + slow * 0.2 + tailmove.x) * Quaternion::rotation_x(0.0);
next.tail.scale = Vec3::one();
next.torso_front.offset = Vec3::new(
next.torso_front.position = Vec3::new(
0.0,
skeleton_attr.torso_front.0,
skeleton_attr.torso_front.1 + slower * 0.3,
) * skeleton_attr.scaler
/ 11.0;
next.torso_front.ori = Quaternion::rotation_y(slow * 0.02);
next.torso_front.orientation = Quaternion::rotation_y(slow * 0.02);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset = Vec3::new(
next.torso_back.position = Vec3::new(
0.0,
skeleton_attr.torso_back.0,
skeleton_attr.torso_back.1 + slower * 0.2,
);
next.torso_back.ori = Quaternion::rotation_y(-slow * 0.005)
next.torso_back.orientation = Quaternion::rotation_y(-slow * 0.005)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0);
next.torso_back.scale = Vec3::one() * 0.99;
next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.ori = Quaternion::rotation_x(0.0 + slower * 0.03);
next.ears.position = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.orientation = Quaternion::rotation_x(0.0 + slower * 0.03);
next.ears.scale = Vec3::one() * 1.02;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1,
skeleton_attr.leg_f.2 + slow * -0.15 + slower * -0.15,
);
next.leg_fl.ori = Quaternion::rotation_y(slow * -0.02);
next.leg_fl.orientation = Quaternion::rotation_y(slow * -0.02);
next.leg_fl.scale = Vec3::one() * 1.02;
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1,
skeleton_attr.leg_f.2 + slow * 0.15 + slower * -0.15,
);
next.leg_fr.ori = Quaternion::rotation_y(slow * -0.02);
next.leg_fr.orientation = Quaternion::rotation_y(slow * -0.02);
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1,
skeleton_attr.leg_b.2 + slower * -0.3,
);
next.leg_bl.ori = Quaternion::rotation_y(slow * -0.02);
next.leg_bl.orientation = Quaternion::rotation_y(slow * -0.02);
next.leg_bl.scale = Vec3::one() * 1.02;
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1,
skeleton_attr.leg_b.2 + slower * -0.3,
);
next.leg_br.ori = Quaternion::rotation_y(slow * -0.02);
next.leg_br.orientation = Quaternion::rotation_y(slow * -0.02);
next.leg_br.scale = Vec3::one() * 1.02;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + slower * -0.2,
);
next.foot_fl.ori = Quaternion::rotation_x(0.0);
next.foot_fl.orientation = Quaternion::rotation_x(0.0);
next.foot_fl.scale = Vec3::one() * 0.94;
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + slower * -0.2,
);
next.foot_fr.ori = Quaternion::rotation_x(0.0);
next.foot_fr.orientation = Quaternion::rotation_x(0.0);
next.foot_fr.scale = Vec3::one() * 0.94;
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + slower * -0.2,
);
next.foot_bl.ori = Quaternion::rotation_x(0.0);
next.foot_bl.orientation = Quaternion::rotation_x(0.0);
next.foot_bl.scale = Vec3::one() * 0.94;
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + slower * -0.2,
);
next.foot_br.ori = Quaternion::rotation_x(0.0);
next.foot_br.orientation = Quaternion::rotation_x(0.0);
next.foot_br.scale = Vec3::one() * 0.94;
next

View File

@ -22,106 +22,106 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.3);
next.head_upper.orientation = Quaternion::rotation_z(0.4) * Quaternion::rotation_x(0.3);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_z(0.2) * Quaternion::rotation_x(0.3);
next.head_lower.orientation = Quaternion::rotation_z(0.2) * Quaternion::rotation_x(0.3);
next.head_lower.scale = Vec3::one() * 1.02;
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(-0.4);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(-0.4);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.3);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(-0.3);
next.tail.scale = Vec3::one();
next.torso_front.offset = Vec3::new(
next.torso_front.position = Vec3::new(
0.0,
skeleton_attr.torso_front.0,
skeleton_attr.torso_front.1,
) * skeleton_attr.scaler
/ 11.0;
next.torso_front.ori = Quaternion::rotation_y(0.0);
next.torso_front.orientation = Quaternion::rotation_y(0.0);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset =
next.torso_back.position =
Vec3::new(0.0, skeleton_attr.torso_back.0, skeleton_attr.torso_back.1);
next.torso_back.ori = Quaternion::rotation_z(-0.3)
next.torso_back.orientation = Quaternion::rotation_z(-0.3)
* Quaternion::rotation_z(0.0)
* Quaternion::rotation_x(0.0);
next.torso_back.scale = Vec3::one();
next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.ori = Quaternion::rotation_x(0.6);
next.ears.position = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.orientation = Quaternion::rotation_x(0.6);
next.ears.scale = Vec3::one() * 1.02;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1,
skeleton_attr.leg_f.2,
);
next.leg_fl.ori = Quaternion::rotation_x(-0.4);
next.leg_fl.orientation = Quaternion::rotation_x(-0.4);
next.leg_fl.scale = Vec3::one();
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1,
skeleton_attr.leg_f.2,
);
next.leg_fr.ori = Quaternion::rotation_x(0.4);
next.leg_fr.orientation = Quaternion::rotation_x(0.4);
next.leg_fr.scale = Vec3::one();
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1,
skeleton_attr.leg_b.2,
);
next.leg_bl.ori = Quaternion::rotation_y(0.0);
next.leg_bl.orientation = Quaternion::rotation_y(0.0);
next.leg_bl.scale = Vec3::one();
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1,
skeleton_attr.leg_b.2,
);
next.leg_br.ori = Quaternion::rotation_y(0.0);
next.leg_br.orientation = Quaternion::rotation_y(0.0);
next.leg_br.scale = Vec3::one();
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fl.ori = Quaternion::rotation_x(-0.3);
next.foot_fl.orientation = Quaternion::rotation_x(-0.3);
next.foot_fl.scale = Vec3::one();
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.foot_fr.ori = Quaternion::rotation_x(0.2);
next.foot_fr.orientation = Quaternion::rotation_x(0.2);
next.foot_fr.scale = Vec3::one();
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_bl.ori = Quaternion::rotation_x(0.0);
next.foot_bl.orientation = Quaternion::rotation_x(0.0);
next.foot_bl.scale = Vec3::one();
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.foot_br.ori = Quaternion::rotation_x(0.0);
next.foot_br.orientation = Quaternion::rotation_x(0.0);
next.foot_br.scale = Vec3::one();
next

View File

@ -8,112 +8,68 @@ pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct QuadrupedMediumSkeleton {
head_upper: Bone,
head_lower: Bone,
jaw: Bone,
tail: Bone,
torso_front: Bone,
torso_back: Bone,
ears: Bone,
leg_fl: Bone,
leg_fr: Bone,
leg_bl: Bone,
leg_br: Bone,
foot_fl: Bone,
foot_fr: Bone,
foot_bl: Bone,
foot_br: Bone,
}
impl QuadrupedMediumSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct QuadrupedMediumSkeleton {
+ head_upper,
+ head_lower,
+ jaw,
+ tail,
+ torso_front,
+ torso_back,
+ ears,
+ leg_fl,
+ leg_fr,
+ leg_bl,
+ leg_br,
+ foot_fl,
+ foot_fr,
+ foot_bl,
+ foot_br,
});
impl Skeleton for QuadrupedMediumSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 15;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"quadruped_medium_compute_mats\0";
fn bone_count(&self) -> usize { 15 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let ears_mat = self.ears.compute_base_matrix();
let head_upper_mat = self.head_upper.compute_base_matrix();
let head_lower_mat = self.head_lower.compute_base_matrix();
let torso_front_mat = self.torso_front.compute_base_matrix();
let torso_back_mat = self.torso_back.compute_base_matrix();
let leg_fl_mat = self.leg_fl.compute_base_matrix();
let leg_fr_mat = self.leg_fr.compute_base_matrix();
let leg_bl_mat = self.leg_bl.compute_base_matrix();
let leg_br_mat = self.leg_br.compute_base_matrix();
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_front_mat = base_mat * Mat4::<f32>::from(self.torso_front);
let torso_back_mat = torso_front_mat * Mat4::<f32>::from(self.torso_back);
let head_lower_mat = torso_front_mat * Mat4::<f32>::from(self.head_lower);
let leg_fl_mat = torso_front_mat * Mat4::<f32>::from(self.leg_fl);
let leg_fr_mat = torso_front_mat * Mat4::<f32>::from(self.leg_fr);
let leg_bl_mat = torso_back_mat * Mat4::<f32>::from(self.leg_bl);
let leg_br_mat = torso_back_mat * Mat4::<f32>::from(self.leg_br);
let head_upper_mat = head_lower_mat * Mat4::<f32>::from(self.head_upper);
(
[
FigureBoneData::new(torso_front_mat * head_lower_mat * head_upper_mat),
FigureBoneData::new(torso_front_mat * head_lower_mat),
FigureBoneData::new(
torso_front_mat
* head_lower_mat
* head_upper_mat
* self.jaw.compute_base_matrix(),
),
FigureBoneData::new(
torso_front_mat * torso_back_mat * self.tail.compute_base_matrix(),
),
FigureBoneData::new(torso_front_mat),
FigureBoneData::new(torso_front_mat * torso_back_mat),
FigureBoneData::new(torso_front_mat * head_lower_mat * head_upper_mat * ears_mat),
FigureBoneData::new(torso_front_mat * leg_fl_mat),
FigureBoneData::new(torso_front_mat * leg_fr_mat),
FigureBoneData::new(torso_front_mat * torso_back_mat * leg_bl_mat),
FigureBoneData::new(torso_front_mat * torso_back_mat * leg_br_mat),
FigureBoneData::new(
torso_front_mat * leg_fl_mat * self.foot_fl.compute_base_matrix(),
),
FigureBoneData::new(
torso_front_mat * leg_fr_mat * self.foot_fr.compute_base_matrix(),
),
FigureBoneData::new(
torso_front_mat
* torso_back_mat
* leg_bl_mat
* self.foot_bl.compute_base_matrix(),
),
FigureBoneData::new(
torso_front_mat
* torso_back_mat
* leg_br_mat
* self.foot_br.compute_base_matrix(),
),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head_upper.interpolate(&target.head_upper, dt);
self.head_lower.interpolate(&target.head_lower, dt);
self.jaw.interpolate(&target.jaw, dt);
self.tail.interpolate(&target.tail, dt);
self.torso_back.interpolate(&target.torso_back, dt);
self.torso_front.interpolate(&target.torso_front, dt);
self.ears.interpolate(&target.ears, dt);
self.leg_fl.interpolate(&target.leg_fl, dt);
self.leg_fr.interpolate(&target.leg_fr, dt);
self.leg_bl.interpolate(&target.leg_bl, dt);
self.leg_br.interpolate(&target.leg_br, dt);
self.foot_fl.interpolate(&target.foot_fl, dt);
self.foot_fr.interpolate(&target.foot_fr, dt);
self.foot_bl.interpolate(&target.foot_bl, dt);
self.foot_br.interpolate(&target.foot_br, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_upper_mat),
make_bone(head_lower_mat),
make_bone(head_upper_mat * Mat4::<f32>::from(self.jaw)),
make_bone(torso_back_mat * Mat4::<f32>::from(self.tail)),
make_bone(torso_front_mat),
make_bone(torso_back_mat),
make_bone(head_upper_mat * Mat4::<f32>::from(self.ears)),
make_bone(leg_fl_mat),
make_bone(leg_fr_mat),
make_bone(leg_bl_mat),
make_bone(leg_br_mat),
make_bone(leg_fl_mat * Mat4::<f32>::from(self.foot_fl)),
make_bone(leg_fr_mat * Mat4::<f32>::from(self.foot_fr)),
make_bone(leg_bl_mat * Mat4::<f32>::from(self.foot_bl)),
make_bone(leg_br_mat * Mat4::<f32>::from(self.foot_br)),
];
Vec3::default()
}
}

View File

@ -75,247 +75,248 @@ impl Animation for RunAnimation {
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
if speed < 8.0 {
//Trot
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_x(short * -0.03 - 0.1 + x_tilt * -0.5)
* Quaternion::rotation_z(tilt * -1.2);
next.head_upper.orientation =
Quaternion::rotation_x(short * -0.03 - 0.1 + x_tilt * -0.5)
* Quaternion::rotation_z(tilt * -1.2);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_z(tilt * -0.8)
next.head_lower.orientation = Quaternion::rotation_z(tilt * -0.8)
* Quaternion::rotation_x(short * -0.05 + x_tilt * -0.5);
next.head_lower.scale = Vec3::one() * 1.02;
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(0.0);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(0.0);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori =
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_x(shortalt * 0.3) * Quaternion::rotation_z(tilt * 1.5);
next.tail.scale = Vec3::one();
next.torso_front.offset = Vec3::new(
next.torso_front.position = Vec3::new(
0.0,
skeleton_attr.torso_front.0,
skeleton_attr.torso_front.1 + shortalt * 1.0 + x_tilt,
) * skeleton_attr.scaler
/ 11.0;
next.torso_front.ori = Quaternion::rotation_x(short * 0.03 + x_tilt)
next.torso_front.orientation = Quaternion::rotation_x(short * 0.03 + x_tilt)
* Quaternion::rotation_y(0.0)
* Quaternion::rotation_z(tilt * -1.5);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset = Vec3::new(
next.torso_back.position = Vec3::new(
0.0,
skeleton_attr.torso_back.0,
skeleton_attr.torso_back.1 + shortalt * 0.04 - 0.2,
);
next.torso_back.ori =
next.torso_back.orientation =
Quaternion::rotation_x(short * 0.06) * Quaternion::rotation_z(tilt * 1.8);
next.torso_back.scale = Vec3::one();
next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.ori = Quaternion::rotation_x(shortalt * 0.04 + 0.2);
next.ears.position = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.orientation = Quaternion::rotation_x(shortalt * 0.04 + 0.2);
next.ears.scale = Vec3::one() * 1.02;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1 + footvertaltfslow * -1.4,
skeleton_attr.leg_f.2 + 1.0 + footverttaltfslow * -0.3,
);
next.leg_fl.ori = Quaternion::rotation_x(footverttaltfslow * -0.35)
next.leg_fl.orientation = Quaternion::rotation_x(footverttaltfslow * -0.35)
* Quaternion::rotation_z(tilt * -0.5);
next.leg_fl.scale = Vec3::one() * 1.02;
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1 + footvertalt * -1.4,
skeleton_attr.leg_f.2 + 1.0 + footverttalt * -0.3,
);
next.leg_fr.ori =
next.leg_fr.orientation =
Quaternion::rotation_x(footverttalt * -0.35) * Quaternion::rotation_z(tilt * -0.5);
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + footvertalt * -1.0,
skeleton_attr.leg_b.2 + 1.0 + footverttalt * -0.3,
);
next.leg_bl.ori =
next.leg_bl.orientation =
Quaternion::rotation_x(footverttalt * -0.2) * Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.scale = Vec3::one() * 1.02;
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + footvertaltfslow * -1.0,
skeleton_attr.leg_b.2 + 1.0 + footverttaltfslow * -0.3,
);
next.leg_br.ori = Quaternion::rotation_x(footverttaltfslow * -0.2)
next.leg_br.orientation = Quaternion::rotation_x(footverttaltfslow * -0.2)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_br.scale = Vec3::one() * 1.02;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + ((footvertfslow * -1.0 * skeleton_attr.maximize).max(0.0)),
);
next.foot_fl.ori =
next.foot_fl.orientation =
Quaternion::rotation_x((1.0 - skeleton_attr.dampen) * -1.0 + footverttfslow * 0.5);
next.foot_fl.scale = Vec3::one() * 0.96;
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + ((footvert * -1.0 * skeleton_attr.maximize).max(0.0)),
);
next.foot_fr.ori =
next.foot_fr.orientation =
Quaternion::rotation_x((1.0 - skeleton_attr.dampen) * -1.0 + footvertt * 0.5);
next.foot_fr.scale = Vec3::one() * 0.96;
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + ((footvert * -1.8).max(0.0)),
);
next.foot_bl.ori = Quaternion::rotation_x(footvertt * 0.5 - 0.2);
next.foot_bl.orientation = Quaternion::rotation_x(footvertt * 0.5 - 0.2);
next.foot_bl.scale = Vec3::one() * 0.96;
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + ((footvertfslow * -0.8).max(-0.0)),
);
next.foot_br.ori = Quaternion::rotation_x(footverttfslow * 0.5 - 0.2);
next.foot_br.orientation = Quaternion::rotation_x(footverttfslow * 0.5 - 0.2);
next.foot_br.scale = Vec3::one() * 0.96;
} else {
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
//Gallop
next.head_upper.offset =
next.head_upper.position =
Vec3::new(0.0, skeleton_attr.head_upper.0, skeleton_attr.head_upper.1);
next.head_upper.ori = Quaternion::rotation_x(short * -0.03 - 0.1)
next.head_upper.orientation = Quaternion::rotation_x(short * -0.03 - 0.1)
* Quaternion::rotation_z(tilt * -1.2)
* Quaternion::rotation_y(tilt * 0.8);
next.head_upper.scale = Vec3::one();
next.head_lower.offset =
next.head_lower.position =
Vec3::new(0.0, skeleton_attr.head_lower.0, skeleton_attr.head_lower.1);
next.head_lower.ori = Quaternion::rotation_z(tilt * -0.8)
next.head_lower.orientation = Quaternion::rotation_z(tilt * -0.8)
* Quaternion::rotation_x(short * -0.05)
* Quaternion::rotation_y(tilt * 0.3);
next.head_lower.scale = Vec3::one() * 1.02;
next.jaw.offset = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.ori = Quaternion::rotation_x(0.0);
next.jaw.position = Vec3::new(0.0, skeleton_attr.jaw.0, skeleton_attr.jaw.1);
next.jaw.orientation = Quaternion::rotation_x(0.0);
next.jaw.scale = Vec3::one() * 1.02;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori =
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation =
Quaternion::rotation_x(shortalt * 0.3) * Quaternion::rotation_z(tilt * 1.5);
next.tail.scale = Vec3::one();
next.torso_front.offset = Vec3::new(
next.torso_front.position = Vec3::new(
0.0,
skeleton_attr.torso_front.0,
skeleton_attr.torso_front.1 + shortalt * 2.5 + x_tilt * 10.0,
) * skeleton_attr.scaler
/ 11.0;
next.torso_front.ori = Quaternion::rotation_x(short * 0.13 + x_tilt)
next.torso_front.orientation = Quaternion::rotation_x(short * 0.13 + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.5);
next.torso_front.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.torso_back.offset = Vec3::new(
next.torso_back.position = Vec3::new(
0.0,
skeleton_attr.torso_back.0,
skeleton_attr.torso_back.1 + shortalt * 0.2 - 0.2,
);
next.torso_back.ori = Quaternion::rotation_x(short * 0.1)
next.torso_back.orientation = Quaternion::rotation_x(short * 0.1)
* Quaternion::rotation_z(tilt * 1.8)
* Quaternion::rotation_y(tilt * 0.6);
next.torso_back.scale = Vec3::one();
next.ears.offset = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.ori = Quaternion::rotation_x(shortalt * 0.2 + 0.2);
next.ears.position = Vec3::new(0.0, skeleton_attr.ears.0, skeleton_attr.ears.1);
next.ears.orientation = Quaternion::rotation_x(shortalt * 0.2 + 0.2);
next.ears.scale = Vec3::one() * 1.02;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1 + footvertaltf * -1.3,
skeleton_attr.leg_f.2 + 1.0 + footverttaltf * -1.9,
);
next.leg_fl.ori = Quaternion::rotation_x(footverttaltf * -0.65)
next.leg_fl.orientation = Quaternion::rotation_x(footverttaltf * -0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fl.scale = Vec3::one() * 1.02;
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.leg_f.0,
skeleton_attr.leg_f.1 + footvertalt * -1.3,
skeleton_attr.leg_f.2 + 1.0 + footverttalt * -1.9,
);
next.leg_fr.ori = Quaternion::rotation_x(footverttalt * -0.65)
next.leg_fr.orientation = Quaternion::rotation_x(footverttalt * -0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + footvert * -1.7,
skeleton_attr.leg_b.2 + 1.0 + footvertt * -1.5,
);
next.leg_bl.ori = Quaternion::rotation_x(footvertt * -0.45 - 0.2)
next.leg_bl.orientation = Quaternion::rotation_x(footvertt * -0.45 - 0.2)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.scale = Vec3::one() * 1.02;
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.leg_b.0,
skeleton_attr.leg_b.1 + footvertf * -1.7,
skeleton_attr.leg_b.2 + 1.0 + footverttf * -1.5,
);
next.leg_br.ori = Quaternion::rotation_x(footverttf * -0.45 - 0.2)
next.leg_br.orientation = Quaternion::rotation_x(footverttf * -0.45 - 0.2)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_br.scale = Vec3::one() * 1.02;
next.foot_fl.offset = Vec3::new(
next.foot_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + ((footvertf * -2.7 * skeleton_attr.maximize).max(0.0)),
);
next.foot_fl.ori =
next.foot_fl.orientation =
Quaternion::rotation_x((1.0 - skeleton_attr.dampen) * -1.0 + footverttf * 0.9)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_fl.scale = Vec3::one() * 0.96;
next.foot_fr.offset = Vec3::new(
next.foot_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + ((footvert * -2.7 * skeleton_attr.maximize).max(0.0)),
);
next.foot_fr.ori =
next.foot_fr.orientation =
Quaternion::rotation_x((1.0 - skeleton_attr.dampen) * -1.0 + footvertt * 0.9)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_fr.scale = Vec3::one() * 0.96;
next.foot_bl.offset = Vec3::new(
next.foot_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + ((footvert * 1.3).max(0.0)),
);
next.foot_bl.ori = Quaternion::rotation_x(footvertt * -0.9 - 0.2)
next.foot_bl.orientation = Quaternion::rotation_x(footvertt * -0.9 - 0.2)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_bl.scale = Vec3::one() * 0.96;
next.foot_br.offset = Vec3::new(
next.foot_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + ((footvertf * 1.3).max(-0.0)),
);
next.foot_br.ori = Quaternion::rotation_x(footverttf * -0.9 - 0.2)
next.foot_br.orientation = Quaternion::rotation_x(footverttf * -0.9 - 0.2)
* Quaternion::rotation_y(tilt * -1.0);
next.foot_br.scale = Vec3::one() * 0.96;
}

View File

@ -41,60 +41,62 @@ impl Animation for FeedAnimation {
* 0.5,
);
next.head.offset = Vec3::new(
next.head.position = Vec3::new(
0.0,
skeleton_attr.head.0 + 1.5,
skeleton_attr.head.1 + slow * 0.2,
);
next.head.ori = Quaternion::rotation_z(head_look.y)
next.head.orientation = Quaternion::rotation_z(head_look.y)
* Quaternion::rotation_x(slow * 0.05 + quick * 0.08 - 0.4 * skeleton_attr.feed);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(slow * 0.02, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(slow * 0.02, skeleton_attr.chest.0, skeleton_attr.chest.1)
/ 11.0
* skeleton_attr.scaler;
next.chest.ori = Quaternion::rotation_x(-0.35 * skeleton_attr.feed)
next.chest.orientation = Quaternion::rotation_x(-0.35 * skeleton_attr.feed)
* Quaternion::rotation_y(head_look.y * 0.1);
next.chest.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + 0.5,
);
next.leg_fl.ori = Quaternion::rotation_x(slow * 0.01 + 0.25 * skeleton_attr.feed)
next.leg_fl.orientation = Quaternion::rotation_x(slow * 0.01 + 0.25 * skeleton_attr.feed)
* Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
next.leg_fl.scale = Vec3::one();
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + 0.5,
);
next.leg_fr.ori = Quaternion::rotation_x(slow_alt * 0.01 + 0.25 * skeleton_attr.feed)
* Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
next.leg_fr.orientation =
Quaternion::rotation_x(slow_alt * 0.01 + 0.25 * skeleton_attr.feed)
* Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
next.leg_fr.scale = Vec3::one();
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + 1.0,
skeleton_attr.feet_b.2 - 1.0,
);
next.leg_bl.ori = Quaternion::rotation_x(slow_alt * 0.01 + 0.15 * skeleton_attr.feed)
* Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
next.leg_bl.orientation =
Quaternion::rotation_x(slow_alt * 0.01 + 0.15 * skeleton_attr.feed)
* Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
next.leg_bl.scale = Vec3::one();
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + 1.0,
skeleton_attr.feet_b.2 - 1.0,
);
next.leg_br.ori = Quaternion::rotation_x(slow * 0.01 + 0.15 * skeleton_attr.feed)
next.leg_br.orientation = Quaternion::rotation_x(slow * 0.01 + 0.15 * skeleton_attr.feed)
* Quaternion::rotation_y(slow * -0.02 - head_look.y * 0.1);
next.leg_br.scale = Vec3::one();
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_z(slow * 0.3 + head_look.y * 0.3);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_z(slow * 0.3 + head_look.y * 0.3);
next.tail.scale = Vec3::one();
next

View File

@ -40,55 +40,56 @@ impl Animation for IdleAnimation {
* 0.25,
);
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1 + slow * 0.2);
next.head.ori = Quaternion::rotation_z(head_look.x)
next.head.position =
Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1 + slow * 0.2);
next.head.orientation = Quaternion::rotation_z(head_look.x)
* Quaternion::rotation_x(head_look.y + slow_alt * 0.03);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(slow * 0.05, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(slow * 0.05, skeleton_attr.chest.0, skeleton_attr.chest.1)
/ 11.0
* skeleton_attr.scaler;
next.chest.ori = Quaternion::rotation_y(slow * 0.05);
next.chest.orientation = Quaternion::rotation_y(slow * 0.05);
next.chest.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + slow * -0.2,
);
next.leg_fl.ori =
next.leg_fl.orientation =
Quaternion::rotation_x(slow * 0.03) * Quaternion::rotation_y(slow * -0.05);
next.leg_fl.scale = Vec3::one();
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2 + slow * 0.2,
);
next.leg_fr.ori =
next.leg_fr.orientation =
Quaternion::rotation_x(slow_alt * 0.03) * Quaternion::rotation_y(slow * -0.05);
next.leg_fr.scale = Vec3::one();
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + slow * -0.2,
);
next.leg_bl.ori =
next.leg_bl.orientation =
Quaternion::rotation_x(slow_alt * 0.03) * Quaternion::rotation_y(slow * -0.05);
next.leg_bl.scale = Vec3::one();
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2 + slow * 0.2,
);
next.leg_br.ori =
next.leg_br.orientation =
Quaternion::rotation_x(slow * 0.03) * Quaternion::rotation_y(slow * -0.05);
next.leg_br.scale = Vec3::one();
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_z(slow * 0.4);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_z(slow * 0.4);
next.tail.scale = Vec3::one();
next

View File

@ -22,50 +22,50 @@ impl Animation for JumpAnimation {
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_z(-0.8) * Quaternion::rotation_x(0.5);
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_z(-0.8) * Quaternion::rotation_x(0.5);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
next.chest.position = Vec3::new(0.0, skeleton_attr.chest.0, skeleton_attr.chest.1)
* skeleton_attr.scaler
/ 11.0;
next.chest.ori = Quaternion::rotation_y(0.0);
next.chest.orientation = Quaternion::rotation_y(0.0);
next.chest.scale = Vec3::one() * skeleton_attr.scaler / 11.0;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.leg_fl.ori = Quaternion::rotation_x(0.0);
next.leg_fl.orientation = Quaternion::rotation_x(0.0);
next.leg_fl.scale = Vec3::one();
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1,
skeleton_attr.feet_f.2,
);
next.leg_fr.ori = Quaternion::rotation_x(0.0);
next.leg_fr.orientation = Quaternion::rotation_x(0.0);
next.leg_fr.scale = Vec3::one();
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.leg_bl.ori = Quaternion::rotation_x(0.0);
next.leg_bl.orientation = Quaternion::rotation_x(0.0);
next.leg_bl.scale = Vec3::one();
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1,
skeleton_attr.feet_b.2,
);
next.leg_br.ori = Quaternion::rotation_x(0.0);
next.leg_br.orientation = Quaternion::rotation_x(0.0);
next.leg_br.scale = Vec3::one();
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_x(-0.3);
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_x(-0.3);
next.tail.scale = Vec3::one();
next
}

View File

@ -6,66 +6,45 @@ pub mod run;
// Reexports
pub use self::{feed::FeedAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use super::{make_bone, vek::*, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
#[derive(Clone, Default)]
pub struct QuadrupedSmallSkeleton {
head: Bone,
chest: Bone,
leg_fl: Bone,
leg_fr: Bone,
leg_bl: Bone,
leg_br: Bone,
tail: Bone,
}
impl QuadrupedSmallSkeleton {
pub fn new() -> Self { Self::default() }
}
skeleton_impls!(struct QuadrupedSmallSkeleton {
+ head,
+ chest,
+ leg_fl,
+ leg_fr,
+ leg_bl,
+ leg_br,
+ tail,
});
impl Skeleton for QuadrupedSmallSkeleton {
type Attr = SkeletonAttr;
const BONE_COUNT: usize = 7;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"quadruped_small_compute_mats\0";
fn bone_count(&self) -> usize { 7 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_small_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let chest_mat = self.chest.compute_base_matrix();
(
[
FigureBoneData::new(chest_mat * self.head.compute_base_matrix()),
FigureBoneData::new(chest_mat),
FigureBoneData::new(chest_mat * self.leg_fl.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.leg_fr.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.leg_bl.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.leg_br.compute_base_matrix()),
FigureBoneData::new(chest_mat * self.tail.compute_base_matrix()),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
FigureBoneData::default(),
],
Vec3::default(),
)
}
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
fn interpolate(&mut self, target: &Self, dt: f32) {
self.head.interpolate(&target.head, dt);
self.chest.interpolate(&target.chest, dt);
self.leg_fl.interpolate(&target.leg_fl, dt);
self.leg_fr.interpolate(&target.leg_fr, dt);
self.leg_bl.interpolate(&target.leg_bl, dt);
self.leg_br.interpolate(&target.leg_br, dt);
self.tail.interpolate(&target.tail, dt);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(chest_mat * Mat4::<f32>::from(self.head)),
make_bone(chest_mat),
make_bone(chest_mat * Mat4::<f32>::from(self.leg_fl)),
make_bone(chest_mat * Mat4::<f32>::from(self.leg_fr)),
make_bone(chest_mat * Mat4::<f32>::from(self.leg_bl)),
make_bone(chest_mat * Mat4::<f32>::from(self.leg_br)),
make_bone(chest_mat * Mat4::<f32>::from(self.tail)),
];
Vec3::default()
}
}

View File

@ -50,13 +50,13 @@ impl Animation for RunAnimation {
} * 1.3;
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
next.head.offset = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.ori = Quaternion::rotation_x(x_tilt * -0.5 + short * -0.2)
next.head.position = Vec3::new(0.0, skeleton_attr.head.0, skeleton_attr.head.1);
next.head.orientation = Quaternion::rotation_x(x_tilt * -0.5 + short * -0.2)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.2);
next.head.scale = Vec3::one();
next.chest.offset = Vec3::new(
next.chest.position = Vec3::new(
0.0,
skeleton_attr.chest.0,
skeleton_attr.chest.1
@ -64,54 +64,58 @@ impl Animation for RunAnimation {
+ shortalt * 3.0 * skeleton_attr.spring,
) / 11.0
* skeleton_attr.scaler;
next.chest.ori = Quaternion::rotation_x(short * 0.2 * skeleton_attr.spring + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.5);
next.chest.orientation =
Quaternion::rotation_x(short * 0.2 * skeleton_attr.spring + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * -1.5);
next.chest.scale = Vec3::one() / 11.0 * skeleton_attr.scaler;
next.leg_fl.offset = Vec3::new(
next.leg_fl.position = Vec3::new(
-skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + footverttf * 3.0 * skeleton_attr.maximize,
skeleton_attr.feet_f.2 + ((footvertf * -1.5).max(-1.0)),
);
next.leg_fl.ori = Quaternion::rotation_x(0.2 + skeleton_attr.minimize * footverttf * 0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fl.orientation =
Quaternion::rotation_x(0.2 + skeleton_attr.minimize * footverttf * 0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fl.scale = Vec3::one() * 1.02;
next.leg_fr.offset = Vec3::new(
next.leg_fr.position = Vec3::new(
skeleton_attr.feet_f.0,
skeleton_attr.feet_f.1 + footvertt * 3.0 * skeleton_attr.minimize,
skeleton_attr.feet_f.2 + ((footvert * -1.5).max(-1.0)),
);
next.leg_fr.ori = Quaternion::rotation_x(0.2 + skeleton_attr.maximize * footvertt * 0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fr.orientation =
Quaternion::rotation_x(0.2 + skeleton_attr.maximize * footvertt * 0.65)
* Quaternion::rotation_z(tilt * -0.5)
* Quaternion::rotation_y(tilt * 1.5);
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.offset = Vec3::new(
next.leg_bl.position = Vec3::new(
-skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + footvertt * -1.4,
skeleton_attr.feet_b.2 + ((footvert * 1.5).max(-1.0)),
);
next.leg_bl.ori = Quaternion::rotation_x(-0.25 + skeleton_attr.maximize * footvertt * -0.8)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.orientation =
Quaternion::rotation_x(-0.25 + skeleton_attr.maximize * footvertt * -0.8)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_bl.scale = Vec3::one() * 1.02;
next.leg_br.offset = Vec3::new(
next.leg_br.position = Vec3::new(
skeleton_attr.feet_b.0,
skeleton_attr.feet_b.1 + footverttf * -1.4,
skeleton_attr.feet_b.2 + ((footvertf * 1.5).max(-1.0)),
);
next.leg_br.ori =
next.leg_br.orientation =
Quaternion::rotation_x(-0.25 + skeleton_attr.maximize * footverttf * -0.8)
* Quaternion::rotation_y(tilt * 1.5)
* Quaternion::rotation_z(tilt * -1.5);
next.leg_br.scale = Vec3::one() * 1.02;
next.tail.offset = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.ori = Quaternion::rotation_x(short * 0.2 + x_tilt)
next.tail.position = Vec3::new(0.0, skeleton_attr.tail.0, skeleton_attr.tail.1);
next.tail.orientation = Quaternion::rotation_x(short * 0.2 + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(tilt * 1.5);
next.tail.scale = Vec3::one();

View File

@ -0,0 +1,18 @@
pub use ::vek::{
bezier::repr_simd::*, geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*,
quaternion::repr_simd::*, transform::repr_simd::*, transition::*, vec::repr_simd::*,
};
/* pub use ::vek::{
bezier::repr_c::*, geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*,
quaternion::repr_c::*, transform::repr_c::*, transition::*, vec::repr_c::*,
}; */
/* pub use vek::{
bezier::repr_c::*,
geom::repr_c::*,
mat::repr_simd::column_major::Mat4,
ops::*,
quaternion::repr_simd::*,
transform::repr_c::*,
transition::*,
vec::repr_simd::*,
}; */

View File

@ -134,7 +134,7 @@ impl<'a> Widget for Map<'a> {
.set(state.ids.icon, ui);
// Map Title
Text::new(&self.localized_strings.get("hud.map.map_title"))
Text::new(self.localized_strings.get("hud.map.map_title"))
.mid_top_with_margin_on(state.ids.frame, 3.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(29))
@ -142,15 +142,12 @@ impl<'a> Widget for Map<'a> {
.set(state.ids.map_title, ui);
// Questlog Title
Text::new(&format!(
"{}",
&self.localized_strings.get("hud.map.qlog_title")
))
.mid_top_with_margin_on(state.ids.qlog_align, 6.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(21))
.color(TEXT_COLOR)
.set(state.ids.qlog_title, ui);
Text::new(self.localized_strings.get("hud.map.qlog_title"))
.mid_top_with_margin_on(state.ids.qlog_align, 6.0)
.font_id(self.fonts.cyri.conrod_id)
.font_size(self.fonts.cyri.scale(21))
.color(TEXT_COLOR)
.set(state.ids.qlog_title, ui);
// X-Button
if Button::image(self.imgs.close_button)

View File

@ -749,7 +749,7 @@ impl Hud {
}
// Max amount the sct font size increases when "flashing"
const FLASH_MAX: f32 = 25.0;
const FLASH_MAX: u32 = 2;
// Get player position.
let player_pos = client
@ -793,9 +793,9 @@ impl Hud {
// Increase font size based on fraction of maximum health
// "flashes" by having a larger size in the first 100ms
let font_size = 30
+ (max_hp_frac * 30.0) as u32
+ ((max_hp_frac * 10.0) as u32) * 3
+ if timer < 0.1 {
(FLASH_MAX * (1.0 - timer / 0.1)) as u32
FLASH_MAX * (((1.0 - timer / 0.1) * 10.0) as u32)
} else {
0
};
@ -846,9 +846,9 @@ impl Hud {
// Increase font size based on fraction of maximum health
// "flashes" by having a larger size in the first 100ms
let font_size = 30
+ (max_hp_frac * 30.0) as u32
+ ((max_hp_frac * 10.0) as u32) * 3
+ if floater.timer < 0.1 {
(FLASH_MAX * (1.0 - floater.timer / 0.1)) as u32
FLASH_MAX * (((1.0 - floater.timer / 0.1) * 10.0) as u32)
} else {
0
};
@ -928,7 +928,7 @@ impl Hud {
+ ((exp_change.abs() as f32 / stats.exp.maximum() as f32).min(1.0)
* 50.0) as u32
+ if timer < 0.1 {
(FLASH_MAX * (1.0 - timer / 0.1)) as u32
FLASH_MAX * (((1.0 - timer / 0.1) * 10.0) as u32)
} else {
0
};
@ -972,7 +972,7 @@ impl Hud {
.min(1.0)
* 50.0) as u32
+ if floater.timer < 0.1 {
(FLASH_MAX * (1.0 - floater.timer / 0.1)) as u32
FLASH_MAX * (((1.0 - floater.timer / 0.1) * 10.0) as u32)
} else {
0
};
@ -1162,9 +1162,9 @@ impl Hud {
// Increase font size based on fraction of maximum health
// "flashes" by having a larger size in the first 100ms
let font_size = 30
+ (max_hp_frac * 30.0) as u32
+ ((max_hp_frac * 10.0) as u32) * 3
+ if timer < 0.1 {
(FLASH_MAX * (1.0 - timer / 0.1)) as u32
FLASH_MAX * (((1.0 - timer / 0.1) * 10.0) as u32)
} else {
0
};
@ -1207,9 +1207,9 @@ impl Hud {
// Increase font size based on fraction of maximum health
// "flashes" by having a larger size in the first 100ms
let font_size = 30
+ (max_hp_frac * 30.0) as u32
+ ((max_hp_frac * 10.0) as u32) * 3
+ if floater.timer < 0.1 {
(FLASH_MAX * (1.0 - floater.timer / 0.1)) as u32
FLASH_MAX * (((1.0 - floater.timer / 0.1) * 10.0) as u32)
} else {
0
};
@ -2365,6 +2365,11 @@ impl Hud {
.handle_event(conrod_core::event::Input::Text("\t".to_string()));
}
if !self.show.ui {
// Optimization: skip maintaining UI when it's off.
return vec![];
}
if let Some(maybe_id) = self.to_focus.take() {
self.ui.focus_widget(maybe_id);
}
@ -2373,14 +2378,15 @@ impl Hud {
view_mat, proj_mat, ..
} = camera.dependents();
let focus_off = camera.get_focus_pos().map(f32::trunc);
// Check if item images need to be reloaded
self.item_imgs.reload_if_changed(&mut self.ui);
self.ui.maintain(
&mut global_state.window.renderer_mut(),
Some(proj_mat * view_mat * Mat4::translation_3d(-focus_off)),
);
// Check if item images need to be reloaded
self.item_imgs.reload_if_changed(&mut self.ui);
events
}

View File

@ -105,12 +105,14 @@ impl<'a> Ingameable for Overhead<'a> {
// this could be done automatically?
// - 2 Text::new for name
// - 1 for level: either Text or Image
// - 4 for HP + mana + fg + bg
// - 3 for HP + fg + bg
// If there's a speech bubble
// - 2 Text::new for speech bubble
// - 1 Image::new for icon
// - 10 Image::new for speech bubble (9-slice + tail)
7 + if self.bubble.is_some() { 13 } else { 0 }
// If there's mana
// - 1 Rect::new for man
6 + if self.bubble.is_some() { 13 } else { 0 } + if self.energy.is_some() { 1 } else { 0 }
}
}
@ -263,10 +265,11 @@ impl<'a> Widget for Overhead<'a> {
.mid_bottom_with_margin_on(state.ids.speech_bubble_text, -32.0);
if dark_mode {
tail.w_h(22.0, 13.0).set(state.ids.speech_bubble_tail, ui)
tail.w_h(22.0, 13.0)
} else {
tail.w_h(22.0, 28.0).set(state.ids.speech_bubble_tail, ui)
};
tail.w_h(22.0, 28.0)
}
.set(state.ids.speech_bubble_tail, ui);
let mut text_shadow = Text::new(&bubble_contents)
.color(shadow_color)
@ -292,6 +295,8 @@ impl<'a> Widget for Overhead<'a> {
Image::new(icon)
.w_h(16.0, 16.0)
.top_left_with_margin_on(state.ids.speech_bubble_text, -16.0)
// TODO: Figure out whether this should be parented.
// .parent(id)
.set(state.ids.speech_bubble_icon, ui);
}

View File

@ -17,7 +17,7 @@ widget_ids! {
#[derive(WidgetCommon)]
pub struct Overitem<'a> {
name: &'a str,
distance: &'a f32,
_distance: &'a f32,
fonts: &'a ConrodVoxygenFonts,
#[conrod(common_builder)]
common: widget::CommonBuilder,
@ -27,7 +27,7 @@ impl<'a> Overitem<'a> {
pub fn new(name: &'a str, distance: &'a f32, fonts: &'a ConrodVoxygenFonts) -> Self {
Self {
name,
distance,
_distance: distance,
fonts,
common: widget::CommonBuilder::default(),
}
@ -63,8 +63,8 @@ impl<'a> Widget for Overitem<'a> {
fn update(self, args: widget::UpdateArgs<Self>) -> Self::Event {
let widget::UpdateArgs { state, ui, .. } = args;
let font_size =
((1.0 - (self.distance / common::comp::MAX_PICKUP_RANGE_SQR)) * 30.0) as u32;
let font_size = 30;
// ((1.0 - (self.distance / common::comp::MAX_PICKUP_RANGE_SQR)) * 30.0) as u32;
// ItemName
Text::new(&self.name)

View File

@ -21,7 +21,7 @@ where
impl<P: Pipeline> Mesh<P> {
/// Create a new `Mesh`.
#[allow(clippy::new_without_default)] // TODO: Pending review in #587
pub fn new() -> Self { Self { verts: vec![] } }
pub fn new() -> Self { Self { verts: Vec::new() } }
/// Clear vertices, allows reusing allocated memory of the underlying Vec.
pub fn clear(&mut self) { self.verts.clear(); }

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@ use crate::{
use anim::{
character::{CharacterSkeleton, IdleAnimation, SkeletonAttr},
fixture::FixtureSkeleton,
Animation, Skeleton,
Animation,
};
use common::{
comp::{humanoid, item::ItemKind, Body, Loadout},
@ -146,10 +146,10 @@ impl Scene {
map_bounds,//: client.world_map.2,
figure_model_cache: FigureModelCache::new(),
figure_state: FigureState::new(renderer, CharacterSkeleton::new()),
figure_state: FigureState::new(renderer, CharacterSkeleton::default()),
backdrop: backdrop.map(|specifier| {
let mut state = FigureState::new(renderer, FixtureSkeleton::new());
let mut state = FigureState::new(renderer, FixtureSkeleton::default());
let mut greedy = FigureModel::make_greedy();
let mesh = load_mesh(
specifier,
@ -157,6 +157,7 @@ impl Scene {
|segment, offset| generate_mesh(&mut greedy, segment, offset),
);
let model = col_lights.create_figure(renderer, greedy, mesh).unwrap();
let mut buf = [Default::default(); anim::MAX_BONE_COUNT];
state.update(
renderer,
anim::vek::Vec3::zero(),
@ -170,6 +171,7 @@ impl Scene {
true,
false,
&camera,
&mut buf,
);
(
model,
@ -292,9 +294,9 @@ impl Scene {
&mut 0.0,
&SkeletonAttr::from(&body),
);
self.figure_state
.skeleton_mut()
.interpolate(&tgt_skeleton, scene_data.delta_time);
let dt_lerp = (scene_data.delta_time * 15.0).min(1.0);
*self.figure_state.skeleton_mut() =
anim::vek::Lerp::lerp(&*self.figure_state.skeleton_mut(), &tgt_skeleton, dt_lerp);
let model = &self
.figure_model_cache
@ -308,6 +310,7 @@ impl Scene {
None,
)
.0;
let mut buf = [Default::default(); anim::MAX_BONE_COUNT];
self.figure_state.update(
renderer,
anim::vek::Vec3::zero(),
@ -321,6 +324,7 @@ impl Scene {
true,
false,
&self.camera,
&mut buf,
);
}
}

View File

@ -1,18 +1,23 @@
use super::graphic::{Graphic, GraphicCache, Id as GraphicId};
use crate::{
render::{Renderer, Texture},
render::{Mesh, Renderer, Texture, UiPipeline},
Error,
};
use conrod_core::text::GlyphCache;
use conrod_core::{text::GlyphCache, widget::Id};
use hashbrown::HashMap;
use vek::*;
// Multiplied by current window size
const GLYPH_CACHE_SIZE: u16 = 1;
// Glyph cache tolerances
const SCALE_TOLERANCE: f32 = 0.1;
const POSITION_TOLERANCE: f32 = 0.1;
const SCALE_TOLERANCE: f32 = 0.5;
const POSITION_TOLERANCE: f32 = 0.5;
type TextCache = HashMap<Id, Mesh<UiPipeline>>;
pub struct Cache {
// Map from text ids to their positioned glyphs.
text_cache: TextCache,
glyph_cache: GlyphCache<'static>,
glyph_cache_tex: Texture,
graphic_cache: GraphicCache,
@ -29,6 +34,7 @@ impl Cache {
Vec2::new(w, h).map(|e| (e * GLYPH_CACHE_SIZE).min(max_texture_size).max(512));
Ok(Self {
text_cache: Default::default(),
glyph_cache: GlyphCache::builder()
.dimensions(glyph_cache_dims.x as u32, glyph_cache_dims.y as u32)
.scale_tolerance(SCALE_TOLERANCE)
@ -41,14 +47,24 @@ impl Cache {
pub fn glyph_cache_tex(&self) -> &Texture { &self.glyph_cache_tex }
pub fn glyph_cache_mut_and_tex(&mut self) -> (&mut GlyphCache<'static>, &Texture) {
(&mut self.glyph_cache, &self.glyph_cache_tex)
pub fn cache_mut_and_tex(
&mut self,
) -> (
&mut GraphicCache,
&mut TextCache,
&mut GlyphCache<'static>,
&Texture,
) {
(
&mut self.graphic_cache,
&mut self.text_cache,
&mut self.glyph_cache,
&self.glyph_cache_tex,
)
}
pub fn graphic_cache(&self) -> &GraphicCache { &self.graphic_cache }
pub fn graphic_cache_mut(&mut self) -> &mut GraphicCache { &mut self.graphic_cache }
pub fn add_graphic(&mut self, graphic: Graphic) -> GraphicId {
self.graphic_cache.add_graphic(graphic)
}
@ -57,13 +73,13 @@ impl Cache {
self.graphic_cache.replace_graphic(id, graphic)
}
// Resizes and clears the GraphicCache
pub fn resize_graphic_cache(&mut self, renderer: &mut Renderer) {
/// Resizes and clears the various caches.
///
/// To be called when something like the scaling factor changes,
/// invalidating all existing cached UI state.
pub fn resize(&mut self, renderer: &mut Renderer) -> Result<(), Error> {
self.graphic_cache.clear_cache(renderer);
}
// Resizes and clears the GlyphCache
pub fn resize_glyph_cache(&mut self, renderer: &mut Renderer) -> Result<(), Error> {
self.text_cache.clear();
let max_texture_size = renderer.max_texture_size();
let cache_dims = renderer
.get_resolution()

View File

@ -35,15 +35,16 @@ use cache::Cache;
use common::{assets, util::srgba_to_linear};
use conrod_core::{
event::Input,
graph::Graph,
graph::{self, Graph},
image::{self, Map},
input::{touch::Touch, Motion, Widget},
render::{Primitive, PrimitiveKind},
text::{self, font},
widget::{self, id::Generator},
Rect, UiBuilder, UiCell,
Rect, Scalar, UiBuilder, UiCell,
};
use graphic::{Rotation, TexId};
use hashbrown::hash_map::Entry;
use std::{
f32, f64,
fs::File,
@ -103,6 +104,9 @@ pub struct Ui {
cache: Cache,
// Draw commands for the next render
draw_commands: Vec<DrawCommand>,
// Mesh buffer for UI vertics; we reuse its allocation in order to limit vector reallocations
// during redrawing.
mesh: Mesh<UiPipeline>,
// Model for drawing the ui
model: DynamicModel<UiPipeline>,
// Consts for default ui drawing position (ie the interface)
@ -128,6 +132,10 @@ impl Ui {
let renderer = window.renderer_mut();
let mut ui = UiBuilder::new(win_dims).build();
// NOTE: Since we redraw the actual frame each time whether or not the UI needs
// to be updated, there's no reason to set the redraw count higher than
// 1.
ui.set_num_redraw_frames(1);
let tooltip_manager = TooltipManager::new(
ui.widget_id_generator(),
Duration::from_millis(1),
@ -140,6 +148,7 @@ impl Ui {
image_map: Map::new(),
cache: Cache::new(renderer)?,
draw_commands: Vec::new(),
mesh: Mesh::new(),
model: renderer.create_dynamic_model(100)?,
interface_locals: renderer.create_consts(&[UiLocals::default()])?,
default_globals: renderer.create_consts(&[Globals::default()])?,
@ -274,23 +283,55 @@ impl Ui {
self.tooltip_manager
.maintain(self.ui.global_input(), self.scale.scale_factor_logical());
// Regenerate draw commands and associated models only if the ui changed
let mut primitives = match self.ui.draw_if_changed() {
Some(primitives) => primitives,
None => return,
};
// Handle window resizing.
if let Some(new_dims) = self.window_resized.take() {
let (old_w, old_h) = self.scale.scaled_window_size().into_tuple();
self.scale.window_resized(new_dims, renderer);
let (w, h) = self.scale.scaled_window_size().into_tuple();
self.ui.handle_event(Input::Resize(w, h));
// Avoid panic in graphic cache when minimizing.
// Avoid resetting cache if window size didn't change
// Somewhat inefficient for elements that won't change size after a window
// resize
let res = renderer.get_resolution();
self.need_cache_resize = res.x > 0 && res.y > 0 && !(old_w == w && old_h == h);
}
if self.need_cache_resize {
// Resize graphic cache
self.cache.resize_graphic_cache(renderer);
// Resize glyph cache
self.cache.resize_glyph_cache(renderer).unwrap();
// FIXME: Handle errors here.
self.cache.resize(renderer).unwrap();
self.need_cache_resize = false;
}
self.draw_commands.clear();
let mut mesh = Mesh::new();
let mut retry = false;
self.maintain_internal(renderer, view_projection_mat, &mut retry);
if retry {
// Update the glyph cache and try again.
self.maintain_internal(renderer, view_projection_mat, &mut retry);
}
}
fn maintain_internal(
&mut self,
renderer: &mut Renderer,
view_projection_mat: Option<Mat4<f32>>,
retry: &mut bool,
) {
let (graphic_cache, text_cache, glyph_cache, cache_tex) = self.cache.cache_mut_and_tex();
let mut primitives = if *retry {
// If this is a retry, always redraw.
self.ui.draw()
} else {
// Otherwise, redraw only if widgets were actually updated.
match self.ui.draw_if_changed() {
Some(primitives) => primitives,
None => return,
}
};
let (half_res, x_align, y_align) = {
let res = renderer.get_resolution();
@ -301,6 +342,215 @@ impl Ui {
)
};
let ui = &self.ui;
let p_scale_factor = self.scale.scale_factor_physical();
// Functions for converting for conrod scalar coords to GL vertex coords (-1.0
// to 1.0).
let (ui_win_w, ui_win_h) = (ui.win_w, ui.win_h);
let vx = |x: f64| (x / ui_win_w * 2.0) as f32;
let vy = |y: f64| (y / ui_win_h * 2.0) as f32;
let gl_aabr = |rect: Rect| {
let (l, r, b, t) = rect.l_r_b_t();
let min = Vec2::new(
((vx(l) * half_res.x + x_align).round() - x_align) / half_res.x,
((vy(b) * half_res.y + y_align).round() - y_align) / half_res.y,
);
let max = Vec2::new(
((vx(r) * half_res.x + x_align).round() - x_align) / half_res.x,
((vy(t) * half_res.y + y_align).round() - y_align) / half_res.y,
);
Aabr { min, max }
};
// let window_dim = ui.window_dim();
let theme = &ui.theme;
let widget_graph = ui.widget_graph();
let fonts = &ui.fonts;
let dpi_factor = p_scale_factor as f32;
// We can use information about whether a widget was actually updated to more
// easily track cache invalidations.
let updated_widgets = ui.updated_widgets();
let mut glyph_missing = false;
updated_widgets.iter()
// Filter out widgets that are either:
// - not text primitives, or
// - are text primitives, but were both already in the cache, and not updated this
// frame.
//
// The reason the second condition is so complicated is that we want to handle cases
// where we cleared the whole cache, which can result in glyphs from text updated in a
// previous frame not being present in the text cache.
.filter_map(|(&widget_id, updated)| {
widget_graph.widget(widget_id)
.and_then(|widget| Some((widget.rect, widget.unique_widget_state::<widget::Text>()?)))
.and_then(|(rect, text)| {
// NOTE: This fallback is weird and probably shouldn't exist.
let font_id = text.style.font_id(theme)/*.or_else(|| fonts.ids().next())*/?;
let font = fonts.get(font_id)?;
Some((widget_id, updated, rect, text, font_id, font))
})
})
// Recache the entry.
.for_each(|(widget_id, updated, rect, graph::UniqueWidgetState { state, style }, font_id, font)| {
let entry = match text_cache.entry(widget_id) {
Entry::Occupied(_) if !updated => return,
entry => entry,
};
// Retrieve styling.
let color = style.color(theme);
let font_size = style.font_size(theme);
let line_spacing = style.line_spacing(theme);
let justify = style.justify(theme);
let y_align = conrod_core::position::Align::End;
let text = &state.string;
let line_infos = &state.line_infos;
// Convert conrod coordinates to pixel coordinates.
let trans_x = |x: Scalar| (x + ui_win_w / 2.0) * dpi_factor as Scalar;
let trans_y = |y: Scalar| ((-y) + ui_win_h / 2.0) * dpi_factor as Scalar;
// Produce the text layout iterators.
let lines = line_infos.iter().map(|info| &text[info.byte_range()]);
let line_rects = text::line::rects(line_infos.iter(), font_size, rect,
justify, y_align, line_spacing);
// Grab the positioned glyphs from the text primitives.
let scale = text::f32_pt_to_scale(font_size as f32 * dpi_factor);
let positioned_glyphs = lines.zip(line_rects).flat_map(|(line, line_rect)| {
let (x, y) = (trans_x(line_rect.left()) as f32, trans_y(line_rect.bottom()) as f32);
let point = text::rt::Point { x, y };
font.layout(line, scale, point)
});
// Reuse the mesh allocation if possible at this entry if possible; we
// then clear it to avoid using stale entries.
let mesh = entry.or_insert_with(Mesh::new);
mesh.clear();
let color = srgba_to_linear(color.to_fsa().into());
positioned_glyphs.for_each(|g| {
match glyph_cache.rect_for(font_id.index(), &g) {
Ok(Some((uv_rect, screen_rect))) => {
let uv = Aabr {
min: Vec2::new(uv_rect.min.x, uv_rect.max.y),
max: Vec2::new(uv_rect.max.x, uv_rect.min.y),
};
let rect = Aabr {
min: Vec2::new(
vx(screen_rect.min.x as f64 / p_scale_factor
- ui.win_w / 2.0),
vy(ui.win_h / 2.0
- screen_rect.max.y as f64 / p_scale_factor),
),
max: Vec2::new(
vx(screen_rect.max.x as f64 / p_scale_factor
- ui.win_w / 2.0),
vy(ui.win_h / 2.0
- screen_rect.min.y as f64 / p_scale_factor),
),
};
mesh.push_quad(create_ui_quad(rect, uv, color, UiMode::Text));
},
// Glyph not found, no-op.
Ok(None) => {},
// Glyph was found, but was not yet cached; we'll need to add it to the
// cache and retry.
Err(_) => {
// Queue the unknown glyph to be cached.
glyph_missing = true;
}
}
// NOTE: Important to do this for *all* glyphs to try to make sure that
// any that are uncached are part of the graph. Because we always
// clear the entire cache whenever a new glyph is encountered, by
// adding and checking all glyphs as they come in we guarantee that (1)
// any glyphs in the text cache are in the queue, and (2) any glyphs
// not in the text cache are either in the glyph cache, or (during our
// processing here) we set the retry flag to force a glyph cache
// update. Setting the flag causes all glyphs in the current queue to
// become part of the glyph cache during the second call to
// `maintain_internal`, so as long as the cache refresh succeeded,
// during the second call all glyphs will hit this branch as desired.
glyph_cache.queue_glyph(font_id.index(), g);
});
});
if glyph_missing {
if *retry {
// If a glyph was missing and this was our second try, we know something was
// messed up during the glyph_cache redraw. It is possible that
// the queue contained unneeded glyphs, so we don't necessarily
// have to give up; a more precise enumeration of the
// glyphs required to render this frame might work out. However, this is a
// pretty remote edge case, so we opt to not care about this
// frame (we skip rendering it, basically), and just clear the
// text cache and glyph queue; next frame will then
// start out with an empty slate, and therefore will enqueue precisely the
// glyphs needed for that frame. If *that* frame fails, we're
// in bigger trouble.
text_cache.clear();
glyph_cache.clear();
glyph_cache.clear_queue();
self.ui.needs_redraw();
warn!("Could not recache queued glyphs, skipping frame.");
} else {
// NOTE: If this is the first round after encountering a new glyph, we just
// refresh the whole glyph cache. Technically this is not necessary since
// positioned_glyphs should still be accurate, but it's just the easiest way
// to ensure that all glyph positions get updated. It also helps keep the glyph
// cache reasonable by making sure any glyphs that subsequently get rendered are
// actually in the cache, including glyphs that were mapped to ids but didn't
// happen to be rendered on the frame where the cache was
// refreshed.
text_cache.clear();
tracing::debug!("Updating glyphs and clearing text cache.");
if let Err(err) = glyph_cache.cache_queued(|rect, data| {
let offset = [rect.min.x as u16, rect.min.y as u16];
let size = [rect.width() as u16, rect.height() as u16];
let new_data = data
.iter()
.map(|x| [255, 255, 255, *x])
.collect::<Vec<[u8; 4]>>();
if let Err(err) = renderer.update_texture(cache_tex, offset, size, &new_data) {
warn!("Failed to update texture: {:?}", err);
}
}) {
// FIXME: If we actually hit this error, it's still possible we could salvage
// things in various ways (for instance, the current queue might have extra
// stuff in it, so we could try calling maintain_internal a
// third time with a fully clean queue; or we could try to
// increase the glyph texture size, etc. But hopefully
// we will not actually encounter this error.
warn!("Failed to cache queued glyphs: {:?}", err);
// Clear queued glyphs, so that (hopefully) next time we won't have the
// offending glyph or glyph set. We then exit the loop and don't try to
// rerender the frame.
glyph_cache.clear_queue();
self.ui.needs_redraw();
} else {
// Successfully cached, so repeat the loop.
*retry = true;
}
}
return;
}
self.draw_commands.clear();
let mesh = &mut self.mesh;
mesh.clear();
enum State {
Image(TexId),
Plain,
@ -321,7 +571,6 @@ impl Ui {
};
let mut placement = Placement::Interface;
let p_scale_factor = self.scale.scale_factor_physical();
// Switches to the `Plain` state and completes the previous `Command` if not
// already in the `Plain` state.
@ -341,9 +590,8 @@ impl Ui {
kind,
scizzor,
rect,
..
id: widget_id,
} = prim;
// Check for a change in the scissor.
let new_scissor = {
let (l, b, w, h) = scizzor.l_b_w_h();
@ -351,8 +599,8 @@ impl Ui {
// Calculate minimum x and y coordinates while
// flipping y axis (from +up to +down) and
// moving origin to top-left corner (from middle).
let min_x = self.ui.win_w / 2.0 + l;
let min_y = self.ui.win_h / 2.0 - b - h;
let min_x = ui.win_w / 2.0 + l;
let min_y = ui.win_h / 2.0 - b - h;
let intersection = Aabr {
min: Vec2 {
x: (min_x * scale_factor) as u16,
@ -415,24 +663,6 @@ impl Ui {
Placement::Interface => {},
}
// Functions for converting for conrod scalar coords to GL vertex coords (-1.0
// to 1.0).
let (ui_win_w, ui_win_h) = (self.ui.win_w, self.ui.win_h);
let vx = |x: f64| (x / ui_win_w * 2.0) as f32;
let vy = |y: f64| (y / ui_win_h * 2.0) as f32;
let gl_aabr = |rect: Rect| {
let (l, r, b, t) = rect.l_r_b_t();
let min = Vec2::new(
((vx(l) * half_res.x + x_align).round() - x_align) / half_res.x,
((vy(b) * half_res.y + y_align).round() - y_align) / half_res.y,
);
let max = Vec2::new(
((vx(r) * half_res.x + x_align).round() - x_align) / half_res.x,
((vy(t) * half_res.y + y_align).round() - y_align) / half_res.y,
);
Aabr { min, max }
};
match kind {
PrimitiveKind::Image {
image_id,
@ -443,7 +673,6 @@ impl Ui {
.image_map
.get(&image_id)
.expect("Image does not exist in image map");
let graphic_cache = self.cache.graphic_cache_mut();
let gl_aabr = gl_aabr(rect);
let (source_aabr, gl_size) = {
// Transform the source rectangle into uv coordinate.
@ -573,67 +802,16 @@ impl Ui {
Rotation::TargetNorth => UiMode::ImageTargetNorth,
}));
},
PrimitiveKind::Text {
color,
text,
font_id,
} => {
PrimitiveKind::Text { .. } => {
switch_to_plain_state!();
let positioned_glyphs = text.positioned_glyphs(p_scale_factor as f32);
let (glyph_cache, cache_tex) = self.cache.glyph_cache_mut_and_tex();
// Queue the glyphs to be cached.
for glyph in positioned_glyphs {
glyph_cache.queue_glyph(font_id.index(), glyph.clone());
}
if let Err(err) = glyph_cache.cache_queued(|rect, data| {
let offset = [rect.min.x as u16, rect.min.y as u16];
let size = [rect.width() as u16, rect.height() as u16];
let new_data = data
.iter()
.map(|x| [255, 255, 255, *x])
.collect::<Vec<[u8; 4]>>();
if let Err(err) =
renderer.update_texture(cache_tex, offset, size, &new_data)
{
warn!("Failed to update texture: {:?}", err);
}
}) {
warn!("Failed to cache queued glyphs: {:?}", err);
// Clear uncachable glyphs from the queue
glyph_cache.clear_queue();
}
let color = srgba_to_linear(color.to_fsa().into());
for g in positioned_glyphs {
if let Ok(Some((uv_rect, screen_rect))) =
glyph_cache.rect_for(font_id.index(), g)
{
let uv = Aabr {
min: Vec2::new(uv_rect.min.x, uv_rect.max.y),
max: Vec2::new(uv_rect.max.x, uv_rect.min.y),
};
let rect = Aabr {
min: Vec2::new(
vx(screen_rect.min.x as f64 / p_scale_factor
- self.ui.win_w / 2.0),
vy(self.ui.win_h / 2.0
- screen_rect.max.y as f64 / p_scale_factor),
),
max: Vec2::new(
vx(screen_rect.max.x as f64 / p_scale_factor
- self.ui.win_w / 2.0),
vy(self.ui.win_h / 2.0
- screen_rect.min.y as f64 / p_scale_factor),
),
};
mesh.push_quad(create_ui_quad(rect, uv, color, UiMode::Text));
}
}
// Mesh should already be cached.
mesh.push_mesh(
text_cache
.get(&widget_id)
.as_deref()
.unwrap_or(&Mesh::new()),
);
},
PrimitiveKind::Rectangle { color } => {
let color = srgba_to_linear(color.to_fsa().into());
@ -675,13 +853,6 @@ impl Ui {
} else {
[p2.into_array(), p1.into_array(), p3.into_array()]
};
/* // If triangle is counter-clockwise, reverse it.
let (v1, v2): (Vec3<f32>, Vec3<f32>) = ((p2 - p1).into(), (p3 - p1).into());
let triangle = if v1.cross(v2).z > 0.0 {
[p2.into_array(), p1.into_array(), p3.into_array()]
} else {
[p1.into_array(), p2.into_array(), p3.into_array()]
}; */
mesh.push_tri(create_ui_tri(
triangle,
[[0.0; 2]; 3],
@ -762,8 +933,8 @@ impl Ui {
State::Image(id) => DrawCommand::image(start..mesh.vertices().len(), id),
});
// Draw glyph cache (use for debugging).
/*self.draw_commands
/* // Draw glyph cache (use for debugging).
self.draw_commands
.push(DrawCommand::Scissor(default_scissor(renderer)));
start = mesh.vertices().len();
mesh.push_quad(create_ui_quad(
@ -779,32 +950,17 @@ impl Ui {
UiMode::Text,
));
self.draw_commands
.push(DrawCommand::plain(start..mesh.vertices().len()));*/
.push(DrawCommand::plain(start..mesh.vertices().len())); */
// Create a larger dynamic model if the mesh is larger than the current model
// size.
if self.model.vbuf.len() < mesh.vertices().len() {
if self.model.vbuf.len() < self.mesh.vertices().len() {
self.model = renderer
.create_dynamic_model(mesh.vertices().len() * 4 / 3)
.create_dynamic_model(self.mesh.vertices().len() * 4 / 3)
.unwrap();
}
// Update model with new mesh.
renderer.update_model(&self.model, &mesh, 0).unwrap();
// Handle window resizing.
if let Some(new_dims) = self.window_resized.take() {
let (old_w, old_h) = self.scale.scaled_window_size().into_tuple();
self.scale.window_resized(new_dims, renderer);
let (w, h) = self.scale.scaled_window_size().into_tuple();
self.ui.handle_event(Input::Resize(w, h));
// Avoid panic in graphic cache when minimizing.
// Avoid resetting cache if window size didn't change
// Somewhat inefficient for elements that won't change size after a window
// resize
let res = renderer.get_resolution();
self.need_cache_resize = res.x > 0 && res.y > 0 && !(old_w == w && old_h == h);
}
renderer.update_model(&self.model, &self.mesh, 0).unwrap();
}
pub fn render(&self, renderer: &mut Renderer, maybe_globals: Option<&Consts<Globals>>) {

View File

@ -54,7 +54,7 @@ pub struct IngameParameters {
}
pub struct State {
id: Option<widget::Id>,
id: widget::Id,
pub parameters: IngameParameters,
}
@ -78,7 +78,7 @@ impl<W: Ingameable> Widget for Ingame<W> {
fn init_state(&self, mut id_gen: widget::id::Generator) -> Self::State {
State {
id: Some(id_gen.next()),
id: id_gen.next(),
parameters: IngameParameters {
num: self.prim_num,
pos: self.pos,
@ -112,7 +112,7 @@ impl<W: Ingameable> Widget for Ingame<W> {
});
}
widget.set_ingame(state.id.unwrap(), ui)
widget.set_ingame(state.id, ui)
}
fn default_x_position(&self, _: &Ui) -> Position { Position::Absolute(0.0) }

View File

@ -11,7 +11,7 @@ bitvec = "0.17.4"
fxhash = "0.2.1"
image = { version = "0.23.8", default-features = false, features = ["png"] }
itertools = "0.9"
vek = { version = "0.11.0", features = ["serde"] }
vek = { version = "0.11.2", features = ["repr_simd", "serde"] }
noise = { version = "0.6.0", default-features = false }
num = "0.2"
ordered-float = "1.0"