Skip to content

Commit

Permalink
[#72] Render neckline
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 17, 2023
1 parent c8522ad commit a4a9f5d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
8 changes: 4 additions & 4 deletions rpg_tools_rendering/src/rendering/body/torso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ pub fn render_torso(
pub fn create_torso(aabb: &AABB, config: &BodyConfig, torso: &TorsoConfig) -> Polygon2dBuilder {
let mut builder = Polygon2dBuilder::new();

builder.add_mirrored_points(&aabb, torso.shoulder_width, 0.0, false);
builder.add_mirrored_points(&aabb, torso.shoulder_width, config.y_upper, false);
builder.add_mirrored_points(&aabb, torso.waist_width, config.y_waist, false);
builder.add_mirrored_points(&aabb, torso.hip_width, config.y_lower, false);
builder.add_mirrored_points(&aabb, torso.hip_width, 1.0, false);
builder.add_mirrored_points(&aabb, torso.hip_width, config.y_lower, false);
builder.add_mirrored_points(&aabb, torso.waist_width, config.y_waist, false);
builder.add_mirrored_points(&aabb, torso.shoulder_width, config.y_upper, false);
builder.add_mirrored_points(&aabb, torso.shoulder_width, 0.0, false);

builder
}
35 changes: 28 additions & 7 deletions rpg_tools_rendering/src/rendering/equipment/shirt.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use crate::math::aabb2d::AABB;
use crate::math::polygon2d::builder::Polygon2dBuilder;
use crate::renderer::Renderer;
use crate::rendering::body::torso::create_torso;
use crate::rendering::config::body::torso::TorsoConfig;
use crate::rendering::config::body::BodyConfig;
use crate::rendering::config::RenderConfig;
use rpg_tools_core::model::character::appearance::body::Body;
use rpg_tools_core::model::equipment::appearance::shirt::Shirt;
use rpg_tools_core::model::equipment::appearance::shirt::{Neckline, Shirt};

pub fn render_shirt(
renderer: &mut dyn Renderer,
Expand All @@ -14,11 +17,29 @@ pub fn render_shirt(
) {
let options = config.get_options(shirt.color);
let torso_aabb = config.body.get_torso_aabb(body, aabb);
let polygon = create_torso(
&torso_aabb,
&config.body,
config.body.get_torso_config(body.shape),
)
.build();
let torso = config.body.get_torso_config(body.shape);
let mut builder = create_torso(&torso_aabb, &config.body, torso);
add_neckline(config, &torso_aabb, torso, shirt, &mut builder);
let polygon = builder.build();
renderer.render_rounded_polygon(&polygon, &options);
}

fn add_neckline(
config: &RenderConfig,
aabb: &AABB,
torso: &TorsoConfig,
shirt: &Shirt,
builder: &mut Polygon2dBuilder,
) {
match shirt.neckline {
Neckline::Boat => {}
Neckline::Crew => {
let crew_width = torso.shoulder_width / 3.0;
builder.add_mirrored_points(&aabb, crew_width, 0.0, true);
builder.add_mirrored_points(&aabb, crew_width, 0.1, false);
}
Neckline::DeepV => {}
Neckline::Scoop => {}
Neckline::V => {}
}
}

0 comments on commit a4a9f5d

Please sign in to comment.