Skip to content

Commit

Permalink
[#73] Add config
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Nov 5, 2023
1 parent 3925d7c commit 129f126
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 10 deletions.
4 changes: 2 additions & 2 deletions resources/characters/characters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
outerwear:
type: Cloak
length: Ankle
outer_color: Blue
inner_color: Blue
outer_color: Green
inner_color: Green
head:
ears:
type: Normal
Expand Down
1 change: 1 addition & 0 deletions rpg_tools_rendering/src/rendering/config/equipment/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pub mod belt;
pub mod eyewear;
pub mod footwear;
pub mod outerwear;
pub mod pants;
pub mod shirt;
11 changes: 11 additions & 0 deletions rpg_tools_rendering/src/rendering/config/equipment/outerwear.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// The rendering config of the [`outerwear`](rpg_tools_core::model::equipment::appearance::outerwear::Outerwear).
#[derive(Debug, PartialEq)]
pub struct OuterwearConfig {
pub top_y: f32,
pub curve_offset: f32,
pub double_breasted_offset: f32,
pub padding_cloak: f32,
pub padding_coat_hip: f32,
pub padding_coat_pants: f32,
pub zipper_width: f32,
}
10 changes: 10 additions & 0 deletions rpg_tools_rendering/src/rendering/config/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::rendering::config::ear::EarConfig;
use crate::rendering::config::equipment::belt::{BeltConfig, BuckleConfig};
use crate::rendering::config::equipment::eyewear::EyewearConfig;
use crate::rendering::config::equipment::footwear::FootwearConfig;
use crate::rendering::config::equipment::outerwear::OuterwearConfig;
use crate::rendering::config::equipment::pants::PantsConfig;
use crate::rendering::config::equipment::shirt::ShirtConfig;
use crate::rendering::config::eye::eyebrow::EyebrowConfig;
Expand Down Expand Up @@ -158,6 +159,15 @@ pub fn create_config() -> RenderConfig {
width_shaft: 1.05,
width_sole: 1.1,
},
outerwear: OuterwearConfig {
top_y: -0.05,
curve_offset: 0.01,
double_breasted_offset: 0.05,
padding_cloak: 0.2,
padding_coat_hip: 0.1,
padding_coat_pants: 0.03,
zipper_width: 2.0,
},
pants: PantsConfig {
height_bermuda: 0.5,
height_shorts: 0.3,
Expand Down
2 changes: 2 additions & 0 deletions rpg_tools_rendering/src/rendering/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::rendering::config::ear::EarConfig;
use crate::rendering::config::equipment::belt::BeltConfig;
use crate::rendering::config::equipment::eyewear::EyewearConfig;
use crate::rendering::config::equipment::footwear::FootwearConfig;
use crate::rendering::config::equipment::outerwear::OuterwearConfig;
use crate::rendering::config::equipment::pants::PantsConfig;
use crate::rendering::config::equipment::shirt::ShirtConfig;
use crate::rendering::config::eye::EyeConfig;
Expand Down Expand Up @@ -44,6 +45,7 @@ pub struct RenderConfig {
pub belt: BeltConfig,
pub eyewear: EyewearConfig,
pub footwear: FootwearConfig,
pub outerwear: OuterwearConfig,
pub pants: PantsConfig,
pub shirt: ShirtConfig,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ fn get_cloak_polygon(config: &RenderConfig, aabb: &AABB, body: &Body, cloak: &Cl
let torso = config.body.get_torso_config(body.shape);
let mut builder = Polygon2dBuilder::new();
let y_factor = get_bottom_y(config, body, cloak.length);
let shoulder_width = torso.shoulder_width + 0.2;
let shoulder_width = torso.shoulder_width + config.outerwear.padding_cloak;
let bottom_width = shoulder_width * config.body.get_torso_width(body);

builder.add_mirrored_points(&torso_aabb, shoulder_width, -0.05, false);
builder.add_mirrored_points(&torso_aabb, shoulder_width, config.outerwear.top_y, false);
builder.add_mirrored_points(&torso_aabb, shoulder_width, config.body.y_upper, false);
builder.add_mirrored_points(aabb, bottom_width, y_factor, true);
builder.add_point(aabb.get_point(0.5, y_factor - 0.01), false);
builder.add_point(
aabb.get_point(0.5, y_factor - config.outerwear.curve_offset),
false,
);

builder.build()
}
20 changes: 15 additions & 5 deletions rpg_tools_rendering/src/rendering/equipment/outerwear/coat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,30 @@ fn get_torso_polygon(
coat: &Coat,
from_front: bool,
) -> Polygon2d {
let mut builder = create_shirt(config, aabb, body, coat.neckline, from_front, 0.1);
let mut builder = create_shirt(
config,
aabb,
body,
coat.neckline,
from_front,
config.outerwear.padding_coat_hip,
);

builder.reverse();

let (pants_width, _inner_width) = config.pants.get_widths(&config.body, body);
let pants_width = pants_width + 0.03;
let pants_width = pants_width + config.outerwear.padding_coat_pants;
let hip_width =
config.pants.get_hip_width(&config.body, body) * config.body.get_torso_width(body);
let width = hip_width.max(pants_width);

let y = get_bottom_y(config, body, coat.length);

builder.add_mirrored_points(aabb, width, y, true);
builder.add_point(aabb.get_point(0.5, y + 0.01), false);
builder.add_point(
aabb.get_point(0.5, y + config.outerwear.curve_offset),
false,
);

builder.build()
}
Expand All @@ -89,7 +99,7 @@ fn render_closing(
render_buttons(renderer, config, aabb, buttons, top_y, bottom_y, 0.5)
}
ClosingOption::DoubleBreasted { buttons } => {
let offset = 0.05;
let offset = config.outerwear.double_breasted_offset;
render_buttons(
renderer,
config,
Expand All @@ -110,7 +120,7 @@ fn render_closing(
);
}
ClosingOption::Zipper { color } => {
let option = config.line_with_color(color, 2.0);
let option = config.line_with_color(color, config.outerwear.zipper_width);
let top = aabb.get_point(0.5, top_y);
let bottom = aabb.get_point(0.5, bottom_y);
let line = Line2d::new(vec![top, bottom]);
Expand Down

0 comments on commit 129f126

Please sign in to comment.