diff --git a/Cargo.lock b/Cargo.lock index fe66c04fe0..d5ee304651 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/Cargo.toml b/Cargo.toml index e73d2cd0a8..3aea1da646 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } diff --git a/assets/voxygen/shaders/include/lod.glsl b/assets/voxygen/shaders/include/lod.glsl index 8c294365d2..2cb34b406c 100644 --- a/assets/voxygen/shaders/include/lod.glsl +++ b/assets/voxygen/shaders/include/lod.glsl @@ -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. diff --git a/assets/voxygen/shaders/include/sky.glsl b/assets/voxygen/shaders/include/sky.glsl index 55ab5945d5..babb39ab66 100644 --- a/assets/voxygen/shaders/include/sky.glsl +++ b/assets/voxygen/shaders/include/sky.glsl @@ -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); diff --git a/assets/voxygen/shaders/lod-terrain-frag.glsl b/assets/voxygen/shaders/lod-terrain-frag.glsl index 46c45c9cb2..8ae0f0ab2c 100644 --- a/assets/voxygen/shaders/lod-terrain-frag.glsl +++ b/assets/voxygen/shaders/lod-terrain-frag.glsl @@ -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; diff --git a/client/Cargo.toml b/client/Cargo.toml index 8be7a09c8f..3465fc28cb 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -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" } diff --git a/common/Cargo.toml b/common/Cargo.toml index 150436336f..ba086185cd 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -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"] } diff --git a/common/src/comp/body/humanoid.rs b/common/src/comp/body/humanoid.rs index 3785be2dbb..189e1e613e 100644 --- a/common/src/comp/body/humanoid.rs +++ b/common/src/comp/body/humanoid.rs @@ -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), diff --git a/server/Cargo.toml b/server/Cargo.toml index 49f59da6de..32daf3cbab 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -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" diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index fb8606e37a..f2ea1ddc63 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -95,7 +95,7 @@ pub fn handle_create_waypoint(server: &mut Server, pos: Vec3) { .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, }) diff --git a/voxygen/Cargo.toml b/voxygen/Cargo.toml index 0fd543a2a3..5f7f7bb21a 100644 --- a/voxygen/Cargo.toml +++ b/voxygen/Cargo.toml @@ -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 diff --git a/voxygen/src/anim/Cargo.toml b/voxygen/src/anim/Cargo.toml index ab4d0e2bfe..8947cd20f5 100644 --- a/voxygen/src/anim/Cargo.toml +++ b/voxygen/src/anim/Cargo.toml @@ -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 } diff --git a/voxygen/src/anim/src/biped_large/idle.rs b/voxygen/src/anim/src/biped_large/idle.rs index 4caa2d07c9..d8cf301761 100644 --- a/voxygen/src/anim/src/biped_large/idle.rs +++ b/voxygen/src/anim/src/biped_large/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/biped_large/jump.rs b/voxygen/src/anim/src/biped_large/jump.rs index 4883686028..d0a5b1f080 100644 --- a/voxygen/src/anim/src/biped_large/jump.rs +++ b/voxygen/src/anim/src/biped_large/jump.rs @@ -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 } diff --git a/voxygen/src/anim/src/biped_large/mod.rs b/voxygen/src/anim/src/biped_large/mod.rs index 9262474e90..9aaf949bff 100644 --- a/voxygen/src/anim/src/biped_large/mod.rs +++ b/voxygen/src/anim/src/biped_large/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let upper_torso = Mat4::::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::::from(self.torso); + let control_mat = torso_mat * Mat4::::from(self.control) * upper_torso; + let upper_torso_mat = torso_mat * upper_torso; + let lower_torso_mat = upper_torso_mat * Mat4::::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::::from(self.head)), + make_bone(upper_torso_mat), + make_bone(lower_torso_mat), + make_bone(control_mat * Mat4::::from(self.main)), + make_bone(upper_torso_mat * Mat4::::from(self.shoulder_l)), + make_bone(upper_torso_mat * Mat4::::from(self.shoulder_r)), + make_bone(control_mat * Mat4::::from(self.hand_l)), + make_bone(control_mat * Mat4::::from(self.hand_r)), + make_bone(lower_torso_mat * Mat4::::from(self.leg_l)), + make_bone(lower_torso_mat * Mat4::::from(self.leg_r)), + make_bone(base_mat * Mat4::::from(self.foot_l)), + make_bone(base_mat * Mat4::::from(self.foot_r)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/biped_large/run.rs b/voxygen/src/anim/src/biped_large/run.rs index 71a1eab78e..d3c71f907b 100644 --- a/voxygen/src/anim/src/biped_large/run.rs +++ b/voxygen/src/anim/src/biped_large/run.rs @@ -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 } diff --git a/voxygen/src/anim/src/biped_large/wield.rs b/voxygen/src/anim/src/biped_large/wield.rs index 1b35ce4a9c..7dc23a4dc0 100644 --- a/voxygen/src/anim/src/biped_large/wield.rs +++ b/voxygen/src/anim/src/biped_large/wield.rs @@ -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(); diff --git a/voxygen/src/anim/src/bird_medium/feed.rs b/voxygen/src/anim/src/bird_medium/feed.rs index 50e24e68ff..51db636ca4 100644 --- a/voxygen/src/anim/src/bird_medium/feed.rs +++ b/voxygen/src/anim/src/bird_medium/feed.rs @@ -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 } diff --git a/voxygen/src/anim/src/bird_medium/fly.rs b/voxygen/src/anim/src/bird_medium/fly.rs index 56465cd141..8fdc61b7ed 100644 --- a/voxygen/src/anim/src/bird_medium/fly.rs +++ b/voxygen/src/anim/src/bird_medium/fly.rs @@ -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 } diff --git a/voxygen/src/anim/src/bird_medium/idle.rs b/voxygen/src/anim/src/bird_medium/idle.rs index b117620db5..2b7765121b 100644 --- a/voxygen/src/anim/src/bird_medium/idle.rs +++ b/voxygen/src/anim/src/bird_medium/idle.rs @@ -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 } diff --git a/voxygen/src/anim/src/bird_medium/mod.rs b/voxygen/src/anim/src/bird_medium/mod.rs index 485640e3dc..09096ab094 100644 --- a/voxygen/src/anim/src/bird_medium/mod.rs +++ b/voxygen/src/anim/src/bird_medium/mod.rs @@ -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) { - let torso_mat = self.torso.compute_base_matrix(); + fn compute_matrices_inner( + &self, + base_mat: Mat4, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::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::::from(self.head)), + make_bone(torso_mat), + make_bone(torso_mat * Mat4::::from(self.tail)), + make_bone(torso_mat * Mat4::::from(self.wing_l)), + make_bone(torso_mat * Mat4::::from(self.wing_r)), + make_bone(base_mat * Mat4::::from(self.leg_l)), + make_bone(base_mat * Mat4::::from(self.leg_r)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/bird_medium/run.rs b/voxygen/src/anim/src/bird_medium/run.rs index ff078f7b00..8cfb0699d4 100644 --- a/voxygen/src/anim/src/bird_medium/run.rs +++ b/voxygen/src/anim/src/bird_medium/run.rs @@ -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 } diff --git a/voxygen/src/anim/src/bird_small/idle.rs b/voxygen/src/anim/src/bird_small/idle.rs index d7a8d94319..94b540d9e9 100644 --- a/voxygen/src/anim/src/bird_small/idle.rs +++ b/voxygen/src/anim/src/bird_small/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/bird_small/jump.rs b/voxygen/src/anim/src/bird_small/jump.rs index 925330ce42..671d838d67 100644 --- a/voxygen/src/anim/src/bird_small/jump.rs +++ b/voxygen/src/anim/src/bird_small/jump.rs @@ -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 diff --git a/voxygen/src/anim/src/bird_small/mod.rs b/voxygen/src/anim/src/bird_small/mod.rs index 5c5fe028ca..3684e6d977 100644 --- a/voxygen/src/anim/src/bird_small/mod.rs +++ b/voxygen/src/anim/src/bird_small/mod.rs @@ -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) { - let torso_mat = self.torso.compute_base_matrix(); + fn compute_matrices_inner( + &self, + base_mat: Mat4, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::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::::from(self.head)), + make_bone(torso_mat), + make_bone(torso_mat * Mat4::::from(self.wing_l)), + make_bone(torso_mat * Mat4::::from(self.wing_r)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/bird_small/run.rs b/voxygen/src/anim/src/bird_small/run.rs index f27d70e48e..80c06aa5e8 100644 --- a/voxygen/src/anim/src/bird_small/run.rs +++ b/voxygen/src/anim/src/bird_small/run.rs @@ -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 diff --git a/voxygen/src/anim/src/character/alpha.rs b/voxygen/src/anim/src/character/alpha.rs index f118e4b6df..187ae40c2e 100644 --- a/voxygen/src/anim/src/character/alpha.rs +++ b/voxygen/src/anim/src/character/alpha.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/beta.rs b/voxygen/src/anim/src/character/beta.rs index a64ee73b83..07ecfa68da 100644 --- a/voxygen/src/anim/src/character/beta.rs +++ b/voxygen/src/anim/src/character/beta.rs @@ -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; diff --git a/voxygen/src/anim/src/character/block.rs b/voxygen/src/anim/src/character/block.rs index 6316ae70b7..2d58ba282e 100644 --- a/voxygen/src/anim/src/character/block.rs +++ b/voxygen/src/anim/src/character/block.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/blockidle.rs b/voxygen/src/anim/src/character/blockidle.rs index f0840c0370..5eb31c9d12 100644 --- a/voxygen/src/anim/src/character/blockidle.rs +++ b/voxygen/src/anim/src/character/blockidle.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/charge.rs b/voxygen/src/anim/src/character/charge.rs index 4f8f1321f7..5589299236 100644 --- a/voxygen/src/anim/src/character/charge.rs +++ b/voxygen/src/anim/src/character/charge.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/climb.rs b/voxygen/src/anim/src/character/climb.rs index 9a159d5aca..6b01c2b028 100644 --- a/voxygen/src/anim/src/character/climb.rs +++ b/voxygen/src/anim/src/character/climb.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/dance.rs b/voxygen/src/anim/src/character/dance.rs index a8cbfb3e7a..624077fc41 100644 --- a/voxygen/src/anim/src/character/dance.rs +++ b/voxygen/src/anim/src/character/dance.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/dash.rs b/voxygen/src/anim/src/character/dash.rs index 0e8d5d4e0c..6b49943f41 100644 --- a/voxygen/src/anim/src/character/dash.rs +++ b/voxygen/src/anim/src/character/dash.rs @@ -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; diff --git a/voxygen/src/anim/src/character/equip.rs b/voxygen/src/anim/src/character/equip.rs index 259a7b6511..90d929c255 100644 --- a/voxygen/src/anim/src/character/equip.rs +++ b/voxygen/src/anim/src/character/equip.rs @@ -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 ( diff --git a/voxygen/src/anim/src/character/glidewield.rs b/voxygen/src/anim/src/character/glidewield.rs index 533c475f88..61dbd69ee9 100644 --- a/voxygen/src/anim/src/character/glidewield.rs +++ b/voxygen/src/anim/src/character/glidewield.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/gliding.rs b/voxygen/src/anim/src/character/gliding.rs index 936a36fddb..ca50605437 100644 --- a/voxygen/src/anim/src/character/gliding.rs +++ b/voxygen/src/anim/src/character/gliding.rs @@ -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; diff --git a/voxygen/src/anim/src/character/idle.rs b/voxygen/src/anim/src/character/idle.rs index 56eb10ba0d..5f77d28a68 100644 --- a/voxygen/src/anim/src/character/idle.rs +++ b/voxygen/src/anim/src/character/idle.rs @@ -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 ( diff --git a/voxygen/src/anim/src/character/jump.rs b/voxygen/src/anim/src/character/jump.rs index 94591876ea..ac001ce3bd 100644 --- a/voxygen/src/anim/src/character/jump.rs +++ b/voxygen/src/anim/src/character/jump.rs @@ -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 ( diff --git a/voxygen/src/anim/src/character/leapmelee.rs b/voxygen/src/anim/src/character/leapmelee.rs index cd3aeacbcc..f2e3340136 100644 --- a/voxygen/src/anim/src/character/leapmelee.rs +++ b/voxygen/src/anim/src/character/leapmelee.rs @@ -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 } diff --git a/voxygen/src/anim/src/character/mod.rs b/voxygen/src/anim/src/character/mod.rs index f4ae26778f..5bc1ac616b 100644 --- a/voxygen/src/anim/src/character/mod.rs +++ b/voxygen/src/anim/src/character/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::from(self.torso); + let chest_mat = torso_mat * Mat4::::from(self.chest); + let head_mat = chest_mat * Mat4::::from(self.head); + let shorts_mat = chest_mat * Mat4::::from(self.shorts); + let control_mat = chest_mat * Mat4::::from(self.control); + let l_control_mat = control_mat * Mat4::::from(self.l_control); + let r_control_mat = control_mat * Mat4::::from(self.r_control); - let lantern_final_mat = - torso_mat * chest_mat * shorts_mat * self.lantern.compute_base_matrix(); + let l_hand_mat = Mat4::::from(self.l_hand); + let lantern_mat = Mat4::::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::::from(self.belt)), + make_bone(chest_mat * Mat4::::from(self.back)), + make_bone(shorts_mat), + make_bone(l_control_mat * l_hand_mat), + make_bone(r_control_mat * Mat4::::from(self.r_hand)), + make_bone(torso_mat * Mat4::::from(self.l_foot)), + make_bone(torso_mat * Mat4::::from(self.r_foot)), + make_bone(chest_mat * Mat4::::from(self.l_shoulder)), + make_bone(chest_mat * Mat4::::from(self.r_shoulder)), + make_bone(chest_mat * Mat4::::from(self.glider)), + make_bone(l_control_mat * Mat4::::from(self.main)), + make_bone(r_control_mat * Mat4::::from(self.second)), + make_bone(shorts_mat * lantern_mat), + // FIXME: Should this be l_control_mat? + make_bone(control_mat * l_hand_mat * Mat4::::from(self.hold)), + ]; + // NOTE: lantern_mat.cols.w = lantern_mat * Vec4::unit_w() + (head_mat * lantern_mat.cols.w).xyz() } } diff --git a/voxygen/src/anim/src/character/roll.rs b/voxygen/src/anim/src/character/roll.rs index 133bedabb4..ac83f5a7fd 100644 --- a/voxygen/src/anim/src/character/roll.rs +++ b/voxygen/src/anim/src/character/roll.rs @@ -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 ( diff --git a/voxygen/src/anim/src/character/run.rs b/voxygen/src/anim/src/character/run.rs index 427738ad74..58a2a90c83 100644 --- a/voxygen/src/anim/src/character/run.rs +++ b/voxygen/src/anim/src/character/run.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/shoot.rs b/voxygen/src/anim/src/character/shoot.rs index daadf2d16d..1fe4dfc856 100644 --- a/voxygen/src/anim/src/character/shoot.rs +++ b/voxygen/src/anim/src/character/shoot.rs @@ -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 ( diff --git a/voxygen/src/anim/src/character/sit.rs b/voxygen/src/anim/src/character/sit.rs index 873ea8332c..86ca5336e5 100644 --- a/voxygen/src/anim/src/character/sit.rs +++ b/voxygen/src/anim/src/character/sit.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/spin.rs b/voxygen/src/anim/src/character/spin.rs index 23a465d74e..c7b96df62c 100644 --- a/voxygen/src/anim/src/character/spin.rs +++ b/voxygen/src/anim/src/character/spin.rs @@ -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 ( diff --git a/voxygen/src/anim/src/character/spinmelee.rs b/voxygen/src/anim/src/character/spinmelee.rs index d9ffd4a93c..023e0d181b 100644 --- a/voxygen/src/anim/src/character/spinmelee.rs +++ b/voxygen/src/anim/src/character/spinmelee.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/stand.rs b/voxygen/src/anim/src/character/stand.rs index 5d3d702d54..ddb3887780 100644 --- a/voxygen/src/anim/src/character/stand.rs +++ b/voxygen/src/anim/src/character/stand.rs @@ -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(); diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 2a345bf5ac..bd218307da 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -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; diff --git a/voxygen/src/anim/src/character/wield.rs b/voxygen/src/anim/src/character/wield.rs index ed8a0401e4..375ce073b7 100644 --- a/voxygen/src/anim/src/character/wield.rs +++ b/voxygen/src/anim/src/character/wield.rs @@ -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(); diff --git a/voxygen/src/anim/src/critter/idle.rs b/voxygen/src/anim/src/critter/idle.rs index 89b1531cff..192a89cab0 100644 --- a/voxygen/src/anim/src/critter/idle.rs +++ b/voxygen/src/anim/src/critter/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/critter/jump.rs b/voxygen/src/anim/src/critter/jump.rs index d872a43ba9..4192ba66c3 100644 --- a/voxygen/src/anim/src/critter/jump.rs +++ b/voxygen/src/anim/src/critter/jump.rs @@ -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 diff --git a/voxygen/src/anim/src/critter/mod.rs b/voxygen/src/anim/src/critter/mod.rs index 167967b613..5e50de56cc 100644 --- a/voxygen/src/anim/src/critter/mod.rs +++ b/voxygen/src/anim/src/critter/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let chest_mat = base_mat * Mat4::::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::::from(self.head)), + make_bone(chest_mat), + make_bone(chest_mat * Mat4::::from(self.feet_f)), + make_bone(chest_mat * Mat4::::from(self.feet_b)), + make_bone(chest_mat * Mat4::::from(self.tail)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/critter/run.rs b/voxygen/src/anim/src/critter/run.rs index 57c099098b..60c96a4d3f 100644 --- a/voxygen/src/anim/src/critter/run.rs +++ b/voxygen/src/anim/src/critter/run.rs @@ -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 diff --git a/voxygen/src/anim/src/dragon/fly.rs b/voxygen/src/anim/src/dragon/fly.rs index 56918b25b3..4602f19cd5 100644 --- a/voxygen/src/anim/src/dragon/fly.rs +++ b/voxygen/src/anim/src/dragon/fly.rs @@ -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 diff --git a/voxygen/src/anim/src/dragon/idle.rs b/voxygen/src/anim/src/dragon/idle.rs index 874b5834bd..bee9419896 100644 --- a/voxygen/src/anim/src/dragon/idle.rs +++ b/voxygen/src/anim/src/dragon/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/dragon/mod.rs b/voxygen/src/anim/src/dragon/mod.rs index 8468b8a9a3..4792a7afdb 100644 --- a/voxygen/src/anim/src/dragon/mod.rs +++ b/voxygen/src/anim/src/dragon/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let chest_front_mat = base_mat * Mat4::::from(self.chest_front); + let chest_rear_mat = chest_front_mat * Mat4::::from(self.chest_rear); + let head_lower_mat = chest_front_mat * Mat4::::from(self.head_lower); + let wing_in_l_mat = chest_front_mat * Mat4::::from(self.wing_in_l); + let wing_in_r_mat = chest_front_mat * Mat4::::from(self.wing_in_r); + let tail_front_mat = chest_rear_mat * Mat4::::from(self.tail_front); + let head_upper_mat = head_lower_mat * Mat4::::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::::from(self.jaw)), + make_bone(chest_front_mat), + make_bone(chest_rear_mat), + make_bone(tail_front_mat), + make_bone(tail_front_mat * Mat4::::from(self.tail_rear)), + make_bone(wing_in_l_mat), + make_bone(wing_in_r_mat), + make_bone(wing_in_l_mat * Mat4::::from(self.wing_out_l)), + make_bone(wing_in_r_mat * Mat4::::from(self.wing_out_r)), + make_bone(chest_front_mat * Mat4::::from(self.foot_fl)), + make_bone(chest_front_mat * Mat4::::from(self.foot_fr)), + make_bone(chest_rear_mat * Mat4::::from(self.foot_bl)), + make_bone(chest_rear_mat * Mat4::::from(self.foot_br)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/dragon/run.rs b/voxygen/src/anim/src/dragon/run.rs index 7ca126782e..f2ebd5671d 100644 --- a/voxygen/src/anim/src/dragon/run.rs +++ b/voxygen/src/anim/src/dragon/run.rs @@ -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 diff --git a/voxygen/src/anim/src/fish_medium/idle.rs b/voxygen/src/anim/src/fish_medium/idle.rs index 06f72e0651..150a67826d 100644 --- a/voxygen/src/anim/src/fish_medium/idle.rs +++ b/voxygen/src/anim/src/fish_medium/idle.rs @@ -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 } diff --git a/voxygen/src/anim/src/fish_medium/jump.rs b/voxygen/src/anim/src/fish_medium/jump.rs index f86760ef3d..33e679b0e2 100644 --- a/voxygen/src/anim/src/fish_medium/jump.rs +++ b/voxygen/src/anim/src/fish_medium/jump.rs @@ -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 } diff --git a/voxygen/src/anim/src/fish_medium/mod.rs b/voxygen/src/anim/src/fish_medium/mod.rs index 988b58bee1..97e663bb97 100644 --- a/voxygen/src/anim/src/fish_medium/mod.rs +++ b/voxygen/src/anim/src/fish_medium/mod.rs @@ -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) { - let torso_mat = self.torso.compute_base_matrix(); - let rear_mat = self.rear.compute_base_matrix(); + fn compute_matrices_inner( + &self, + base_mat: Mat4, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::from(self.torso); + let rear_mat = torso_mat * Mat4::::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::::from(self.head)), + make_bone(torso_mat), + make_bone(rear_mat), + make_bone(rear_mat * Mat4::::from(self.tail)), + make_bone(rear_mat * Mat4::::from(self.fin_l)), + make_bone(rear_mat * Mat4::::from(self.fin_r)), + ]; + Vec3::default() } } + pub struct SkeletonAttr; impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr { diff --git a/voxygen/src/anim/src/fish_medium/run.rs b/voxygen/src/anim/src/fish_medium/run.rs index 05cd767a2d..4d0823abd3 100644 --- a/voxygen/src/anim/src/fish_medium/run.rs +++ b/voxygen/src/anim/src/fish_medium/run.rs @@ -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 } diff --git a/voxygen/src/anim/src/fish_small/idle.rs b/voxygen/src/anim/src/fish_small/idle.rs index b6cba63250..841627ec41 100644 --- a/voxygen/src/anim/src/fish_small/idle.rs +++ b/voxygen/src/anim/src/fish_small/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/fish_small/jump.rs b/voxygen/src/anim/src/fish_small/jump.rs index 5a7acaaac6..5af66c2869 100644 --- a/voxygen/src/anim/src/fish_small/jump.rs +++ b/voxygen/src/anim/src/fish_small/jump.rs @@ -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 diff --git a/voxygen/src/anim/src/fish_small/mod.rs b/voxygen/src/anim/src/fish_small/mod.rs index 8c8eb9248c..d3281ff459 100644 --- a/voxygen/src/anim/src/fish_small/mod.rs +++ b/voxygen/src/anim/src/fish_small/mod.rs @@ -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) { - let torso_mat = self.torso.compute_base_matrix(); + fn compute_matrices_inner( + &self, + base_mat: Mat4, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::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::::from(self.tail)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/fish_small/run.rs b/voxygen/src/anim/src/fish_small/run.rs index bd0fa55024..f19d685e9e 100644 --- a/voxygen/src/anim/src/fish_small/run.rs +++ b/voxygen/src/anim/src/fish_small/run.rs @@ -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 diff --git a/voxygen/src/anim/src/fixture/mod.rs b/voxygen/src/anim/src/fixture/mod.rs index fbede358b5..633b2a5ec6 100644 --- a/voxygen/src/anim/src/fixture/mod.rs +++ b/voxygen/src/anim/src/fixture/mod.rs @@ -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 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) { - ( - [ - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + buf[0] = make_bone(base_mat); + Vec3::default() } - - fn interpolate(&mut self, _target: &Self, _dt: f32) {} } diff --git a/voxygen/src/anim/src/golem/idle.rs b/voxygen/src/anim/src/golem/idle.rs index dc20071758..da453d4629 100644 --- a/voxygen/src/anim/src/golem/idle.rs +++ b/voxygen/src/anim/src/golem/idle.rs @@ -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 } diff --git a/voxygen/src/anim/src/golem/jump.rs b/voxygen/src/anim/src/golem/jump.rs index b9c834a04d..277f345ebd 100644 --- a/voxygen/src/anim/src/golem/jump.rs +++ b/voxygen/src/anim/src/golem/jump.rs @@ -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 } diff --git a/voxygen/src/anim/src/golem/mod.rs b/voxygen/src/anim/src/golem/mod.rs index 1a75152815..015c3d8750 100644 --- a/voxygen/src/anim/src/golem/mod.rs +++ b/voxygen/src/anim/src/golem/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::from(self.torso); + let foot_l_mat = base_mat * Mat4::::from(self.foot_l); + let foot_r_mat = base_mat * Mat4::::from(self.foot_r); + let upper_torso_mat = torso_mat * Mat4::::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::::from(self.head)), + make_bone(upper_torso_mat), + make_bone(upper_torso_mat * Mat4::::from(self.shoulder_l)), + make_bone(upper_torso_mat * Mat4::::from(self.shoulder_r)), + make_bone(upper_torso_mat * Mat4::::from(self.hand_l)), + make_bone(upper_torso_mat * Mat4::::from(self.hand_r)), + make_bone(foot_l_mat * Mat4::::from(self.leg_l)), + make_bone(foot_r_mat * Mat4::::from(self.leg_r)), + make_bone(foot_l_mat), + make_bone(foot_r_mat), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/golem/run.rs b/voxygen/src/anim/src/golem/run.rs index 31e24f001d..63761bb1a2 100644 --- a/voxygen/src/anim/src/golem/run.rs +++ b/voxygen/src/anim/src/golem/run.rs @@ -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 } diff --git a/voxygen/src/anim/src/lib.rs b/voxygen/src/anim/src/lib.rs index c3711a883b..506abfe2de 100644 --- a/voxygen/src/anim/src/lib.rs +++ b/voxygen/src/anim/src/lib.rs @@ -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 for &'a $Skeleton + where + Factor: Copy, + Bone: Lerp + { + 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); -impl FigureBoneData { - pub fn new(mat: Mat4) -> 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) -> 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, - pub ori: Quaternion, - pub scale: Vec3, -} - -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 { - Mat4::::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; 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, + buf: &mut [FigureBoneData; MAX_BONE_COUNT], + ) -> Vec3; +} - fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3); - - fn compute_matrices(&self) -> ([FigureBoneData; 16], Vec3) { - #[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 ([FigureBoneData; 16], Vec3)> = - 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( + skeleton: &S, + base_mat: Mat4, + buf: &mut [FigureBoneData; MAX_BONE_COUNT], +) -> Vec3 { + #[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, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Vec3, + > = 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 { diff --git a/voxygen/src/anim/src/object/mod.rs b/voxygen/src/anim/src/object/mod.rs index 6088fb9f37..d0613aa59c 100644 --- a/voxygen/src/anim/src/object/mod.rs +++ b/voxygen/src/anim/src/object/mod.rs @@ -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 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) { - ( - [ - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + buf[0] = make_bone(base_mat * Mat4::scaling_3d(SCALE)); + Vec3::default() } - - fn interpolate(&mut self, _target: &Self, _dt: f32) {} } diff --git a/voxygen/src/anim/src/quadruped_low/alpha.rs b/voxygen/src/anim/src/quadruped_low/alpha.rs index f339b4c7c4..87eedd579b 100644 --- a/voxygen/src/anim/src/quadruped_low/alpha.rs +++ b/voxygen/src/anim/src/quadruped_low/alpha.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_low/idle.rs b/voxygen/src/anim/src/quadruped_low/idle.rs index 70fdb57460..091f129c42 100644 --- a/voxygen/src/anim/src/quadruped_low/idle.rs +++ b/voxygen/src/anim/src/quadruped_low/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_low/jump.rs b/voxygen/src/anim/src/quadruped_low/jump.rs index f5a1805e0d..6e1266cf8f 100644 --- a/voxygen/src/anim/src/quadruped_low/jump.rs +++ b/voxygen/src/anim/src/quadruped_low/jump.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_low/mod.rs b/voxygen/src/anim/src/quadruped_low/mod.rs index 5813d3d359..a6463fc007 100644 --- a/voxygen/src/anim/src/quadruped_low/mod.rs +++ b/voxygen/src/anim/src/quadruped_low/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let chest_mat = base_mat * Mat4::::from(self.chest); + let tail_front = chest_mat * Mat4::::from(self.tail_front); + let head_lower_mat = chest_mat * Mat4::::from(self.head_lower); + let head_upper_mat = head_lower_mat * Mat4::::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::::from(self.jaw)), + make_bone(chest_mat), + make_bone(tail_front), + make_bone(tail_front * Mat4::::from(self.tail_rear)), + make_bone(chest_mat * Mat4::::from(self.foot_fl)), + make_bone(chest_mat * Mat4::::from(self.foot_fr)), + make_bone(chest_mat * Mat4::::from(self.foot_bl)), + make_bone(chest_mat * Mat4::::from(self.foot_br)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/quadruped_low/run.rs b/voxygen/src/anim/src/quadruped_low/run.rs index b862bd82e8..54c876e084 100644 --- a/voxygen/src/anim/src/quadruped_low/run.rs +++ b/voxygen/src/anim/src/quadruped_low/run.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_medium/alpha.rs b/voxygen/src/anim/src/quadruped_medium/alpha.rs index 9a7978b194..ae84f5f8ce 100644 --- a/voxygen/src/anim/src/quadruped_medium/alpha.rs +++ b/voxygen/src/anim/src/quadruped_medium/alpha.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_medium/idle.rs b/voxygen/src/anim/src/quadruped_medium/idle.rs index 846187c1e1..193bb3aa6e 100644 --- a/voxygen/src/anim/src/quadruped_medium/idle.rs +++ b/voxygen/src/anim/src/quadruped_medium/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_medium/jump.rs b/voxygen/src/anim/src/quadruped_medium/jump.rs index 7f79daab99..5d70d11b3c 100644 --- a/voxygen/src/anim/src/quadruped_medium/jump.rs +++ b/voxygen/src/anim/src/quadruped_medium/jump.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_medium/mod.rs b/voxygen/src/anim/src/quadruped_medium/mod.rs index bfcc29eaee..8a0c8c48c0 100644 --- a/voxygen/src/anim/src/quadruped_medium/mod.rs +++ b/voxygen/src/anim/src/quadruped_medium/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let torso_front_mat = base_mat * Mat4::::from(self.torso_front); + let torso_back_mat = torso_front_mat * Mat4::::from(self.torso_back); + let head_lower_mat = torso_front_mat * Mat4::::from(self.head_lower); + let leg_fl_mat = torso_front_mat * Mat4::::from(self.leg_fl); + let leg_fr_mat = torso_front_mat * Mat4::::from(self.leg_fr); + let leg_bl_mat = torso_back_mat * Mat4::::from(self.leg_bl); + let leg_br_mat = torso_back_mat * Mat4::::from(self.leg_br); + let head_upper_mat = head_lower_mat * Mat4::::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::::from(self.jaw)), + make_bone(torso_back_mat * Mat4::::from(self.tail)), + make_bone(torso_front_mat), + make_bone(torso_back_mat), + make_bone(head_upper_mat * Mat4::::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::::from(self.foot_fl)), + make_bone(leg_fr_mat * Mat4::::from(self.foot_fr)), + make_bone(leg_bl_mat * Mat4::::from(self.foot_bl)), + make_bone(leg_br_mat * Mat4::::from(self.foot_br)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/quadruped_medium/run.rs b/voxygen/src/anim/src/quadruped_medium/run.rs index 0f3f71acf6..8e12e0ee01 100644 --- a/voxygen/src/anim/src/quadruped_medium/run.rs +++ b/voxygen/src/anim/src/quadruped_medium/run.rs @@ -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; } diff --git a/voxygen/src/anim/src/quadruped_small/feed.rs b/voxygen/src/anim/src/quadruped_small/feed.rs index 14ba0ce77d..348eb5caf8 100644 --- a/voxygen/src/anim/src/quadruped_small/feed.rs +++ b/voxygen/src/anim/src/quadruped_small/feed.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_small/idle.rs b/voxygen/src/anim/src/quadruped_small/idle.rs index 4a8aa427b6..9209704c2d 100644 --- a/voxygen/src/anim/src/quadruped_small/idle.rs +++ b/voxygen/src/anim/src/quadruped_small/idle.rs @@ -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 diff --git a/voxygen/src/anim/src/quadruped_small/jump.rs b/voxygen/src/anim/src/quadruped_small/jump.rs index 3772fb1244..8315f0bbf9 100644 --- a/voxygen/src/anim/src/quadruped_small/jump.rs +++ b/voxygen/src/anim/src/quadruped_small/jump.rs @@ -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 } diff --git a/voxygen/src/anim/src/quadruped_small/mod.rs b/voxygen/src/anim/src/quadruped_small/mod.rs index 2effc88233..05142e0639 100644 --- a/voxygen/src/anim/src/quadruped_small/mod.rs +++ b/voxygen/src/anim/src/quadruped_small/mod.rs @@ -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) { - 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, + buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + ) -> Vec3 { + let chest_mat = base_mat * Mat4::::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::::from(self.head)), + make_bone(chest_mat), + make_bone(chest_mat * Mat4::::from(self.leg_fl)), + make_bone(chest_mat * Mat4::::from(self.leg_fr)), + make_bone(chest_mat * Mat4::::from(self.leg_bl)), + make_bone(chest_mat * Mat4::::from(self.leg_br)), + make_bone(chest_mat * Mat4::::from(self.tail)), + ]; + Vec3::default() } } diff --git a/voxygen/src/anim/src/quadruped_small/run.rs b/voxygen/src/anim/src/quadruped_small/run.rs index 974d9ce983..2cf079875e 100644 --- a/voxygen/src/anim/src/quadruped_small/run.rs +++ b/voxygen/src/anim/src/quadruped_small/run.rs @@ -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(); diff --git a/voxygen/src/anim/src/vek.rs b/voxygen/src/anim/src/vek.rs new file mode 100644 index 0000000000..718f267d83 --- /dev/null +++ b/voxygen/src/anim/src/vek.rs @@ -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::*, +}; */ diff --git a/voxygen/src/hud/map.rs b/voxygen/src/hud/map.rs index 9c0099beff..ae34f752d0 100644 --- a/voxygen/src/hud/map.rs +++ b/voxygen/src/hud/map.rs @@ -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) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 931570e5d4..8a1a88c358 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -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 } diff --git a/voxygen/src/hud/overhead.rs b/voxygen/src/hud/overhead.rs index ad551d7281..1c08691740 100644 --- a/voxygen/src/hud/overhead.rs +++ b/voxygen/src/hud/overhead.rs @@ -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); } diff --git a/voxygen/src/hud/overitem.rs b/voxygen/src/hud/overitem.rs index bb4458ecb6..46da9859db 100644 --- a/voxygen/src/hud/overitem.rs +++ b/voxygen/src/hud/overitem.rs @@ -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::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) diff --git a/voxygen/src/render/mesh.rs b/voxygen/src/render/mesh.rs index bad7507530..fc19781c3c 100644 --- a/voxygen/src/render/mesh.rs +++ b/voxygen/src/render/mesh.rs @@ -21,7 +21,7 @@ where impl Mesh

{ /// 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(); } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 08bca8ce60..8e87b8c23b 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -83,27 +83,6 @@ impl FigureMgrStates { } } - /* fn get<'a, Q: ?Sized>(&'a self, body: &Body, entity: &Q) -> Option<&'a FigureStateMeta> - where - EcsEntity: Borrow, - Q: Hash + Eq, - { - match body { - Body::Humanoid(_) => self.character_states.get(&entity).map(Deref::deref), - Body::QuadrupedSmall(_) => self.quadruped_small_states.get(&entity).map(Deref::deref), - Body::QuadrupedMedium(_) => self.quadruped_medium_states.get(&entity).map(Deref::deref), - Body::BirdMedium(_) => self.bird_medium_states.get(&entity).map(Deref::deref), - Body::FishMedium(_) => self.fish_medium_states.get(&entity).map(Deref::deref), - Body::Critter(_) => self.critter_states.get(&entity).map(Deref::deref), - Body::Dragon(_) => self.dragon_states.get(&entity).map(Deref::deref), - Body::BirdSmall(_) => self.bird_small_states.get(&entity).map(Deref::deref), - Body::FishSmall(_) => self.fish_small_states.get(&entity).map(Deref::deref), - Body::BipedLarge(_) => self.biped_large_states.get(&entity).map(Deref::deref), - Body::Golem(_) => self.golem_states.get(&entity).map(Deref::deref), - Body::Object(_) => self.object_states.get(&entity).map(Deref::deref), - } - } */ - fn get_mut<'a, Q: ?Sized>( &'a mut self, body: &Body, @@ -360,7 +339,7 @@ impl FigureMgr { let mut anim_storage = ecs.write_storage::(); if let None = anim_storage.get_mut(entity) { let anim = LightAnimation { - offset: vek::Vec3::zero(), //Vec3::new(0.0, 0.0, 2.0), + offset: vek::Vec3::zero(), col: light_emitter.col, strength: 0.0, }; @@ -371,7 +350,7 @@ impl FigureMgr { let updater = ecs.read_resource::(); for (entity, waypoint, light_emitter_opt, light_anim) in ( &ecs.entities(), - ecs.read_storage::().maybe(), + ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), &mut ecs.write_storage::(), ) @@ -393,7 +372,7 @@ impl FigureMgr { (vek::Rgb::zero(), 0.0, 0.0, true) }; if let Some(_) = waypoint { - light_anim.offset = vek::Vec3::unit_z() * 0.5; + light_anim.offset = vek::Vec3::unit_z() * 5.0; } if let Some(state) = self.states.character_states.get(&entity) { light_anim.offset = vek::Vec3::from(state.lantern_offset); @@ -446,6 +425,7 @@ impl FigureMgr { let ecs = state.ecs(); let view_distance = scene_data.view_distance; let dt = state.get_delta_time(); + let dt_lerp = (15.0 * dt).min(1.0); let frustum = camera.frustum(); // Sun shadows--find the bounding box of the shadow map plane (i.e. the bounds @@ -469,34 +449,6 @@ impl FigureMgr { let ray_mat: math::Mat4 = math::Mat4::look_at_rh(cam_pos, cam_pos + ray_direction, math::Vec3::up()); let focus_off = math::Vec3::from(camera.get_focus_pos().map(f32::trunc)); - /* let visible_bounding_box = Aabb { - min: visible_bounding_box.min - focus_off, - max: visible_bounding_box.max - focus_off, - }; - let visible_bounds_fine = math::Aabb:: { - min: math::Vec3::from(visible_bounding_box.min.map(f64::from)), - max: math::Vec3::from(visible_bounding_box.max.map(f64::from)), - }; - let inv_proj_view = math::Mat4::from_col_arrays( - (proj_mat * view_mat/* * Mat4::translation_3d(-focus_off)*/).into_col_arrays(), - ) - .map(f64::from) - .inverted(); - let visible_light_volume = math::calc_focused_light_volume_points( - inv_proj_view, - ray_direction.map(f64::from), - visible_bounds_fine, - 1e-6, - ) - .map(|v| v.map(|e| e as f32)); - // Now that the work that requires high accuracy is done, switch from focus-relative - // to proper world space coordinates. - let visible_bounds = math::Aabr::from(math::fit_psr( - ray_mat, - /* super::aabb_to_points(visible_bounding_box).iter().copied() */ - visible_light_volume, - |p| p, //math::Vec3::from(p), /* / p.w */ - )); */ let ray_mat = ray_mat * math::Mat4::translation_3d(-focus_off); let collides_with_aabr = |a: math::Aabr, b: math::Aabr| { @@ -515,7 +467,6 @@ impl FigureMgr { min: center - radius, max: center + radius, }; - // println!("center: {:?}, radius: {:?}", center, figure_box); // Quick intersection test for membership in the PSC (potential shader caster) // list. collides_with_aabr(figure_box, visible_psr_bounds) @@ -534,6 +485,8 @@ impl FigureMgr { let focus_pos = anim::vek::Vec3::::from(camera.get_focus_pos()); + let mut update_buf = [Default::default(); anim::MAX_BONE_COUNT]; + for ( i, ( @@ -702,7 +655,9 @@ impl FigureMgr { .states .character_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, CharacterSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, CharacterSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), _ => continue, @@ -719,7 +674,7 @@ impl FigureMgr { ) { // Standing (true, false, _) => anim::character::StandAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), ( active_tool_kind.clone(), second_tool_kind.clone(), @@ -732,7 +687,7 @@ impl FigureMgr { ), // Running (true, true, _) => anim::character::RunAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), ( active_tool_kind.clone(), second_tool_kind.clone(), @@ -748,7 +703,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::character::JumpAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), ( active_tool_kind.clone(), second_tool_kind.clone(), @@ -762,7 +717,7 @@ impl FigureMgr { ), // Swim (false, _, true) => anim::character::SwimAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), ( active_tool_kind.clone(), second_tool_kind.clone(), @@ -920,7 +875,7 @@ impl FigureMgr { }, CharacterState::BasicBlock { .. } => { anim::character::BlockIdleAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), (active_tool_kind, second_tool_kind, time), state.state_time, &mut state_animation_rate, @@ -973,7 +928,7 @@ impl FigureMgr { }, CharacterState::Climb { .. } => { anim::character::ClimbAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), (active_tool_kind, second_tool_kind, vel.0, ori, time), state.state_time, &mut state_animation_rate, @@ -982,7 +937,7 @@ impl FigureMgr { }, CharacterState::Sit { .. } => { anim::character::SitAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), (active_tool_kind, second_tool_kind, time), state.state_time, &mut state_animation_rate, @@ -991,7 +946,7 @@ impl FigureMgr { }, CharacterState::GlideWield { .. } => { anim::character::GlideWieldAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), ( active_tool_kind, second_tool_kind, @@ -1007,7 +962,7 @@ impl FigureMgr { }, CharacterState::Dance { .. } => { anim::character::DanceAnimation::update_skeleton( - &CharacterSkeleton::new(), + &CharacterSkeleton::default(), (active_tool_kind, second_tool_kind, time), state.state_time, &mut state_animation_rate, @@ -1017,7 +972,7 @@ impl FigureMgr { _ => target_base, }; - state.skeleton.interpolate(&target_bones, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0, @@ -1031,6 +986,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::QuadrupedSmall(_) => { @@ -1050,7 +1006,7 @@ impl FigureMgr { .quadruped_small_states .entry(entity) .or_insert_with(|| { - FigureState::new(renderer, QuadrupedSmallSkeleton::new()) + FigureState::new(renderer, QuadrupedSmallSkeleton::default()) }); let (character, last_character) = match (character, last_character) { @@ -1070,7 +1026,7 @@ impl FigureMgr { // Standing (true, false, false) => { anim::quadruped_small::IdleAnimation::update_skeleton( - &QuadrupedSmallSkeleton::new(), + &QuadrupedSmallSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1080,7 +1036,7 @@ impl FigureMgr { // Running (true, true, false) => { anim::quadruped_small::RunAnimation::update_skeleton( - &QuadrupedSmallSkeleton::new(), + &QuadrupedSmallSkeleton::default(), (vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel), state.state_time, &mut state_animation_rate, @@ -1089,14 +1045,14 @@ impl FigureMgr { }, // In air (false, _, false) => anim::quadruped_small::JumpAnimation::update_skeleton( - &QuadrupedSmallSkeleton::new(), + &QuadrupedSmallSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, ), _ => anim::quadruped_small::IdleAnimation::update_skeleton( - &QuadrupedSmallSkeleton::new(), + &QuadrupedSmallSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1117,7 +1073,7 @@ impl FigureMgr { _ => target_base, }; - state.skeleton.interpolate(&target_bones, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0, @@ -1131,6 +1087,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::QuadrupedMedium(_) => { @@ -1150,7 +1107,7 @@ impl FigureMgr { .quadruped_medium_states .entry(entity) .or_insert_with(|| { - FigureState::new(renderer, QuadrupedMediumSkeleton::new()) + FigureState::new(renderer, QuadrupedMediumSkeleton::default()) }); let (character, last_character) = match (character, last_character) { @@ -1170,7 +1127,7 @@ impl FigureMgr { // Standing (true, false, false) => { anim::quadruped_medium::IdleAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), + &QuadrupedMediumSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1179,7 +1136,7 @@ impl FigureMgr { }, // Running (true, true, _) => anim::quadruped_medium::RunAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), + &QuadrupedMediumSkeleton::default(), (vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel), state.state_time, &mut state_animation_rate, @@ -1188,7 +1145,7 @@ impl FigureMgr { // In air (false, _, false) => { anim::quadruped_medium::JumpAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), + &QuadrupedMediumSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1196,7 +1153,7 @@ impl FigureMgr { ) }, _ => anim::quadruped_medium::IdleAnimation::update_skeleton( - &QuadrupedMediumSkeleton::new(), + &QuadrupedMediumSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1217,7 +1174,7 @@ impl FigureMgr { _ => target_base, }; - state.skeleton.interpolate(&target_bones, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0, @@ -1231,6 +1188,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::QuadrupedLow(_) => { @@ -1249,7 +1207,9 @@ impl FigureMgr { .states .quadruped_low_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, QuadrupedLowSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, QuadrupedLowSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1268,7 +1228,7 @@ impl FigureMgr { // Standing (true, false, false) => { anim::quadruped_low::IdleAnimation::update_skeleton( - &QuadrupedLowSkeleton::new(), + &QuadrupedLowSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1277,7 +1237,7 @@ impl FigureMgr { }, // Running (true, true, _) => anim::quadruped_low::RunAnimation::update_skeleton( - &QuadrupedLowSkeleton::new(), + &QuadrupedLowSkeleton::default(), (vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel), state.state_time, &mut state_animation_rate, @@ -1285,14 +1245,14 @@ impl FigureMgr { ), // In air (false, _, false) => anim::quadruped_low::JumpAnimation::update_skeleton( - &QuadrupedLowSkeleton::new(), + &QuadrupedLowSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, ), _ => anim::quadruped_low::IdleAnimation::update_skeleton( - &QuadrupedLowSkeleton::new(), + &QuadrupedLowSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1313,7 +1273,7 @@ impl FigureMgr { _ => target_base, }; - state.skeleton.interpolate(&target_bones, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0, @@ -1327,6 +1287,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::BirdMedium(_) => { @@ -1344,7 +1305,9 @@ impl FigureMgr { .states .bird_medium_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, BirdMediumSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, BirdMediumSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1362,7 +1325,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::bird_medium::IdleAnimation::update_skeleton( - &BirdMediumSkeleton::new(), + &BirdMediumSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1370,7 +1333,7 @@ impl FigureMgr { ), // Running (true, true, _) => anim::bird_medium::RunAnimation::update_skeleton( - &BirdMediumSkeleton::new(), + &BirdMediumSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1378,14 +1341,14 @@ impl FigureMgr { ), // In air (false, _, false) => anim::bird_medium::FlyAnimation::update_skeleton( - &BirdMediumSkeleton::new(), + &BirdMediumSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, ), _ => anim::bird_medium::IdleAnimation::update_skeleton( - &BirdMediumSkeleton::new(), + &BirdMediumSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1406,7 +1369,7 @@ impl FigureMgr { _ => target_base, }; - state.skeleton.interpolate(&target_bones, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0, @@ -1420,6 +1383,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::FishMedium(_) => { @@ -1437,7 +1401,9 @@ impl FigureMgr { .states .fish_medium_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, FishMediumSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, FishMediumSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1455,7 +1421,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::fish_medium::IdleAnimation::update_skeleton( - &FishMediumSkeleton::new(), + &FishMediumSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1463,7 +1429,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::fish_medium::RunAnimation::update_skeleton( - &FishMediumSkeleton::new(), + &FishMediumSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1471,7 +1437,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::fish_medium::JumpAnimation::update_skeleton( - &FishMediumSkeleton::new(), + &FishMediumSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1482,7 +1448,7 @@ impl FigureMgr { _ => state.skeleton_mut().clone(), }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt); state.update( renderer, pos.0, @@ -1496,6 +1462,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::Dragon(_) => { @@ -1509,11 +1476,10 @@ impl FigureMgr { None, ); - let state = self - .states - .dragon_states - .entry(entity) - .or_insert_with(|| FigureState::new(renderer, DragonSkeleton::new())); + let state = + self.states.dragon_states.entry(entity).or_insert_with(|| { + FigureState::new(renderer, DragonSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1531,7 +1497,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::dragon::IdleAnimation::update_skeleton( - &DragonSkeleton::new(), + &DragonSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1539,7 +1505,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::dragon::RunAnimation::update_skeleton( - &DragonSkeleton::new(), + &DragonSkeleton::default(), (vel.0.magnitude(), ori, state.last_ori, time, state.avg_vel), state.state_time, &mut state_animation_rate, @@ -1547,7 +1513,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::dragon::FlyAnimation::update_skeleton( - &DragonSkeleton::new(), + &DragonSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1557,7 +1523,7 @@ impl FigureMgr { _ => state.skeleton_mut().clone(), }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt); state.update( renderer, pos.0, @@ -1571,6 +1537,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::Critter(_) => { @@ -1584,11 +1551,10 @@ impl FigureMgr { None, ); - let state = self - .states - .critter_states - .entry(entity) - .or_insert_with(|| FigureState::new(renderer, CritterSkeleton::new())); + let state = + self.states.critter_states.entry(entity).or_insert_with(|| { + FigureState::new(renderer, CritterSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1606,7 +1572,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::critter::IdleAnimation::update_skeleton( - &CritterSkeleton::new(), + &CritterSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1614,7 +1580,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::critter::RunAnimation::update_skeleton( - &CritterSkeleton::new(), + &CritterSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1622,7 +1588,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::critter::JumpAnimation::update_skeleton( - &CritterSkeleton::new(), + &CritterSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1633,7 +1599,7 @@ impl FigureMgr { _ => state.skeleton_mut().clone(), }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt); state.update( renderer, pos.0, @@ -1647,6 +1613,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::BirdSmall(_) => { @@ -1664,7 +1631,9 @@ impl FigureMgr { .states .bird_small_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, BirdSmallSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, BirdSmallSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1682,7 +1651,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::bird_small::IdleAnimation::update_skeleton( - &BirdSmallSkeleton::new(), + &BirdSmallSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1690,7 +1659,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::bird_small::RunAnimation::update_skeleton( - &BirdSmallSkeleton::new(), + &BirdSmallSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1698,7 +1667,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::bird_small::JumpAnimation::update_skeleton( - &BirdSmallSkeleton::new(), + &BirdSmallSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1709,7 +1678,7 @@ impl FigureMgr { _ => state.skeleton_mut().clone(), }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt); state.update( renderer, pos.0, @@ -1723,6 +1692,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::FishSmall(_) => { @@ -1740,7 +1710,9 @@ impl FigureMgr { .states .fish_small_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, FishSmallSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, FishSmallSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1758,7 +1730,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::fish_small::IdleAnimation::update_skeleton( - &FishSmallSkeleton::new(), + &FishSmallSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1766,7 +1738,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::fish_small::RunAnimation::update_skeleton( - &FishSmallSkeleton::new(), + &FishSmallSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1774,7 +1746,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::fish_small::JumpAnimation::update_skeleton( - &FishSmallSkeleton::new(), + &FishSmallSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1785,7 +1757,7 @@ impl FigureMgr { _ => state.skeleton_mut().clone(), }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt); state.update( renderer, pos.0, @@ -1799,6 +1771,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::BipedLarge(_) => { @@ -1816,7 +1789,9 @@ impl FigureMgr { .states .biped_large_states .entry(entity) - .or_insert_with(|| FigureState::new(renderer, BipedLargeSkeleton::new())); + .or_insert_with(|| { + FigureState::new(renderer, BipedLargeSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1834,7 +1809,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::biped_large::IdleAnimation::update_skeleton( - &BipedLargeSkeleton::new(), + &BipedLargeSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1842,7 +1817,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::biped_large::RunAnimation::update_skeleton( - &BipedLargeSkeleton::new(), + &BipedLargeSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1850,14 +1825,14 @@ impl FigureMgr { ), // In air (false, _, false) => anim::biped_large::JumpAnimation::update_skeleton( - &BipedLargeSkeleton::new(), + &BipedLargeSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, ), _ => anim::biped_large::IdleAnimation::update_skeleton( - &BipedLargeSkeleton::new(), + &BipedLargeSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1878,7 +1853,7 @@ impl FigureMgr { _ => target_base, }; - state.skeleton.interpolate(&target_bones, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); state.update( renderer, pos.0, @@ -1892,6 +1867,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::Golem(_) => { @@ -1905,11 +1881,10 @@ impl FigureMgr { None, ); - let state = self - .states - .golem_states - .entry(entity) - .or_insert_with(|| FigureState::new(renderer, GolemSkeleton::new())); + let state = + self.states.golem_states.entry(entity).or_insert_with(|| { + FigureState::new(renderer, GolemSkeleton::default()) + }); let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), @@ -1927,7 +1902,7 @@ impl FigureMgr { ) { // Standing (true, false, false) => anim::golem::IdleAnimation::update_skeleton( - &GolemSkeleton::new(), + &GolemSkeleton::default(), time, state.state_time, &mut state_animation_rate, @@ -1935,7 +1910,7 @@ impl FigureMgr { ), // Running (true, true, false) => anim::golem::RunAnimation::update_skeleton( - &GolemSkeleton::new(), + &GolemSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1943,7 +1918,7 @@ impl FigureMgr { ), // In air (false, _, false) => anim::golem::JumpAnimation::update_skeleton( - &GolemSkeleton::new(), + &GolemSkeleton::default(), (vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, @@ -1954,7 +1929,7 @@ impl FigureMgr { _ => state.skeleton_mut().clone(), }; - state.skeleton.interpolate(&target_base, dt); + state.skeleton = anim::vek::Lerp::lerp(&state.skeleton, &target_base, dt); state.update( renderer, pos.0, @@ -1968,6 +1943,7 @@ impl FigureMgr { in_frustum, is_player, camera, + &mut update_buf, ); }, Body::Object(_) => { @@ -1981,11 +1957,10 @@ impl FigureMgr { None, ); - let state = self - .states - .object_states - .entry(entity) - .or_insert_with(|| FigureState::new(renderer, ObjectSkeleton::new())); + let state = + self.states.object_states.entry(entity).or_insert_with(|| { + FigureState::new(renderer, ObjectSkeleton::default()) + }); state.update( renderer, @@ -2000,6 +1975,7 @@ impl FigureMgr { true, is_player, camera, + &mut update_buf, ); }, } @@ -2209,29 +2185,6 @@ impl FigureMgr { } } - /* fn do_models_for_render( - state: &State, - player_entity: EcsEntity, - ) -> impl IntoIterator<> + Clone { - let ecs = state.ecs(); - - ( - &ecs.entities(), - &ecs.read_storage::(), - ecs.read_storage::().maybe(), - &ecs.read_storage::(), - ecs.read_storage::().maybe(), - ecs.read_storage::().maybe(), - ecs.read_storage::().maybe(), - ) - .join() - // Don't render dead entities - .filter(|(_, _, _, _, stats, _, _)| stats.map_or(true, |s| !s.is_dead)) - .for_each(|(entity, pos, _, body, _, loadout, _)| { - - }); - } */ - #[allow(clippy::too_many_arguments)] // TODO: Pending review in #587 fn get_model_for_render( &mut self, @@ -2597,9 +2550,8 @@ impl FigureColLights { &mut self, renderer: &mut Renderer, greedy: GreedyMesh<'a>, - /* (opaque, shadow) */ (opaque, bounds): BoneMeshes, + (opaque, bounds): BoneMeshes, ) -> Result { - // println!("Figure bounds: {:?}", bounds); let (tex, tex_size) = greedy.finalize(); let atlas = &mut self.atlas; let allocation = atlas @@ -2608,38 +2560,6 @@ impl FigureColLights { i32::from(tex_size.y), )) .expect("Not yet implemented: allocate new atlas on allocation faillure."); - // println!("Allocation {:?} for {:?} (original size = {:?}... ugh)", - // allocation, response.pos, tex_size); NOTE: Cast is safe since the - // origin was a u16. - let atlas_offs = vek::Vec2::new( - allocation.rectangle.min.x as u16, - allocation.rectangle.min.y as u16, - ); - if atlas_offs == vek::Vec2::zero() { - // println!("Model: {:?}", &response.opaque_mesh.vertices()); - // println!("Texture: {:?}", tex); - } - - /* if let Err(err) = renderer.update_texture( - &self.col_lights, - // &col_lights, - // NOTE: Cast is safe since the origin was a u16. - atlas_offs.into_array(), - tex_size.into_array(), - &tex, - ) { - panic!("Ahhh {:?}", err); - log::warn!("Failed to update texture: {:?}", err); - } */ - // FIXME: Deal with allocation failure! - /* renderer.update_texture( - &self.col_lights, - // &col_lights, - // NOTE: Cast is safe since the origin was a u16. - atlas_offs.into_array(), - tex_size.into_array(), - &tex, - )?; */ let col_lights = ShadowPipeline::create_col_lights(renderer, (tex, tex_size))?; Ok(FigureModel { @@ -2657,7 +2577,6 @@ impl FigureColLights { let max_texture_size = renderer.max_texture_size(); let atlas_size = guillotiere::Size::new(i32::from(max_texture_size), i32::from(max_texture_size)); - // let atlas_size = guillotiere::Size::new(1, 1); let atlas = AtlasAllocator::with_options(atlas_size, &guillotiere::AllocatorOptions { // TODO: Verify some good empirical constants. small_size_threshold: 32, @@ -2671,8 +2590,7 @@ impl FigureColLights { gfx::texture::AaMode::Single, ), 1 as gfx::texture::Level, - // gfx::memory::Upload, - gfx::memory::Bind::SHADER_RESOURCE, /* | gfx::memory::Bind::TRANSFER_DST */ + gfx::memory::Bind::SHADER_RESOURCE, gfx::memory::Usage::Dynamic, (0, 0), gfx::format::Swizzle::new(), @@ -2681,25 +2599,6 @@ impl FigureColLights { gfx::texture::WrapMode::Clamp, ), )?; - /* renderer.flush(); - renderer.update_texture( - &texture, - [0, 0], - [max_texture_size, max_texture_size], - &vec![[0u8; 4]; (usize::from(max_texture_size) * usize::from(max_texture_size))], - //&[[255u8; 4]; 64 * 64], - // NOTE: Cast is safe since the origin was a u16. - )?; - renderer.flush(); */ - // texture.cleanup(); - // Not sure if this is necessary... - // renderer.flush(); - // texture.update(); - // // FIXME: Currently, there seems to be a bug where the very first texture - // update always // fails. Not sure why, but we currently work around - // it with a dummy allocation (which we // proceed to leak, in case the - // bug can return after it's freed). let _ = atlas.allocate(guillotiere: - // :Size::new(64, 64)); Ok((atlas, texture)) } } @@ -2743,13 +2642,13 @@ impl DerefMut for FigureState { impl FigureState { pub fn new(renderer: &mut Renderer, skeleton: S) -> Self { - let (bone_mats, lantern_offset) = skeleton.compute_matrices(); - let bone_consts = figure_bone_data_from_anim(bone_mats, |mat| { - FigureBoneData::new(mat, mat.map_cols(|c| c.normalized())) - }); + let mut buf = [Default::default(); anim::MAX_BONE_COUNT]; + let lantern_offset = + anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), &mut buf); + let bone_consts = figure_bone_data_from_anim(&buf); Self { meta: FigureStateMeta { - bone_consts: renderer.create_consts(&bone_consts).unwrap(), + bone_consts: renderer.create_consts(bone_consts).unwrap(), locals: renderer.create_consts(&[FigureLocals::default()]).unwrap(), lantern_offset, state_time: 0.0, @@ -2779,6 +2678,7 @@ impl FigureState { _visible: bool, is_player: bool, camera: &Camera, + buf: &mut [anim::FigureBoneData; anim::MAX_BONE_COUNT], ) { let _frustum = camera.frustum(); @@ -2789,27 +2689,14 @@ impl FigureState { let radius = model.bounds.half_size().reduce_partial_max(); let _bounds = BoundingSphere::new(pos.into_array(), scale * 0.8 * radius); - /* let (in_frustum, lpindex) = bounds.coherent_test_against_frustum(frustum, self.lpindex); - let visible = visible && in_frustum; - - self.lpindex = lpindex; - self.visible = visible; */ - // What is going on here? - // (note: that ori is now the slerped ori) self.last_ori = vek::Lerp::lerp(self.last_ori, ori, 15.0 * dt); self.state_time += (dt * state_animation_rate) as f64; - // let _focus_off = camera.get_focus_pos().map(|e| e.trunc()); - let mat = anim::vek::Mat4::::identity() - // * Mat4::translation_3d(pos - focus_off) - * anim::vek::Mat4::rotation_z(-ori.x.atan2(ori.y)) + let mat = anim::vek::Mat4::rotation_z(-ori.x.atan2(ori.y)) * anim::vek::Mat4::rotation_x(ori.z.atan2(anim::vek::Vec2::from(ori).magnitude())) * anim::vek::Mat4::scaling_3d(anim::vek::Vec3::from(0.8 * scale)); - /* let dependents = camera.get_dependents(); - let all_mat = dependents.proj_mat * dependents.view_mat; */ - let atlas_offs = model.allocation.rectangle.min; let locals = FigureLocals::new( mat, @@ -2820,17 +2707,14 @@ impl FigureState { ); renderer.update_consts(&mut self.locals, &[locals]).unwrap(); - let (new_bone_mats, lantern_offset) = self.skeleton.compute_matrices(); + let lantern_offset = anim::compute_matrices(&self.skeleton, mat, buf); - let new_bone_consts = figure_bone_data_from_anim(new_bone_mats, |bone_mat| { - let model_mat = mat * bone_mat; - FigureBoneData::new(model_mat, model_mat.map_cols(|c| c.normalized())) - }); + let new_bone_consts = figure_bone_data_from_anim(buf); renderer .update_consts( &mut self.meta.bone_consts, - &new_bone_consts[0..self.skeleton.bone_count()], + &new_bone_consts[0..S::BONE_COUNT], ) .unwrap(); self.lantern_offset = lantern_offset; @@ -2850,25 +2734,7 @@ impl FigureState { } fn figure_bone_data_from_anim( - mats: [anim::FigureBoneData; 16], - mut make_bone: impl FnMut(anim::vek::Mat4) -> FigureBoneData, -) -> [FigureBoneData; 16] { - [ - make_bone(mats[0].0), - make_bone(mats[1].0), - make_bone(mats[2].0), - make_bone(mats[3].0), - make_bone(mats[4].0), - make_bone(mats[5].0), - make_bone(mats[6].0), - make_bone(mats[7].0), - make_bone(mats[8].0), - make_bone(mats[9].0), - make_bone(mats[10].0), - make_bone(mats[11].0), - make_bone(mats[12].0), - make_bone(mats[13].0), - make_bone(mats[14].0), - make_bone(mats[15].0), - ] + mats: &[anim::FigureBoneData; anim::MAX_BONE_COUNT], +) -> &[FigureBoneData] { + gfx::memory::cast_slice(mats) } diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index d25548394e..3f6d34b1f3 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -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, ); } } diff --git a/voxygen/src/ui/cache.rs b/voxygen/src/ui/cache.rs index 08ffacf005..fe2eaa13f5 100644 --- a/voxygen/src/ui/cache.rs +++ b/voxygen/src/ui/cache.rs @@ -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>; 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() diff --git a/voxygen/src/ui/mod.rs b/voxygen/src/ui/mod.rs index 41d29d6ec3..182f1e4b87 100644 --- a/voxygen/src/ui/mod.rs +++ b/voxygen/src/ui/mod.rs @@ -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, + // Mesh buffer for UI vertics; we reuse its allocation in order to limit vector reallocations + // during redrawing. + mesh: Mesh, // Model for drawing the ui model: DynamicModel, // 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>, + 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::()?))) + .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::>(); + + 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::>(); - - 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, Vec3) = ((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>) { diff --git a/voxygen/src/ui/widgets/ingame.rs b/voxygen/src/ui/widgets/ingame.rs index e8f5ccf49f..957b049343 100644 --- a/voxygen/src/ui/widgets/ingame.rs +++ b/voxygen/src/ui/widgets/ingame.rs @@ -54,7 +54,7 @@ pub struct IngameParameters { } pub struct State { - id: Option, + id: widget::Id, pub parameters: IngameParameters, } @@ -78,7 +78,7 @@ impl Widget for Ingame { 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 Widget for Ingame { }); } - widget.set_ingame(state.id.unwrap(), ui) + widget.set_ingame(state.id, ui) } fn default_x_position(&self, _: &Ui) -> Position { Position::Absolute(0.0) } diff --git a/world/Cargo.toml b/world/Cargo.toml index 31d44f483c..cc5662e18a 100644 --- a/world/Cargo.toml +++ b/world/Cargo.toml @@ -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"