Add basic segment combination

This commit is contained in:
Imbris 2019-08-18 22:57:41 -04:00
parent 0668823493
commit ab34377309
13 changed files with 568 additions and 454 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/voxygen/voxel/armor/chest/generic.vox (Stored with Git LFS) Normal file

Binary file not shown.

BIN
assets/voxygen/voxel/figure/body/chest.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -2,7 +2,7 @@ use crate::vol::Vox;
use vek::*;
/// A type representing a single voxel in a figure.
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Cell {
Filled([u8; 3]),
Empty,

View File

@ -2,7 +2,8 @@ pub mod cell;
use self::cell::Cell;
use crate::{
vol::{Vox, WriteVol},
util::chromify_srgb,
vol::{ReadVol, SizedVol, Vox, WriteVol},
volumes::dyna::Dyna,
};
use dot_vox::DotVoxData;
@ -44,3 +45,65 @@ impl From<&DotVoxData> for Segment {
}
}
}
impl Segment {
/// Create a new `Segment` by combining two existing ones
pub fn union(&self, other: &Self, other_offset: Vec3<i32>) -> Self {
let size = self.get_size();
let other_size = self.get_size();
let new_size = other_offset
.map2(other_size, |oo, os| (oo, os))
.map2(size, |(oo, os), s| {
(oo + os as i32).max(s as i32) - oo.min(0)
})
.map(|e| e as u32);
let mut combined = Segment::filled(new_size, Cell::empty(), ());
// Copy self into combined
let offset = other_offset.map(|e| e.min(0).abs());
for pos in self.iter_positions() {
if let Cell::Filled(col) = *self.get(pos).unwrap() {
combined.set(pos + offset, Cell::Filled(col)).unwrap();
}
}
// Copy other into combined
let offset = other_offset.map(|e| e.max(0));
for pos in other.iter_positions() {
if let Cell::Filled(col) = *other.get(pos).unwrap() {
combined.set(pos + offset, Cell::Filled(col)).unwrap();
}
}
combined
}
/// Replaces one cell with another
pub fn replace(mut self, old: Cell, new: Cell) -> Self {
for pos in self.iter_positions() {
if old == *self.get(pos).unwrap() {
self.set(pos, new);
}
}
self
}
/// Preserve the luminance of all the colors but set the chomaticity to match the provided color
pub fn chromify(mut self, chroma: Rgb<u8>) -> Self {
let chroma = chroma.map(|e| e as f32 * 255.0);
for pos in self.iter_positions() {
match self.get(pos).unwrap() {
Cell::Filled(rgb) => self
.set(
pos,
Cell::Filled(
chromify_srgb(Rgb::from_slice(rgb).map(|e| e as f32 / 255.0), chroma)
.map(|e| (e * 255.0) as u8)
.into_array(),
),
)
.unwrap(),
Cell::Empty => (),
}
}
self
}
}

View File

@ -1,6 +1,6 @@
pub const GIT_HASH: &str = include_str!(concat!(env!("OUT_DIR"), "/githash"));
use vek::{Rgb, Rgba, Vec3};
use vek::{Mat3, Rgb, Rgba, Vec3};
#[inline(always)]
pub fn srgb_to_linear(col: Rgb<f32>) -> Rgb<f32> {
@ -91,6 +91,32 @@ pub fn hsv_to_rgb(hsv: Vec3<f32>) -> Rgb<f32> {
Rgb::new(r + m, g + m, b + m)
}
/// Convert linear rgb to CIExyY
#[inline(always)]
pub fn rgb_to_xyy(rgb: Rgb<f32>) -> Vec3<f32> {
// XYZ
let xyz = Mat3::new(
0.4124, 0.3576, 0.1805, 0.2126, 0.7152, 0.0722, 0.0193, 0.1192, 0.9504,
) * Vec3::from(rgb);
let sum = xyz.sum();
Vec3::new(xyz.x / sum, xyz.y / sum, xyz.y)
}
/// Convert to CIExyY to linear rgb
#[inline(always)]
pub fn xyy_to_rgb(xyy: Vec3<f32>) -> Rgb<f32> {
let xyz = Vec3::new(
xyy.z / xyy.y * xyy.x,
xyy.z,
xyy.z / xyy.y * (1.0 - xyy.x - xyy.y),
);
Rgb::from(
Mat3::new(
3.2406, -1.5372, -0.4986, -0.9689, 1.8758, 0.0415, 0.0557, -0.2040, 1.0570,
) * xyz,
)
}
#[inline(always)]
pub fn saturate_srgb(col: Rgb<f32>, value: f32) -> Rgb<f32> {
@ -98,3 +124,13 @@ pub fn saturate_srgb(col: Rgb<f32>, value: f32) -> Rgb<f32> {
hsv.y *= 1.0 + value;
linear_to_srgb(hsv_to_rgb(hsv).map(|e| e.min(1.0).max(0.0)))
}
/// Preserves the luma of one color while changing its chromaticty to match the other
#[inline(always)]
pub fn chromify_srgb(luma: Rgb<f32>, chroma: Rgb<f32>) -> Rgb<f32> {
let l = rgb_to_xyy(srgb_to_linear(luma)).z;
let mut xyy = rgb_to_xyy(srgb_to_linear(chroma));
xyy.z = l;
linear_to_srgb(xyy_to_rgb(xyy).map(|e| e.min(1.0).max(0.0)))
}

View File

@ -36,7 +36,7 @@ use crate::{
window::Window,
};
use heaptrack::track_mem;
use log::{self, debug, error, info, warn};
use log::{self, debug, error, info};
use simplelog::{CombinedLogger, Config, TermLogger, TerminalMode, WriteLogger};
use std::{fs::File, mem, panic, str::FromStr};

View File

@ -10,7 +10,7 @@ use crate::{
},
scene::{
camera::{Camera, CameraMode},
figure::{FigureModelCache, FigureState},
figure::{load_mesh, FigureModelCache, FigureState},
},
};
use client::Client;
@ -69,7 +69,7 @@ impl Scene {
figure_state: FigureState::new(renderer, CharacterSkeleton::new()),
backdrop_model: renderer
.create_model(&FigureModelCache::load_mesh(
.create_model(&load_mesh(
"fixture.selection_bg",
Vec3::new(-55.0, -49.5, -2.0),
))

View File

@ -70,30 +70,30 @@ impl FigureModelCache {
{
let bone_meshes = match body {
Body::Humanoid(body) => [
Some(Self::load_head(body.race, body.body_type)),
Some(Self::load_chest(body.chest)),
Some(Self::load_belt(body.belt)),
Some(Self::load_pants(body.pants)),
Some(Self::load_left_hand(body.hand)),
Some(Self::load_right_hand(body.hand)),
Some(Self::load_left_foot(body.foot)),
Some(Self::load_right_foot(body.foot)),
Some(Self::load_main(equipment.and_then(|e| e.main.as_ref()))),
Some(Self::load_left_shoulder(body.shoulder)),
Some(Self::load_right_shoulder(body.shoulder)),
Some(Self::load_draw()),
Some(load_head(body.race, body.body_type)),
Some(load_chest(body.chest)),
Some(load_belt(body.belt)),
Some(load_pants(body.pants)),
Some(load_left_hand(body.hand)),
Some(load_right_hand(body.hand)),
Some(load_left_foot(body.foot)),
Some(load_right_foot(body.foot)),
Some(load_main(equipment.and_then(|e| e.main.as_ref()))),
Some(load_left_shoulder(body.shoulder)),
Some(load_right_shoulder(body.shoulder)),
Some(load_draw()),
None,
None,
None,
None,
],
Body::Quadruped(body) => [
Some(Self::load_pig_head(body.head)),
Some(Self::load_pig_chest(body.chest)),
Some(Self::load_pig_leg_lf(body.leg_l)),
Some(Self::load_pig_leg_rf(body.leg_r)),
Some(Self::load_pig_leg_lb(body.leg_l)),
Some(Self::load_pig_leg_rb(body.leg_r)),
Some(load_pig_head(body.head)),
Some(load_pig_chest(body.chest)),
Some(load_pig_leg_lf(body.leg_l)),
Some(load_pig_leg_rf(body.leg_r)),
Some(load_pig_leg_lb(body.leg_l)),
Some(load_pig_leg_rb(body.leg_r)),
None,
None,
None,
@ -106,17 +106,17 @@ impl FigureModelCache {
None,
],
Body::QuadrupedMedium(body) => [
Some(Self::load_wolf_head_upper(body.head_upper)),
Some(Self::load_wolf_jaw(body.jaw)),
Some(Self::load_wolf_head_lower(body.head_lower)),
Some(Self::load_wolf_tail(body.tail)),
Some(Self::load_wolf_torso_back(body.torso_back)),
Some(Self::load_wolf_torso_mid(body.torso_mid)),
Some(Self::load_wolf_ears(body.ears)),
Some(Self::load_wolf_foot_lf(body.foot_lf)),
Some(Self::load_wolf_foot_rf(body.foot_rf)),
Some(Self::load_wolf_foot_lb(body.foot_lb)),
Some(Self::load_wolf_foot_rb(body.foot_rb)),
Some(load_wolf_head_upper(body.head_upper)),
Some(load_wolf_jaw(body.jaw)),
Some(load_wolf_head_lower(body.head_lower)),
Some(load_wolf_tail(body.tail)),
Some(load_wolf_torso_back(body.torso_back)),
Some(load_wolf_torso_mid(body.torso_mid)),
Some(load_wolf_ears(body.ears)),
Some(load_wolf_foot_lf(body.foot_lf)),
Some(load_wolf_foot_rf(body.foot_rf)),
Some(load_wolf_foot_lb(body.foot_lb)),
Some(load_wolf_foot_rb(body.foot_rb)),
None,
None,
None,
@ -124,7 +124,7 @@ impl FigureModelCache {
None,
],
Body::Object(object) => [
Some(Self::load_object(object)),
Some(load_object(object)),
None,
None,
None,
@ -175,419 +175,443 @@ impl FigureModelCache {
self.models
.retain(|_, (_, last_used)| *last_used + 60 > tick);
}
}
// TODO: Don't make this public.
pub fn load_mesh(mesh_name: &str, position: Vec3<f32>) -> Mesh<FigurePipeline> {
let full_specifier: String = ["voxygen.voxel.", mesh_name].concat();
Meshable::<FigurePipeline, FigurePipeline>::generate_mesh(
&Segment::from(assets::load_expect::<DotVoxData>(full_specifier.as_str()).as_ref()),
position,
)
.0
}
fn load_segment(mesh_name: &str) -> Segment {
let full_specifier: String = ["voxygen.voxel.", mesh_name].concat();
Segment::from(assets::load_expect::<DotVoxData>(full_specifier.as_str()).as_ref())
}
// TODO: Don't make this public.
pub fn load_mesh(mesh_name: &str, position: Vec3<f32>) -> Mesh<FigurePipeline> {
Meshable::<FigurePipeline, FigurePipeline>::generate_mesh(&load_segment(mesh_name), position).0
}
fn load_head(race: humanoid::Race, body_type: humanoid::BodyType) -> Mesh<FigurePipeline> {
use humanoid::{BodyType::*, Race::*};
fn load_head(race: humanoid::Race, body_type: humanoid::BodyType) -> Mesh<FigurePipeline> {
use humanoid::{BodyType, Race};
let (name, offset) = match (race, body_type) {
// z-value should be 0.25 of the total z
(Human, Male) => ("figure.head.head_human_male", Vec3::new(-7.0, -5.0, -2.25)),
(Human, Female) => (
"figure.head.head_human_female",
Vec3::new(-7.0, -7.5, -3.25),
),
(Elf, Male) => ("figure.head.head_elf_male", Vec3::new(-8.0, -5.0, -2.25)),
(Elf, Female) => ("figure.head.head_elf_female", Vec3::new(-8.0, -5.5, -3.0)),
(Dwarf, Male) => ("figure.head.head_dwarf_male", Vec3::new(-6.0, -5.0, -12.5)),
(Dwarf, Female) => (
"figure.head.head_dwarf_female",
Vec3::new(-6.0, -6.0, -9.25),
),
(Orc, Male) => ("figure.head.head_orc_male", Vec3::new(-8.0, -5.0, -2.50)),
(Orc, Female) => ("figure.head.head_orc_female", Vec3::new(-8.0, -8.0, -3.5)),
(Undead, Male) => ("figure.head.head_undead_male", Vec3::new(-5.5, -5.0, -2.5)),
(Undead, Female) => (
"figure.head.head_undead_female",
Vec3::new(-6.0, -5.0, -2.5),
),
(Danari, Male) => ("figure.head.head_danari_male", Vec3::new(-9.0, -5.0, -2.75)),
(Danari, Female) => (
"figure.head.head_danari_female",
Vec3::new(-9.0, -7.5, -3.0),
),
};
Self::load_mesh(name, offset)
}
// loads models with different offsets
// fn load_beard(beard: Beard) -> Mesh<FigurePipeline> {
// let (name, offset) = match beard {
// Beard::None => ("figure/body/empty", Vec3::new(0.0, 0.0, 0.0)),
// Beard::Human1 => ("figure/empty", Vec3::new(0.0, 0.0, 0.0)),
// };
// Self::load_mesh(name, offset)
// }
fn load_chest(chest: humanoid::Chest) -> Mesh<FigurePipeline> {
use humanoid::Chest::*;
Self::load_mesh(
match chest {
Blue => "armor.chest.chest_blue",
Brown => "armor.chest.chest_brown",
Dark => "armor.chest.chest_dark",
Green => "armor.chest.chest_green",
Orange => "armor.chest.chest_orange",
},
Vec3::new(-6.0, -3.5, 0.0),
)
}
fn load_belt(belt: humanoid::Belt) -> Mesh<FigurePipeline> {
use humanoid::Belt::*;
Self::load_mesh(
match belt {
//Belt::Default => "figure/body/belt_male",
Dark => "armor.belt.belt_dark",
},
Vec3::new(-5.0, -3.5, 0.0),
)
}
fn load_pants(pants: humanoid::Pants) -> Mesh<FigurePipeline> {
use humanoid::Pants::*;
Self::load_mesh(
match pants {
Blue => "armor.pants.pants_blue",
Brown => "armor.pants.pants_brown",
Dark => "armor.pants.pants_dark",
Green => "armor.pants.pants_green",
Orange => "armor.pants.pants_orange",
},
Vec3::new(-5.0, -3.5, 0.0),
)
}
fn load_left_hand(hand: humanoid::Hand) -> Mesh<FigurePipeline> {
Self::load_mesh(
match hand {
humanoid::Hand::Default => "figure.body.hand",
},
Vec3::new(-2.0, -2.5, -2.0),
)
}
fn load_right_hand(hand: humanoid::Hand) -> Mesh<FigurePipeline> {
Self::load_mesh(
match hand {
humanoid::Hand::Default => "figure.body.hand",
},
Vec3::new(-2.0, -2.5, -2.0),
)
}
fn load_left_foot(foot: humanoid::Foot) -> Mesh<FigurePipeline> {
use humanoid::Foot::*;
Self::load_mesh(
match foot {
Dark => "armor.foot.foot_dark",
},
Vec3::new(-2.5, -3.5, -9.0),
)
}
fn load_right_foot(foot: humanoid::Foot) -> Mesh<FigurePipeline> {
use humanoid::Foot::*;
Self::load_mesh(
match foot {
Dark => "armor.foot.foot_dark",
},
Vec3::new(-2.5, -3.5, -9.0),
)
}
fn load_main(item: Option<&Item>) -> Mesh<FigurePipeline> {
if let Some(item) = item {
let (name, offset) = match item {
Item::Tool { kind, .. } => match kind {
Tool::Sword => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)),
Tool::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)),
Tool::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::Daggers => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::SwordShield => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)),
Tool::Bow => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::Staff => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)),
},
Item::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)),
_ => ("figure.empty", Vec3::default()),
};
Self::load_mesh(name, offset)
} else {
Self::load_mesh("figure.empty", Vec3::default())
let (name, offset) = match (race, body_type) {
// z-value should be 0.25 of the total z
(Race::Human, BodyType::Male) => {
("figure.head.head_human_male", Vec3::new(-7.0, -5.0, -2.25))
}
}
(Race::Human, BodyType::Female) => (
"figure.head.head_human_female",
Vec3::new(-7.0, -7.5, -3.25),
),
(Race::Elf, BodyType::Male) => ("figure.head.head_elf_male", Vec3::new(-8.0, -5.0, -2.25)),
(Race::Elf, BodyType::Female) => {
("figure.head.head_elf_female", Vec3::new(-8.0, -5.5, -3.0))
}
(Race::Dwarf, BodyType::Male) => {
("figure.head.head_dwarf_male", Vec3::new(-6.0, -5.0, -12.5))
}
(Race::Dwarf, BodyType::Female) => (
"figure.head.head_dwarf_female",
Vec3::new(-6.0, -6.0, -9.25),
),
(Race::Orc, BodyType::Male) => ("figure.head.head_orc_male", Vec3::new(-8.0, -5.0, -2.50)),
(Race::Orc, BodyType::Female) => {
("figure.head.head_orc_female", Vec3::new(-8.0, -8.0, -3.5))
}
(Race::Undead, BodyType::Male) => {
("figure.head.head_undead_male", Vec3::new(-5.5, -5.0, -2.5))
}
(Race::Undead, BodyType::Female) => (
"figure.head.head_undead_female",
Vec3::new(-6.0, -5.0, -2.5),
),
(Race::Danari, BodyType::Male) => {
("figure.head.head_danari_male", Vec3::new(-9.0, -5.0, -2.75))
}
(Race::Danari, BodyType::Female) => (
"figure.head.head_danari_female",
Vec3::new(-9.0, -7.5, -3.0),
),
};
load_mesh(name, offset)
}
// loads models with different offsets
// fn load_beard(beard: Beard) -> Mesh<FigurePipeline> {
// let (name, offset) = match beard {
// Beard::None => ("figure/body/empty", Vec3::new(0.0, 0.0, 0.0)),
// Beard::Human1 => ("figure/empty", Vec3::new(0.0, 0.0, 0.0)),
// };
// load_mesh(name, offset)
// }
fn load_left_shoulder(shoulder: humanoid::Shoulder) -> Mesh<FigurePipeline> {
Self::load_mesh(
match shoulder {
humanoid::Shoulder::None => "figure.empty",
humanoid::Shoulder::Brown1 => "armor.shoulder.shoulder_l_brown",
fn load_chest(chest: humanoid::Chest) -> Mesh<FigurePipeline> {
use humanoid::Chest;
let color = match chest {
Chest::Brown => (125, 53, 0),
Chest::Dark => (0, 38, 43),
Chest::Green => (0, 255, 34),
Chest::Orange => (255, 106, 0),
Chest::Blue => (0, 38, 255),
};
let bare_chest = load_segment("figure.body.chest");
let chest_armor = load_segment("armor.chest.generic");
let chest = bare_chest.union(&chest_armor.chromify(Rgb::from(color)), Vec3::new(0, 0, 0));
Meshable::<FigurePipeline, FigurePipeline>::generate_mesh(&chest, Vec3::new(-6.0, -3.5, 0.0)).0
}
fn load_belt(belt: humanoid::Belt) -> Mesh<FigurePipeline> {
use humanoid::Belt;
load_mesh(
match belt {
//Belt::Default => "figure/body/belt_male",
Belt::Dark => "armor.belt.belt_dark",
},
Vec3::new(-5.0, -3.5, 0.0),
)
}
fn load_pants(pants: humanoid::Pants) -> Mesh<FigurePipeline> {
use humanoid::Pants;
load_mesh(
match pants {
Pants::Blue => "armor.pants.pants_blue",
Pants::Brown => "armor.pants.pants_brown",
Pants::Dark => "armor.pants.pants_dark",
Pants::Green => "armor.pants.pants_green",
Pants::Orange => "armor.pants.pants_orange",
},
Vec3::new(-5.0, -3.5, 0.0),
)
}
fn load_left_hand(hand: humanoid::Hand) -> Mesh<FigurePipeline> {
load_mesh(
match hand {
humanoid::Hand::Default => "figure.body.hand",
},
Vec3::new(-2.0, -2.5, -2.0),
)
}
fn load_right_hand(hand: humanoid::Hand) -> Mesh<FigurePipeline> {
load_mesh(
match hand {
humanoid::Hand::Default => "figure.body.hand",
},
Vec3::new(-2.0, -2.5, -2.0),
)
}
fn load_left_foot(foot: humanoid::Foot) -> Mesh<FigurePipeline> {
use humanoid::Foot;
load_mesh(
match foot {
Foot::Dark => "armor.foot.foot_dark",
},
Vec3::new(-2.5, -3.5, -9.0),
)
}
fn load_right_foot(foot: humanoid::Foot) -> Mesh<FigurePipeline> {
use humanoid::Foot;
load_mesh(
match foot {
Foot::Dark => "armor.foot.foot_dark",
},
Vec3::new(-2.5, -3.5, -9.0),
)
}
fn load_main(item: Option<&Item>) -> Mesh<FigurePipeline> {
if let Some(item) = item {
let (name, offset) = match item {
Item::Tool { kind, .. } => match kind {
Tool::Sword => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)),
Tool::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -5.0, -4.0)),
Tool::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::Daggers => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::SwordShield => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)),
Tool::Bow => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::Staff => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)),
},
Vec3::new(-2.5, -3.5, -1.5),
)
}
fn load_right_shoulder(shoulder: humanoid::Shoulder) -> Mesh<FigurePipeline> {
Self::load_mesh(
match shoulder {
humanoid::Shoulder::None => "figure.empty",
humanoid::Shoulder::Brown1 => "armor.shoulder.shoulder_r_brown",
},
Vec3::new(-2.5, -3.5, -1.5),
)
}
// TODO: Inventory
fn load_draw() -> Mesh<FigurePipeline> {
Self::load_mesh("object.glider", Vec3::new(-26.0, -26.0, -5.0))
}
//fn load_right_equip(hand: humanoid::Hand) -> Mesh<FigurePipeline> {
// Self::load_mesh(
// match hand {
// humanoid::Hand::Default => "figure/body/hand",
// },
// Vec3::new(-2.0, -2.5, -5.0),
// )
//}
/////////
fn load_pig_head(head: quadruped::Head) -> Mesh<FigurePipeline> {
Self::load_mesh(
match head {
quadruped::Head::Default => "npc.pig_purple.pig_head",
},
Vec3::new(-6.0, 4.5, 3.0),
)
}
fn load_pig_chest(chest: quadruped::Chest) -> Mesh<FigurePipeline> {
Self::load_mesh(
match chest {
quadruped::Chest::Default => "npc.pig_purple.pig_chest",
},
Vec3::new(-5.0, 4.5, 0.0),
)
}
fn load_pig_leg_lf(leg_l: quadruped::LegL) -> Mesh<FigurePipeline> {
Self::load_mesh(
match leg_l {
quadruped::LegL::Default => "npc.pig_purple.pig_leg_l",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
fn load_pig_leg_rf(leg_r: quadruped::LegR) -> Mesh<FigurePipeline> {
Self::load_mesh(
match leg_r {
quadruped::LegR::Default => "npc.pig_purple.pig_leg_r",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
fn load_pig_leg_lb(leg_l: quadruped::LegL) -> Mesh<FigurePipeline> {
Self::load_mesh(
match leg_l {
quadruped::LegL::Default => "npc.pig_purple.pig_leg_l",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
fn load_pig_leg_rb(leg_r: quadruped::LegR) -> Mesh<FigurePipeline> {
Self::load_mesh(
match leg_r {
quadruped::LegR::Default => "npc.pig_purple.pig_leg_r",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
//////
fn load_wolf_head_upper(upper_head: quadruped_medium::HeadUpper) -> Mesh<FigurePipeline> {
Self::load_mesh(
match upper_head {
quadruped_medium::HeadUpper::Default => "npc.wolf.wolf_head_upper",
},
Vec3::new(-7.0, -6.0, -5.5),
)
}
fn load_wolf_jaw(jaw: quadruped_medium::Jaw) -> Mesh<FigurePipeline> {
Self::load_mesh(
match jaw {
quadruped_medium::Jaw::Default => "npc.wolf.wolf_jaw",
},
Vec3::new(-3.0, -3.0, -2.5),
)
}
fn load_wolf_head_lower(head_lower: quadruped_medium::HeadLower) -> Mesh<FigurePipeline> {
Self::load_mesh(
match head_lower {
quadruped_medium::HeadLower::Default => "npc.wolf.wolf_head_lower",
},
Vec3::new(-7.0, -6.0, -5.5),
)
}
fn load_wolf_tail(tail: quadruped_medium::Tail) -> Mesh<FigurePipeline> {
Self::load_mesh(
match tail {
quadruped_medium::Tail::Default => "npc.wolf.wolf_tail",
},
Vec3::new(-2.0, -12.0, -5.0),
)
}
fn load_wolf_torso_back(torso_back: quadruped_medium::TorsoBack) -> Mesh<FigurePipeline> {
Self::load_mesh(
match torso_back {
quadruped_medium::TorsoBack::Default => "npc.wolf.wolf_torso_back",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
fn load_wolf_torso_mid(torso_mid: quadruped_medium::TorsoMid) -> Mesh<FigurePipeline> {
Self::load_mesh(
match torso_mid {
quadruped_medium::TorsoMid::Default => "npc.wolf.wolf_torso_mid",
},
Vec3::new(-8.0, -5.5, -6.0),
)
}
fn load_wolf_ears(ears: quadruped_medium::Ears) -> Mesh<FigurePipeline> {
Self::load_mesh(
match ears {
quadruped_medium::Ears::Default => "npc.wolf.wolf_ears",
},
Vec3::new(-4.0, -1.0, -1.0),
)
}
fn load_wolf_foot_lf(foot_lf: quadruped_medium::FootLF) -> Mesh<FigurePipeline> {
Self::load_mesh(
match foot_lf {
quadruped_medium::FootLF::Default => "npc.wolf.wolf_foot_lf",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_wolf_foot_rf(foot_rf: quadruped_medium::FootRF) -> Mesh<FigurePipeline> {
Self::load_mesh(
match foot_rf {
quadruped_medium::FootRF::Default => "npc.wolf.wolf_foot_rf",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_wolf_foot_lb(foot_lb: quadruped_medium::FootLB) -> Mesh<FigurePipeline> {
Self::load_mesh(
match foot_lb {
quadruped_medium::FootLB::Default => "npc.wolf.wolf_foot_lb",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_wolf_foot_rb(foot_rb: quadruped_medium::FootRB) -> Mesh<FigurePipeline> {
Self::load_mesh(
match foot_rb {
quadruped_medium::FootRB::Default => "npc.wolf.wolf_foot_rb",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_object(obj: object::Body) -> Mesh<FigurePipeline> {
let (name, offset) = match obj {
object::Body::Bomb => ("object.bomb", Vec3::new(-5.5, -5.5, 0.0)),
object::Body::Scarecrow => ("object.scarecrow", Vec3::new(-9.5, -4.0, 0.0)),
object::Body::Cauldron => ("object.cauldron", Vec3::new(-10.0, -10.0, 0.0)),
object::Body::ChestVines => ("object.chest_vines", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::Chest => ("object.chest", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestDark => ("object.chest_dark", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestDemon => ("object.chest_demon", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestGold => ("object.chest_gold", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestLight => ("object.chest_light", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestOpen => ("object.chest_open", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestSkull => ("object.chest_skull", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::Pumpkin => ("object.pumpkin", Vec3::new(-5.5, -4.0, 0.0)),
object::Body::Pumpkin2 => ("object.pumpkin_2", Vec3::new(-5.0, -4.0, 0.0)),
object::Body::Pumpkin3 => ("object.pumpkin_3", Vec3::new(-5.0, -4.0, 0.0)),
object::Body::Pumpkin4 => ("object.pumpkin_4", Vec3::new(-5.0, -4.0, 0.0)),
object::Body::Pumpkin5 => ("object.pumpkin_5", Vec3::new(-4.0, -5.0, 0.0)),
object::Body::Campfire => ("object.campfire", Vec3::new(-9.0, -10.0, 0.0)),
object::Body::LanternGround => ("object.lantern_ground", Vec3::new(-3.5, -3.5, 0.0)),
object::Body::LanternGroundOpen => {
("object.lantern_ground_open", Vec3::new(-3.5, -3.5, 0.0))
}
object::Body::LanternStanding => {
("object.lantern_standing", Vec3::new(-7.5, -3.5, 0.0))
}
object::Body::LanternStanding2 => {
("object.lantern_standing_2", Vec3::new(-11.5, -3.5, 0.0))
}
object::Body::PotionRed => ("object.potion_red", Vec3::new(-2.0, -2.0, 0.0)),
object::Body::PotionBlue => ("object.potion_blue", Vec3::new(-2.0, -2.0, 0.0)),
object::Body::PotionGreen => ("object.potion_green", Vec3::new(-2.0, -2.0, 0.0)),
object::Body::Crate => ("object.crate", Vec3::new(-7.0, -7.0, 0.0)),
object::Body::Tent => ("object.tent", Vec3::new(-18.5, -19.5, 0.0)),
object::Body::WindowSpooky => ("object.window_spooky", Vec3::new(-15.0, -1.5, -1.0)),
object::Body::DoorSpooky => ("object.door_spooky", Vec3::new(-15.0, -4.5, 0.0)),
object::Body::Table => ("object.table", Vec3::new(-12.0, -8.0, 0.0)),
object::Body::Table2 => ("object.table_2", Vec3::new(-8.0, -8.0, 0.0)),
object::Body::Table3 => ("object.table_3", Vec3::new(-10.0, -10.0, 0.0)),
object::Body::Drawer => ("object.drawer", Vec3::new(-11.0, -7.5, 0.0)),
object::Body::BedBlue => ("object.bed_human_blue", Vec3::new(-11.0, -15.0, 0.0)),
object::Body::Anvil => ("object.anvil", Vec3::new(-3.0, -7.0, 0.0)),
object::Body::Gravestone => ("object.gravestone", Vec3::new(-5.0, -2.0, 0.0)),
object::Body::Gravestone2 => ("object.gravestone_2", Vec3::new(-8.5, -3.0, 0.0)),
object::Body::Chair => ("object.chair", Vec3::new(-5.0, -4.5, 0.0)),
object::Body::Chair2 => ("object.chair_2", Vec3::new(-5.0, -4.5, 0.0)),
object::Body::Chair3 => ("object.chair_3", Vec3::new(-5.0, -4.5, 0.0)),
object::Body::Bench => ("object.bench", Vec3::new(-8.8, -5.0, 0.0)),
object::Body::Carpet => ("object.carpet", Vec3::new(-14.0, -14.0, -0.5)),
object::Body::Bedroll => ("object.bedroll", Vec3::new(-11.0, -19.5, -0.5)),
object::Body::CarpetHumanRound => {
("object.carpet_human_round", Vec3::new(-14.0, -14.0, -0.5))
}
object::Body::CarpetHumanSquare => {
("object.carpet_human_square", Vec3::new(-13.5, -14.0, -0.5))
}
object::Body::CarpetHumanSquare2 => (
"object.carpet_human_square_2",
Vec3::new(-13.5, -14.0, -0.5),
),
object::Body::CarpetHumanSquircle => (
"object.carpet_human_squircle",
Vec3::new(-21.0, -21.0, -0.5),
),
object::Body::Pouch => ("object.pouch", Vec3::new(-5.5, -4.5, 0.0)),
Item::Debug(_) => ("weapon.debug_wand", Vec3::new(-1.5, -9.5, -4.0)),
_ => ("figure.empty", Vec3::default()),
};
Self::load_mesh(name, offset)
load_mesh(name, offset)
} else {
load_mesh("figure.empty", Vec3::default())
}
}
fn load_weapon(weapon: Tool) -> Mesh<FigurePipeline> {
let (name, offset) = match weapon {
Tool::Sword => ("weapon.sword.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)),
Tool::Axe => ("weapon.axe.rusty_2h", Vec3::new(-1.5, -6.5, -4.0)),
Tool::Hammer => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::Daggers => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::SwordShield => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)),
Tool::Bow => ("weapon.hammer.rusty_2h", Vec3::new(-2.5, -5.5, -4.0)),
Tool::Staff => ("weapon.axe.rusty_2h", Vec3::new(-2.5, -6.5, -2.0)),
};
load_mesh(name, offset)
}
fn load_left_shoulder(shoulder: humanoid::Shoulder) -> Mesh<FigurePipeline> {
load_mesh(
match shoulder {
humanoid::Shoulder::None => "figure.empty",
humanoid::Shoulder::Brown1 => "armor.shoulder.shoulder_l_brown",
},
Vec3::new(-2.5, -3.5, -1.5),
)
}
fn load_right_shoulder(shoulder: humanoid::Shoulder) -> Mesh<FigurePipeline> {
load_mesh(
match shoulder {
humanoid::Shoulder::None => "figure.empty",
humanoid::Shoulder::Brown1 => "armor.shoulder.shoulder_r_brown",
},
Vec3::new(-2.5, -3.5, -1.5),
)
}
// TODO: Inventory
fn load_draw() -> Mesh<FigurePipeline> {
load_mesh("object.glider", Vec3::new(-26.0, -26.0, -5.0))
}
//fn load_right_equip(hand: humanoid::Hand) -> Mesh<FigurePipeline> {
// load_mesh(
// match hand {
// humanoid::Hand::Default => "figure/body/hand",
// },
// Vec3::new(-2.0, -2.5, -5.0),
// )
//}
/////////
fn load_pig_head(head: quadruped::Head) -> Mesh<FigurePipeline> {
load_mesh(
match head {
quadruped::Head::Default => "npc.pig_purple.pig_head",
},
Vec3::new(-6.0, 4.5, 3.0),
)
}
fn load_pig_chest(chest: quadruped::Chest) -> Mesh<FigurePipeline> {
load_mesh(
match chest {
quadruped::Chest::Default => "npc.pig_purple.pig_chest",
},
Vec3::new(-5.0, 4.5, 0.0),
)
}
fn load_pig_leg_lf(leg_l: quadruped::LegL) -> Mesh<FigurePipeline> {
load_mesh(
match leg_l {
quadruped::LegL::Default => "npc.pig_purple.pig_leg_l",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
fn load_pig_leg_rf(leg_r: quadruped::LegR) -> Mesh<FigurePipeline> {
load_mesh(
match leg_r {
quadruped::LegR::Default => "npc.pig_purple.pig_leg_r",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
fn load_pig_leg_lb(leg_l: quadruped::LegL) -> Mesh<FigurePipeline> {
load_mesh(
match leg_l {
quadruped::LegL::Default => "npc.pig_purple.pig_leg_l",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
fn load_pig_leg_rb(leg_r: quadruped::LegR) -> Mesh<FigurePipeline> {
load_mesh(
match leg_r {
quadruped::LegR::Default => "npc.pig_purple.pig_leg_r",
},
Vec3::new(0.0, -1.0, -1.5),
)
}
//////
fn load_wolf_head_upper(upper_head: quadruped_medium::HeadUpper) -> Mesh<FigurePipeline> {
load_mesh(
match upper_head {
quadruped_medium::HeadUpper::Default => "npc.wolf.wolf_head_upper",
},
Vec3::new(-7.0, -6.0, -5.5),
)
}
fn load_wolf_jaw(jaw: quadruped_medium::Jaw) -> Mesh<FigurePipeline> {
load_mesh(
match jaw {
quadruped_medium::Jaw::Default => "npc.wolf.wolf_jaw",
},
Vec3::new(-3.0, -3.0, -2.5),
)
}
fn load_wolf_head_lower(head_lower: quadruped_medium::HeadLower) -> Mesh<FigurePipeline> {
load_mesh(
match head_lower {
quadruped_medium::HeadLower::Default => "npc.wolf.wolf_head_lower",
},
Vec3::new(-7.0, -6.0, -5.5),
)
}
fn load_wolf_tail(tail: quadruped_medium::Tail) -> Mesh<FigurePipeline> {
load_mesh(
match tail {
quadruped_medium::Tail::Default => "npc.wolf.wolf_tail",
},
Vec3::new(-2.0, -12.0, -5.0),
)
}
fn load_wolf_torso_back(torso_back: quadruped_medium::TorsoBack) -> Mesh<FigurePipeline> {
load_mesh(
match torso_back {
quadruped_medium::TorsoBack::Default => "npc.wolf.wolf_torso_back",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
fn load_wolf_torso_mid(torso_mid: quadruped_medium::TorsoMid) -> Mesh<FigurePipeline> {
load_mesh(
match torso_mid {
quadruped_medium::TorsoMid::Default => "npc.wolf.wolf_torso_mid",
},
Vec3::new(-8.0, -5.5, -6.0),
)
}
fn load_wolf_ears(ears: quadruped_medium::Ears) -> Mesh<FigurePipeline> {
load_mesh(
match ears {
quadruped_medium::Ears::Default => "npc.wolf.wolf_ears",
},
Vec3::new(-4.0, -1.0, -1.0),
)
}
fn load_wolf_foot_lf(foot_lf: quadruped_medium::FootLF) -> Mesh<FigurePipeline> {
load_mesh(
match foot_lf {
quadruped_medium::FootLF::Default => "npc.wolf.wolf_foot_lf",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_wolf_foot_rf(foot_rf: quadruped_medium::FootRF) -> Mesh<FigurePipeline> {
load_mesh(
match foot_rf {
quadruped_medium::FootRF::Default => "npc.wolf.wolf_foot_rf",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_wolf_foot_lb(foot_lb: quadruped_medium::FootLB) -> Mesh<FigurePipeline> {
load_mesh(
match foot_lb {
quadruped_medium::FootLB::Default => "npc.wolf.wolf_foot_lb",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_wolf_foot_rb(foot_rb: quadruped_medium::FootRB) -> Mesh<FigurePipeline> {
load_mesh(
match foot_rb {
quadruped_medium::FootRB::Default => "npc.wolf.wolf_foot_rb",
},
Vec3::new(-2.5, -4.0, -2.5),
)
}
fn load_object(obj: object::Body) -> Mesh<FigurePipeline> {
let (name, offset) = match obj {
object::Body::Bomb => ("object.bomb", Vec3::new(-5.5, -5.5, 0.0)),
object::Body::Scarecrow => ("object.scarecrow", Vec3::new(-9.5, -4.0, 0.0)),
object::Body::Cauldron => ("object.cauldron", Vec3::new(-10.0, -10.0, 0.0)),
object::Body::ChestVines => ("object.chest_vines", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::Chest => ("object.chest", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestDark => ("object.chest_dark", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestDemon => ("object.chest_demon", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestGold => ("object.chest_gold", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestLight => ("object.chest_light", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestOpen => ("object.chest_open", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::ChestSkull => ("object.chest_skull", Vec3::new(-7.5, -6.0, 0.0)),
object::Body::Pumpkin => ("object.pumpkin", Vec3::new(-5.5, -4.0, 0.0)),
object::Body::Pumpkin2 => ("object.pumpkin_2", Vec3::new(-5.0, -4.0, 0.0)),
object::Body::Pumpkin3 => ("object.pumpkin_3", Vec3::new(-5.0, -4.0, 0.0)),
object::Body::Pumpkin4 => ("object.pumpkin_4", Vec3::new(-5.0, -4.0, 0.0)),
object::Body::Pumpkin5 => ("object.pumpkin_5", Vec3::new(-4.0, -5.0, 0.0)),
object::Body::Campfire => ("object.campfire", Vec3::new(-9.0, -10.0, 0.0)),
object::Body::LanternGround => ("object.lantern_ground", Vec3::new(-3.5, -3.5, 0.0)),
object::Body::LanternGroundOpen => {
("object.lantern_ground_open", Vec3::new(-3.5, -3.5, 0.0))
}
object::Body::LanternStanding => ("object.lantern_standing", Vec3::new(-7.5, -3.5, 0.0)),
object::Body::LanternStanding2 => {
("object.lantern_standing_2", Vec3::new(-11.5, -3.5, 0.0))
}
object::Body::PotionRed => ("object.potion_red", Vec3::new(-2.0, -2.0, 0.0)),
object::Body::PotionBlue => ("object.potion_blue", Vec3::new(-2.0, -2.0, 0.0)),
object::Body::PotionGreen => ("object.potion_green", Vec3::new(-2.0, -2.0, 0.0)),
object::Body::Crate => ("object.crate", Vec3::new(-7.0, -7.0, 0.0)),
object::Body::Tent => ("object.tent", Vec3::new(-18.5, -19.5, 0.0)),
object::Body::WindowSpooky => ("object.window_spooky", Vec3::new(-15.0, -1.5, -1.0)),
object::Body::DoorSpooky => ("object.door_spooky", Vec3::new(-15.0, -4.5, 0.0)),
object::Body::Table => ("object.table", Vec3::new(-12.0, -8.0, 0.0)),
object::Body::Table2 => ("object.table_2", Vec3::new(-8.0, -8.0, 0.0)),
object::Body::Table3 => ("object.table_3", Vec3::new(-10.0, -10.0, 0.0)),
object::Body::Drawer => ("object.drawer", Vec3::new(-11.0, -7.5, 0.0)),
object::Body::BedBlue => ("object.bed_human_blue", Vec3::new(-11.0, -15.0, 0.0)),
object::Body::Anvil => ("object.anvil", Vec3::new(-3.0, -7.0, 0.0)),
object::Body::Gravestone => ("object.gravestone", Vec3::new(-5.0, -2.0, 0.0)),
object::Body::Gravestone2 => ("object.gravestone_2", Vec3::new(-8.5, -3.0, 0.0)),
object::Body::Chair => ("object.chair", Vec3::new(-5.0, -4.5, 0.0)),
object::Body::Chair2 => ("object.chair_2", Vec3::new(-5.0, -4.5, 0.0)),
object::Body::Chair3 => ("object.chair_3", Vec3::new(-5.0, -4.5, 0.0)),
object::Body::Bench => ("object.bench", Vec3::new(-8.8, -5.0, 0.0)),
object::Body::Carpet => ("object.carpet", Vec3::new(-14.0, -14.0, -0.5)),
object::Body::Bedroll => ("object.bedroll", Vec3::new(-11.0, -19.5, -0.5)),
object::Body::CarpetHumanRound => {
("object.carpet_human_round", Vec3::new(-14.0, -14.0, -0.5))
}
object::Body::CarpetHumanSquare => {
("object.carpet_human_square", Vec3::new(-13.5, -14.0, -0.5))
}
object::Body::CarpetHumanSquare2 => (
"object.carpet_human_square_2",
Vec3::new(-13.5, -14.0, -0.5),
),
object::Body::CarpetHumanSquircle => (
"object.carpet_human_squircle",
Vec3::new(-21.0, -21.0, -0.5),
),
object::Body::Pouch => ("object.pouch", Vec3::new(-5.5, -4.5, 0.0)),
};
load_mesh(name, offset)
}
pub struct FigureMgr {
model_cache: FigureModelCache,
character_states: HashMap<EcsEntity, FigureState<CharacterSkeleton>>,