Adds look_dir to anims, humanoid heads pivot fixes

This commit is contained in:
Snowram 2021-02-22 20:00:06 +01:00
parent 3cb6a5592d
commit 684961b15c
9 changed files with 43 additions and 34 deletions

View File

@ -1,6 +1,6 @@
({
(Human, Male): (
offset: (-7.0, -4.0, -6.0),
offset: (-7.0, -4.0, -2.0),
head: ("figure.head.human.male", (0, 2, 0)),
eyes: [
Some(("figure.eyes.general.male_default-0", (3, 9, 2))),
@ -45,7 +45,7 @@
None]
),
(Human, Female): (
offset: (-7.0, -4.0, -6.0),
offset: (-7.0, -4.0, -2.0),
head: ("figure.head.human.female", (0, 3, 0)),
eyes: [
Some(("figure.eyes.general.female_default-0", (2, 10, 2))),
@ -82,7 +82,7 @@
None]
),
(Orc, Male): (
offset: (-8.0, -5.0, -6.75),
offset: (-8.0, -5.0, -2.0),
head: ("figure.head.orc.male", (0, 3, 0)),
eyes: [
Some(("figure.eyes.orc.male-0", (5, 10, 6))),
@ -113,7 +113,7 @@
],
),
(Orc, Female): (
offset: (-8.0, -2.5, -6.0),
offset: (-8.0, -2.5, -2.0),
head: ("figure.head.orc.female", (0, 1, 0)),
eyes: [
Some(("figure.eyes.general.female_default-0", (3, 8, 2))),
@ -141,7 +141,7 @@
],
),
(Elf, Male): (
offset: (-8.0, -4.0, -6.0),
offset: (-8.0, -4.0, -2.0),
head: ("figure.head.elf.male", (0, 2, 0)),
eyes: [
Some(("figure.eyes.general.male_default-0", (4, 9, 2))),
@ -164,7 +164,7 @@
]
),
(Elf, Female): (
offset: (-8.0, -4.0, -6.0),
offset: (-8.0, -4.0, -2.0),
head: ("figure.head.elf.female", (0, 2, 0)),
eyes: [
Some(("figure.eyes.general.female_styled-0", (3, 9, 2))),
@ -204,7 +204,7 @@
Some(("figure.accessory.elf.headband-0", (6, 9, 4))),]
),
(Dwarf, Male): (
offset: (-6.0, -4.5, -6.0),
offset: (-6.0, -4.5, -2.0),
head: ("figure.head.dwarf.male", (0, 3, 0)),
eyes: [
Some(("figure.eyes.general.male_bushy-0", (2, 10, 2))),
@ -257,7 +257,7 @@
]
),
(Dwarf, Female): (
offset: (-6.0, -4.5, -6.0),
offset: (-6.0, -4.5, -2.0),
head: ("figure.head.dwarf.female", (0, 3, 0)),
eyes: [
Some(("figure.eyes.general.female_default-0", (1, 10, 2))),
@ -289,7 +289,7 @@
]
),
(Undead, Male): (
offset: (-5.0, -4.0, -6.75),
offset: (-5.0, -4.0, -2.0),
head: ("figure.head.undead.male", (0, 2, 0)),
eyes: [
Some(("figure.eyes.undead.male-0", (2, 8, 4))),
@ -310,7 +310,7 @@
Some(("figure.accessory.undead.male_eyepatch", (0, 1, 0))),]
),
(Undead, Female): (
offset: (-5.0, -4.0, -6.75),
offset: (-5.0, -4.0, -2.0),
head: ("figure.head.undead.female", (0, 2, 0)),
eyes: [
Some(("figure.eyes.undead.female-0", (2, 8, 3))),
@ -331,7 +331,7 @@
Some(("figure.accessory.undead.female_eyepatch", (0, 1, -1))),]
),
(Danari, Male): (
offset: (-9.0, -4.0, -7.5),
offset: (-9.0, -4.0, -2.0),
head: ("figure.head.danari.male", (0, 2, 2)),
eyes: [
Some(("figure.eyes.general.male_bushy-0", (5, 9, 4))),
@ -357,7 +357,7 @@
Some(("figure.accessory.danari.horns-0", (4, 8, 8))),]
),
(Danari, Female): (
offset: (-9.0, -4.0, -7.5),
offset: (-9.0, -4.0, -2.0),
head: ("figure.head.danari.female", (0, 2, 2)),
eyes: [
Some(("figure.eyes.general.female_default-0", (4, 9, 4))),

View File

@ -61,7 +61,7 @@ impl Animation for ClimbAnimation {
let stagnant = if speed > -0.7 { 1.0 } else { 0.0 }; //sets static position when there is no movement
if speed > 0.7 || lateral > 0.1 {
next.head.position = Vec3::new(0.0, -4.0 + s_a.head.0, s_a.head.1 + smootha * 0.2);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + smootha * 0.2);
next.head.orientation = Quaternion::rotation_z(smooth * 0.1)
* Quaternion::rotation_x(0.6)
* Quaternion::rotation_y(quick * 0.1);

View File

@ -76,6 +76,7 @@ impl Animation for GlidingAnimation {
anim_time as f32
};
next.head.position = Vec3::new(0.0, s_a.head.0 + 1.0, s_a.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);

View File

@ -61,7 +61,7 @@ impl Animation for JumpAnimation {
next.shoulder_r.scale = Vec3::one() * 1.1;
next.back.scale = Vec3::one() * 1.02;
next.head.position = Vec3::new(0.0, -1.0 + s_a.head.0, -1.0 + s_a.head.1);
next.head.position = Vec3::new(0.0, s_a.head.0, -1.0 + s_a.head.1);
next.head.orientation =
Quaternion::rotation_x(0.25 + slow * 0.04) * Quaternion::rotation_z(tilt * -2.5);

View File

@ -229,18 +229,18 @@ impl<'a> From<&'a Body> for SkeletonAttr {
(Danari, Female) => 1.15,
},
head: match (body.species, body.body_type) {
(Orc, Male) => (-2.0, 13.5),
(Orc, Female) => (-2.0, 13.0),
(Human, Male) => (-2.3, 13.0),
(Human, Female) => (-2.0, 13.0),
(Elf, Male) => (-2.5, 13.0),
(Elf, Female) => (-1.0, 13.0),
(Dwarf, Male) => (-2.0, 14.0),
(Dwarf, Female) => (-2.0, 13.5),
(Undead, Male) => (-1.5, 13.0),
(Undead, Female) => (-1.5, 14.0),
(Danari, Male) => (-1.5, 12.5),
(Danari, Female) => (-1.5, 13.5),
(Orc, Male) => (-2.0, 9.0),
(Orc, Female) => (-2.0, 9.5),
(Human, Male) => (-2.3, 9.5),
(Human, Female) => (-2.0, 9.5),
(Elf, Male) => (-2.5, 9.5),
(Elf, Female) => (-1.0, 9.5),
(Dwarf, Male) => (-2.0, 10.0),
(Dwarf, Female) => (-2.0, 9.5),
(Undead, Male) => (-1.5, 8.5),
(Undead, Female) => (-1.5, 9.5),
(Danari, Male) => (-1.5, 7.0),
(Danari, Female) => (-1.5, 7.0),
},
chest: match (body.species, body.body_type) {
(_, _) => (0.0, 8.0),

View File

@ -119,8 +119,7 @@ impl Animation for RunAnimation {
* 0.1,
);
next.head.position =
Vec3::new(0.0, -1.0 * speednorm + s_a.head.0, s_a.head.1 + short * 0.1);
next.head.position = Vec3::new(0.0, 1.0 * speednorm + s_a.head.0, s_a.head.1 + short * 0.1);
next.head.orientation =
Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.02)
* Quaternion::rotation_x(head_look.y + 0.45 * speednorm);

View File

@ -2,7 +2,7 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::{comp::item::ToolKind, states::utils::StageSection};
use common::{comp::item::ToolKind, states::utils::StageSection, util::Dir};
use std::f32::consts::PI;
pub struct ShootAnimation;
@ -13,6 +13,7 @@ type ShootAnimationDependency = (
f32,
Vec3<f32>,
Vec3<f32>,
Dir,
f64,
Option<StageSection>,
);
@ -33,6 +34,7 @@ impl Animation for ShootAnimation {
velocity,
orientation,
last_ori,
_look_dir,
_global_time,
stage_section,
): Self::Dependency,

View File

@ -93,8 +93,7 @@ impl Animation for SneakAnimation {
next.hand_r.position = Vec3::new(-1.0 + s_a.hand.0, -1.0 + s_a.hand.1, s_a.hand.2);
next.hand_r.orientation = Quaternion::rotation_x(0.4);
next.head.position =
Vec3::new(0.0, -1.0 + s_a.head.0, -1.0 + s_a.head.1 + short * 0.06);
next.head.position = Vec3::new(0.0, 1.0 + s_a.head.0, -1.0 + s_a.head.1 + short * 0.06);
next.head.orientation =
Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.06)
* Quaternion::rotation_x(head_look.y + 0.45);
@ -144,7 +143,7 @@ impl Animation for SneakAnimation {
} else {
next.head.position = Vec3::new(
0.0,
-1.0 + s_a.head.0,
1.0 + s_a.head.0,
-2.0 + s_a.head.1 + slow * 0.1 + breathe * -0.05,
);
next.head.orientation = Quaternion::rotation_z(head_look.x)

View File

@ -29,13 +29,14 @@ use common::{
comp::{
inventory::slot::EquipSlot,
item::{ItemKind, ToolKind},
Body, CharacterState, Health, Inventory, Item, Last, LightAnimation, LightEmitter, Ori,
PhysicsState, PoiseState, Pos, Scale, Vel,
Body, CharacterState, Controller, Health, Inventory, Item, Last, LightAnimation,
LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel,
},
resources::DeltaTime,
span,
states::utils::StageSection,
terrain::TerrainChunk,
util::Dir,
vol::RectRasterableVol,
};
use common_sys::state::State;
@ -543,6 +544,7 @@ impl FigureMgr {
(
entity,
pos,
controller,
interpolated,
vel,
scale,
@ -557,6 +559,7 @@ impl FigureMgr {
) in (
&ecs.entities(),
&ecs.read_storage::<Pos>(),
ecs.read_storage::<Controller>().maybe(),
ecs.read_storage::<Interpolated>().maybe(),
&ecs.read_storage::<Vel>(),
ecs.read_storage::<Scale>().maybe(),
@ -572,6 +575,9 @@ impl FigureMgr {
.enumerate()
{
let vel = (anim::vek::Vec3::<f32>::from(vel.0),);
let look_dir = controller
.map(|c| c.inputs.look_dir)
.unwrap_or(Dir::default());
let is_player = scene_data.player_entity == entity;
let player_camera_mode = if is_player {
camera_mode
@ -881,6 +887,7 @@ impl FigureMgr {
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
look_dir,
time,
Some(s.stage_section),
),
@ -912,6 +919,7 @@ impl FigureMgr {
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
look_dir,
time,
Some(s.stage_section),
),