pub struct MaterialGraph {
pub nodes: Vec<MatNode>,
pub textures: [String; 3],
pub next_id: u32,
pub mode: GraphMode,
}Expand description
A whole material.
Fields§
§nodes: Vec<MatNode>All nodes, including the single Output node.
textures: [String; 3]Images bound to the Texture node slots: albedo, normal map, ORM (occlusion/roughness/metallic).
next_id: u32Next free node id.
mode: GraphModeWhat the graph produces.
Implementations§
Source§impl MaterialGraph
impl MaterialGraph
Sourcepub fn default_graph() -> Self
pub fn default_graph() -> Self
A new graph with only an Output node (grey, rough).
Sourcepub fn default_graph_for(mode: GraphMode) -> Self
pub fn default_graph_for(mode: GraphMode) -> Self
A starter graph for the given kind: the result node plus one connected node.
Sourcepub fn add_node(&mut self, kind: &str, pos: [f32; 2]) -> u32
pub fn add_node(&mut self, kind: &str, pos: [f32; 2]) -> u32
Adds a node of a known type with its default values.
Sourcepub fn connect(&mut self, from: u32, to: u32, input: usize) -> bool
pub fn connect(&mut self, from: u32, to: u32, input: usize) -> bool
Connects from’s main output to input input of node to. Returns false for self-links or cycles.
Sourcepub fn connect_output(
&mut self,
from: u32,
output: u8,
to: u32,
input: usize,
convert: u8,
) -> bool
pub fn connect_output( &mut self, from: u32, output: u8, to: u32, input: usize, convert: u8, ) -> bool
Connects output output of from to input input of to, converting with convert
(see crate::material_nodes_v4::CONVERSIONS).
Sourcepub fn remove_node(&mut self, id: u32)
pub fn remove_node(&mut self, id: u32)
Removes a node (the Output node stays) and every link that used it.
Trait Implementations§
Source§impl Clone for MaterialGraph
impl Clone for MaterialGraph
Source§fn clone(&self) -> MaterialGraph
fn clone(&self) -> MaterialGraph
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MaterialGraph
impl Debug for MaterialGraph
Source§impl Default for MaterialGraph
impl Default for MaterialGraph
Source§impl<'de> Deserialize<'de> for MaterialGraphwhere
MaterialGraph: Default,
impl<'de> Deserialize<'de> for MaterialGraphwhere
MaterialGraph: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MaterialGraph
impl PartialEq for MaterialGraph
Source§impl Serialize for MaterialGraph
impl Serialize for MaterialGraph
impl StructuralPartialEq for MaterialGraph
Auto Trait Implementations§
impl Freeze for MaterialGraph
impl RefUnwindSafe for MaterialGraph
impl Send for MaterialGraph
impl Sync for MaterialGraph
impl Unpin for MaterialGraph
impl UnsafeUnpin for MaterialGraph
impl UnwindSafe for MaterialGraph
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
Converts
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> ⓘ
Converts
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 moreimpl<T> MaybeSync for T
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.