Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icons for location tags #141

Merged
merged 5 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/textures/battery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions assets/textures/battery.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/parking.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions assets/textures/parking.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/textures/stopwatch.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 113 additions & 0 deletions assets/textures/stopwatch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions rmf_site_editor/src/shapes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,19 @@ pub(crate) fn make_ring(inner_radius: f32, outer_radius: f32, resolution: usize)
MeshBuffer::new(positions, normals, indices)
}

pub(crate) fn make_location_icon(radius: f32, height: f32, segments: usize) -> MeshBuffer {
let height = 2.0 * height;
let angle = (360.0 / (2.0 * segments as f32)).to_radians();
let p0 = radius * Vec3::X;
let p1 = Affine3A::from_rotation_z(angle).transform_vector3(p0);
let width = (p1 - p0).length();
make_flat_square_mesh(width).transform_by(Affine3A::from_translation(Vec3::new(
radius + width / 2.0,
0.0,
height / 2.0,
)))
}

pub(crate) fn make_icon_halo(radius: f32, height: f32, segments: usize) -> MeshBuffer {
let angle = (360.0 / (2.0 * segments as f32)).to_radians();
let p0 = radius * Vec3::X;
Expand Down
23 changes: 23 additions & 0 deletions rmf_site_editor/src/site/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,24 @@ pub struct SiteAssets {
pub physical_camera_material: Handle<StandardMaterial>,
pub occupied_material: Handle<StandardMaterial>,
pub default_mesh_grey_material: Handle<StandardMaterial>,
pub location_tag_mesh: Handle<Mesh>,
pub charger_material: Handle<StandardMaterial>,
pub holding_point_material: Handle<StandardMaterial>,
pub parking_material: Handle<StandardMaterial>,
}

impl FromWorld for SiteAssets {
fn from_world(world: &mut World) -> Self {
let asset_server = world.get_resource::<AssetServer>().unwrap();
let charger_texture = asset_server.load(&String::from(&AssetSource::Bundled(
"textures/battery.png".to_string(),
)));
let holding_point_texture = asset_server.load(&String::from(&AssetSource::Bundled(
"textures/stopwatch.png".to_string(),
)));
let parking_texture = asset_server.load(&String::from(&AssetSource::Bundled(
"textures/parking.png".to_string(),
)));

let mut materials = world
.get_resource_mut::<Assets<StandardMaterial>>()
Expand Down Expand Up @@ -138,6 +151,10 @@ impl FromWorld for SiteAssets {
let occupied_material = materials.add(Color::rgba(0.8, 0.1, 0.1, 0.2).into());
let default_mesh_grey_material = materials.add(Color::rgb(0.7, 0.7, 0.7).into());

let charger_material = materials.add(charger_texture.into());
let holding_point_material = materials.add(holding_point_texture.into());
let parking_material = materials.add(parking_texture.into());

let mut meshes = world.get_resource_mut::<Assets<Mesh>>().unwrap();
let level_anchor_mesh = meshes.add(
Mesh::from(shape::UVSphere {
Expand Down Expand Up @@ -200,6 +217,8 @@ impl FromWorld for SiteAssets {
.with_generated_outline_normals()
.unwrap(),
);
let location_tag_mesh =
meshes.add(make_location_icon(1.1 * LANE_WIDTH / 2.0, 0.01, 6).into());
let physical_camera_mesh = meshes.add(
make_physical_camera_mesh()
.with_generated_outline_normals()
Expand Down Expand Up @@ -238,6 +257,10 @@ impl FromWorld for SiteAssets {
physical_camera_material,
occupied_material,
default_mesh_grey_material,
location_tag_mesh,
charger_material,
holding_point_material,
parking_material,
}
}
}
Expand Down
Loading