pub struct MaterialDescriptor { /* private fields */ }Expand description
A descriptor for a future Material.
A MaterialDescriptor is used to construct a Material.
A Descriptor is a smiliar idea as a Builder,
but there is an important difference between which has to be adressed with a differen name.
A Builder would always construct a new instance of a struct, in this project meaning it cannot be used twice in the same KinematicTree.
Since using a Builder twice would result in two exactly the same objects.
A Descriptor on the other hand, first checks if there already exists an instance which matches it description, in this case a Material.
If not the case a new instance (Material) is constructed and added to the index.
If an instance already exists, which exactly matches the description, then the ‘new’ Material will refer to the pre-existing data.
This is desirable in the case of Materials, since they are often reused.
This could also allow for changing a Material and the other used of it changing withit.
§OLD STUFF TODO: UPDATE
When a MaterialDescriptor is constructed for a specific KinematicDataTee, the following steps happen:
- Check if the description of the
MaterialDescriptormatches a pre-existingMaterialalready in the tree.- If the a
Materialmatches the description, the reference to that material is returned. - If no
Materialmatches the desctiption, a newMaterialis constructed and inserted to thematerial_indexof theKinematicDataTreeand the reference is returned. - If only the
nameof theMaterialmatches, an error is raised.
- If the a
Implementations§
Source§impl MaterialDescriptor
impl MaterialDescriptor
Sourcepub fn new_color(red: f32, green: f32, blue: f32, alpha: f32) -> Self
pub fn new_color(red: f32, green: f32, blue: f32, alpha: f32) -> Self
Creates a new MaterialDescriptor with a solid color (rgba)
The red, green, blue and alpha fields expect a value between 0 and 1.
§Example
MaterialDescriptor::new_color(1., 0.4, 0.6, 0.5)Sourcepub fn new_rgb(red: f32, green: f32, blue: f32) -> Self
pub fn new_rgb(red: f32, green: f32, blue: f32) -> Self
Creates a new MaterialDescriptor with a solid color (rgb).
The red, green, blue fields expect a value between 0 and 1.
§Example
MaterialDescriptor::new_rgb(1., 0.4, 0.6)Sourcepub fn new_texture(texture_path: impl Into<String>) -> Self
pub fn new_texture(texture_path: impl Into<String>) -> Self
Creates a new MaterialDescriptor with a texture.
texture_path should be a valid package path (e.g. "package://NAME_OF_PACKAGE/path/{texture}"). You are on your own here.
§Example
MaterialDescriptor::new_texture("package://robot_description/textures/example_texture.png")Sourcepub fn named(self, name: impl Into<String>) -> Self
pub fn named(self, name: impl Into<String>) -> Self
Adds a name to the MaterialDescriptor, so it can later be used as a referenced Material.
§Important
When a named Material is used, it needs to be the same as all materials with the same name.
Otherwise, problems will arise later down the line.
§Example
MaterialDescriptor::new_rgb(0.5, 1., 0.5).named("soft-green")Source§impl MaterialDescriptor
Non-builder methods
impl MaterialDescriptor
Non-builder methods
Sourcepub fn name(&self) -> Option<&String>
pub fn name(&self) -> Option<&String>
Gets the optional of the MaterialDescriptor as a optional reference.
Sourcepub fn data(&self) -> &MaterialData
pub fn data(&self) -> &MaterialData
Gets a reference to the MaterialData of the MaterialDescriptor.
Trait Implementations§
Source§impl Clone for MaterialDescriptor
impl Clone for MaterialDescriptor
Source§fn clone(&self) -> MaterialDescriptor
fn clone(&self) -> MaterialDescriptor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MaterialDescriptor
impl Debug for MaterialDescriptor
Source§impl GroupIDChanger for MaterialDescriptor
impl GroupIDChanger for MaterialDescriptor
Source§unsafe fn change_group_id_unchecked(&mut self, new_group_id: &str)
unsafe fn change_group_id_unchecked(&mut self, new_group_id: &str)
Source§fn apply_group_id(&mut self)
fn apply_group_id(&mut self)
GroupID delimiter replacements. Read moreSource§fn change_group_id(
&mut self,
new_group_id: impl GroupID,
) -> Result<(), GroupIDError>
fn change_group_id( &mut self, new_group_id: impl GroupID, ) -> Result<(), GroupIDError>
Source§impl PartialEq for MaterialDescriptor
impl PartialEq for MaterialDescriptor
impl StructuralPartialEq for MaterialDescriptor
Auto Trait Implementations§
impl Freeze for MaterialDescriptor
impl RefUnwindSafe for MaterialDescriptor
impl Send for MaterialDescriptor
impl Sync for MaterialDescriptor
impl Unpin for MaterialDescriptor
impl UnwindSafe for MaterialDescriptor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.