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) .

Apply materials to nodes#
# get all structural models
nodeIndexer = SAMSON.getNodes('node.type sm')

# make the operation undoable
SAMSON.beginHolding("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)

# stop holding
SAMSON.endHolding()

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.

Apply appearance preset to a material#
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: SBReferenceTarget

This class describes a material.

Overloaded function.

  1. __init__(self: samson.SBNodeMaterial) -> None

Constructs a material with default parameters and no color scheme.

  1. __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

  1. __init__(self: samson.SBNodeMaterial, color: samson.SBColor) -> None

Constructs a material based on the given color. The color is set via the constant color scheme (SBColorSchemeConstant).

Parameters:

color (samson.SBColor) – The color

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:

samson.SBNodeColorScheme

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#

Sets the color for the material. The color is set via the constant color scheme (SBColorSchemeConstant).

Parameters:

color (samson.SBColor) – A color.

Returns:

Returns True if it could set the color, else returns False.

Return type:

bool

setColorScheme(self: samson.SBNodeMaterial, colorScheme: samson.SBNodeColorScheme) bool#

Sets the color scheme. The color scheme is cloned internally, since the material owns the color scheme.

Parameters:

colorScheme (samson.SBNodeColorScheme) – The color scheme.

Returns:

Returns True if it could set the color scheme, else returns False.

Return type:

bool

setEmissionColor(self: samson.SBNodeMaterial, emissionColor: samson.SBColor) None#

Sets the emission color

setMaterialAppearance(self: samson.SBNodeMaterial, materialAppearance: samson.SBNodeMaterialAppearance) None#

Sets the material appearance parameters for this material based on materialAppearance.

Parameters:

materialAppearance (SBNodeMaterialAppearance) – A material appearance.

Examples

Set the ‘Metallic: Copper’ appearance 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.