Skip to content

Commit

Permalink
[#42] Start sole rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 23, 2023
1 parent 345290d commit 34e40e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
16 changes: 12 additions & 4 deletions rpg_tools_rendering/src/rendering/body/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub fn render_body(renderer: &mut dyn Renderer, config: &RenderConfig, aabb: &AA
let options = config.get_skin_options(&body.skin);

render_legs(renderer, config, aabb, body, &options);
render_feet(renderer, config, aabb, body, &options);
render_arms(renderer, config, aabb, body, &options);
render_torso(renderer, config, aabb, body, &options);
}
Expand All @@ -39,15 +40,22 @@ fn render_legs(

render_leg(renderer, options, left_leg_start, leg_size);
render_leg(renderer, options, right_leg_start, leg_size);
}

let left_foot_center = aabb.get_point(left_leg_start_x + leg_width / 2.0, foot_y);
let right_foot_center = aabb.get_point(right_leg_x + leg_width / 2.0, foot_y);
fn render_feet(
renderer: &mut dyn Renderer,
config: &RenderConfig,
aabb: &AABB,
body: &Body,
options: &RenderOptions,
) {
let (left_center, right_center) = config.body.get_feet_centers(body, aabb);
let foot_radius = config.body.get_foot_radius(body, aabb);
let offset = Orientation::from_degree(0.0);
let angle = Orientation::from_degree(180.0);

renderer.render_circle_arc(&left_foot_center, foot_radius, offset, angle, options);
renderer.render_circle_arc(&right_foot_center, foot_radius, offset, angle, options);
renderer.render_circle_arc(&left_center, foot_radius, offset, angle, options);
renderer.render_circle_arc(&right_center, foot_radius, offset, angle, options);
}

pub fn render_hands(renderer: &mut dyn Renderer, config: &RenderConfig, aabb: &AABB, body: &Body) {
Expand Down
12 changes: 12 additions & 0 deletions rpg_tools_rendering/src/rendering/config/body/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::math::aabb2d::{get_end_x, get_start_x, AABB};
use crate::math::point2d::Point2d;
use crate::rendering::config::body::torso::TorsoConfig;
use crate::rendering::config::width::WidthConfig;
use rpg_tools_core::model::character::appearance::body::{Body, BodyShape};
Expand Down Expand Up @@ -117,6 +118,17 @@ impl BodyConfig {
* self.get_torso_config(body.shape).legs_width
}

pub fn get_feet_centers(&self, body: &Body, aabb: &AABB) -> (Point2d, Point2d) {
let leg_half = self.get_leg_width(body) / 2.0;
let foot_y = self.get_foot_y();
let left_leg_start_x = self.get_left_leg_x(body);
let right_leg_x = self.get_right_leg_x(body);
let left = aabb.get_point(left_leg_start_x + leg_half, foot_y);
let right = aabb.get_point(right_leg_x + leg_half, foot_y);

(left, right)
}

pub fn get_left_leg_x(&self, body: &Body) -> f32 {
let legs_width = self.get_legs_width(body);
let leg_width = self.get_leg_width(body);
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/src/rendering/equipment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ pub fn render_clothing(
{
render_shirt(renderer, config, aabb, body, shirt, from_front);
render_pants(renderer, config, aabb, body, pants);
render_footwear(renderer, config, aabb, body, footwear);
render_footwear(renderer, config, aabb, body, footwear, from_front);
}
}

0 comments on commit 34e40e2

Please sign in to comment.