SBNodeMaterial#
Data graph nodes in SAMSON may have materials that apply to themselves and their descendants (if the descendants do not have their own materials).
Materials are used to modify the visual appearance of data graph nodes. Each material has:
an associated color scheme (
SBNodeColorScheme) to color nodes in a specific way, e.g. by residue, chain, or based on some node properties (e.g., charge, temperature factor, occupancy, etc.), or no color scheme to apply the default colorization;appearance properties used when rendering nodes using path tracing (the Trace command) .
# get all structural models
nodeIndexer = SAMSON.getNodes('node.type sm')
# make the operation undoable
with SAMSON.holding("Add material"):
# apply the color scheme to nodes
for node in nodeIndexer:
# [optional] remove existing materials from the descendants
node.removeMaterialsFromDescendants()
# create a color scheme per residue type
# by providing the node indexer of residues to the color scheme constructor
# we allow it to determine the color range based on the min and max residue types
colorScheme = SBColorSchemePerResidueType(nodeIndexer)
# create a material with the color scheme
material = SBNodeMaterial()
material.setColorScheme(colorScheme)
# set the material to the node
node.setMaterial(material)
You can set the appearance properties based on available appearance presets using the SBNodeMaterial.setMaterialAppearance() function.
You can find all the default material appearance presets in the SBNodeMaterialAppearance class.
material.setMaterialAppearance(SBNodeMaterialAppearance.metallicCopper)
Note
Materials (and, hence, color schemes that are part of materials) take precedence based on hierarchy: if the node has a material applied directly to it, then it will be colorized based on this material’s color scheme, else it will be colorized based on a color scheme of its parent node’s material. If none of the node’s parents has a material with a color scheme then a default colorization will be applied, e.g. CPK colors for atoms.
To remove materials from a node and its descendants call the SBNode.removeMaterialsFromDescendants() function on the node.
- class samson.SBNodeMaterial(*args, **kwargs)#
Bases:
SBReferenceTargetThis class describes a material.
Overloaded function.
__init__(self: samson.SBNodeMaterial) -> None
Constructs a material with default parameters and no color scheme.
__init__(self: samson.SBNodeMaterial, colorScheme: samson.SBNodeColorScheme) -> None
Constructs a material based on the given color scheme. The color scheme is cloned internally, since the material owns the color scheme.
- Parameters:
colorScheme (samson.SBNodeColorScheme) – The color scheme
__init__(self: samson.SBNodeMaterial, color: samson.SBColor) -> None
Construct a material with a constant color scheme.
The constructor creates a constant color scheme
SBColorSchemeConstantinternally and makes the new material own it.- Parameters:
color (samson.SBColor) – Color assigned to the material.
- clone(self: samson.SBNodeMaterial) samson.SBNodeMaterial#
Returns a copy of the material
- getColorScheme(self: samson.SBNodeMaterial) samson.SBNodeColorScheme#
Returns the material’s color scheme. The material always has a color scheme.
- Returns:
The material’s color scheme.
- Return type:
- getEmissionColor(self: samson.SBNodeMaterial) samson.SBColor#
Returns the emission color
- getMaterialAppearance(self: samson.SBNodeMaterial) samson.SBNodeMaterialAppearance#
Returns the material appearance
- getNode(self: samson.SBNodeMaterial) samson.SBNode#
Returns the node that owns the material
- getSubsurfaceColor(self: samson.SBNodeMaterial) samson.SBColor#
Returns the subsurface color
- getSubsurfaceRadius(self: samson.SBNodeMaterial) samson.SBPhysicalVector3#
Returns the subsurface radius
- setColor(self: samson.SBNodeMaterial, color: samson.SBColor) bool#
Set the material to a constant color.
This replaces the current color scheme with an internally created
SBColorSchemeConstant.- Parameters:
color (samson.SBColor) – Color assigned to the material.
- Returns:
Trueif the constant color scheme was installed, otherwiseFalse.- Return type:
bool
- setColorScheme(self: samson.SBNodeMaterial, colorScheme: samson.SBNodeColorScheme) bool#
Set the material color scheme.
The color scheme is cloned internally because the material owns its color scheme.
- Parameters:
colorScheme (samson.SBNodeColorScheme) – Color scheme to clone into the material.
- Returns:
Trueif the color scheme was set, otherwiseFalse.- Return type:
bool
- setEmissionColor(self: samson.SBNodeMaterial, emissionColor: samson.SBColor) None#
Sets the emission color
- setMaterialAppearance(self: samson.SBNodeMaterial, materialAppearance: samson.SBNodeMaterialAppearance) None#
Set this material from a predefined appearance.
- Parameters:
materialAppearance (samson.SBNodeMaterialAppearance) – Appearance preset whose parameters are copied into this material.
Examples
Set the
Metallic: Copperappearance preset:>>> material.setMaterialAppearance(SBNodeMaterialAppearance.metallicCopper)
- setSubsurfaceColor(self: samson.SBNodeMaterial, emissionColor: samson.SBColor) None#
Sets the subsurface color
- setSubsurfaceRadius(self: samson.SBNodeMaterial, subsurfaceRadius: samson.SBPhysicalVector3) None#
Sets the subsurface radius
- property anisotropicCoefficient#
The anisotropic coefficient.
- property anisotropicRotation#
The anisotropic rotation.
- property clearcoatCoefficient#
The clearcoat coefficient.
- property clearcoatRoughness#
The clearcoat roughness.
- property emissionStrength#
The emission strength.
- property isSerializable#
Returns True when the class is serializable
- property metallicCoefficient#
The metallic coefficient.
- property roughnessCoefficient#
The roughness coefficient.
- property sheenCoefficient#
The sheen coefficient.
- property sheenTint#
The sheen tint.
- property specularCoefficient#
The specular coefficient.
- property specularTint#
The specular tint.
- property subsurfaceAnisotropy#
The subsurface anisotropy.
- property subsurfaceCoefficient#
The subsurface coefficient.
- property subsurfaceIOR#
The subsurface index of refraction (IOR).
- property transmissionCoefficient#
The transmission coefficient.
- property transmissionIOR#
The transmission index of refraction (IOR).
- property transmissionRoughness#
The transmission roughness.
- property transparency#
The transparency.