Alembic::AbcMaterial

AbcMaterial is a module which sits above Abc. It is not dependent upon AbcGeom – nor is AbcGeom currently dependent upon it. It provides schema and object types for representing materials and material bindings.

Explanation of terms

target: a string representing a target application or renderer by name and agreed-upon convention. Examples include “prman,” “arnold” and “maya.” The library could also include a document of conventions for interchange via a reserved “abc” target value. (More on this later).

shader type: a string representing a shader classification by name and agreed-upon convention. Examples include “surface,” “displacement” and “light.” This could also express things like “coshader_taco” in which the value text following the “coshader_” prefix is used as a coshader instance name.

shader name: a string identifying a shader object within a specified target and shader type. Examples include “paintedplastic” and “spot_light_v12.”

assignment: binding of a material object onto another object via an alembic object path

inheritance/flattening: combining the contributions of multiple material definitions. The common case is the flattening of a hierarchy of material objects following assignment. It can also reference to the combination of a locally defined material with that of an assigned material.

struct Connection

Public Functions

Connection(const std::string &iInputName, const std::string &iConnectedNodeName, const std::string &iConnectedOutputName)
bool operator==(const Connection &iRhs) const

Public Members

std::string inputName
std::string connectedNodeName
std::string connectedOutputName
class IMaterialSchema
#include <IMaterial.h>

Schema for reading and querying shader definitions from either an object or compound property. Only “monolithic” shader definitions (i.e. non network) are presently supported in this implementation.

Public Types

typedef IMaterialSchema this_type

Public Functions

IMaterialSchema()
template <class CPROP_PTR>
IMaterialSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument())
template <class CPROP_PTR>
IMaterialSchema(CPROP_PTR iParent, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument())

This constructor is the same as above, but with default schema name used.

template <class CPROP_PTR>
IMaterialSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument())

Wrap an existing schema object.

IMaterialSchema(const IMaterialSchema &iCopy)

Copy constructor.

void getTargetNames(std::vector<std::string> &iTargetNames)

Fills a list of target name strings for which either shader or parameter definitions are locally present. Target name values match an upon convention for a renderer or application (i.e. “prman”) This gets the target names for the monolithic shaders

void getShaderTypesForTarget(const std::string &iTargetName, std::vector<std::string> &oShaderTypeNames)

Fills a list of shader type strings for which either shader or parameter definitions are locally present for a given target. Shader type names match an agreed upon convention for shader terminals such as “surface,” “displacement,” “light”, “coshader_somename.”

bool getShader(const std::string &iTarget, const std::string &iShaderType, std::string &oResult)

Returns true and fills result with the shader name for a given target and shaderType if locally defined

Abc::ICompoundProperty getShaderParameters(const std::string &iTarget, const std::string &iShaderType)

Returns the enclosing compound property for the given target and shader type. Call .valid() on the result to determine whether it’s locally defined or not.

size_t getNumNetworkNodes()
void getNetworkNodeNames(std::vector<std::string> &oNames)
NetworkNode getNetworkNode(size_t iIndex)
NetworkNode getNetworkNode(const std::string &iNodeName)
void getNetworkTerminalTargetNames(std::vector<std::string> &oTargetNames)
void getNetworkTerminalShaderTypesForTarget(const std::string &iTargetName, std::vector<std::string> &oShaderTypeNames)
bool getNetworkTerminal(const std::string &iTarget, const std::string &iShaderType, std::string &oNodeName, std::string &oOutputName)
size_t getNumNetworkInterfaceParameterMappings()
bool getNetworkInterfaceParameterMapping(size_t iIndex, std::string &oInterfaceParamName, std::string &oMapToNodeName, std::string &oMapToParamName)
void getNetworkInterfaceParameterMappingNames(std::vector<std::string> &oNames)
bool getNetworkInterfaceParameterMapping(const std::string &iInterfaceParamName, std::string &oMapToNodeName, std::string &oMapToParamName)
Abc::ICompoundProperty getNetworkInterfaceParameters()

Private Functions

void init()

Private Members

std::map<std::string, std::string> m_shaderNames
std::map<std::string, std::string> m_terminals
std::map<std::string, std::string> m_interfaceMap
std::vector<std::string> m_interface
Abc::ICompoundProperty m_interfaceParams
Abc::ICompoundProperty m_node
class MaterialFlatten
#include <MaterialFlatten.h>

Utility class for querying against flattened inheritance hierarchies or definitions.

Public Types

typedef std::vector<ParameterEntry> ParameterEntryVector
typedef std::map<std::string, std::string> StringMap
typedef Alembic::Util::shared_ptr<StringMap> StringMapPtr
typedef std::vector<IMaterialSchema> SchemaVector

Public Functions

MaterialFlatten()

Create empty. Use append to add material schema manually.

MaterialFlatten(IMaterialSchema iMaterialSchema)

Create with a single materialSchema.

MaterialFlatten(IMaterial iMaterialObject)

Create from a material object. The schemas of matching parent material objects are automatically append

MaterialFlatten(Abc::IObject iObject, Abc::IArchive iAlternateSearchArchive = Abc::IArchive())

Create from an IObject. This will interpret values for hasMaterial and getMaterialAssignmentPath to flatten the full assignment and inheritance chain. A locally present material is first in the inheritance path. A material assignment is then appended with IMaterial rules.

An alternate archive can be optionally specified. If provided, assigned material paths will be traversed within that archive instead of the archive of the object itself.

void append(IMaterialSchema iMaterialSchema)

Manually append a schema to the inheritance hierarchy.

void append(IMaterial iMaterialObject)

Append the schemas of matching parent material objects.

bool empty()

Returns true is there are no schema in the inheritance path.

void getTargetNames(std::vector<std::string> &oTargetNames)

Fill the list with a union of target names defined within the inheritance hierarchy

void getShaderTypesForTarget(const std::string &iTargetName, std::vector<std::string> &oShaderTypeNames)

Fill the list with a union of shader types define for the specified target within the inheritance hierarchy

bool getShader(const std::string &iTarget, const std::string &iShaderType, std::string &oResult)

Returns true and fills result with the shader name of first defined for the target and shaderType within the inheritance hierarchy. False if not defined.

void getShaderParameters(const std::string &iTarget, const std::string &iShaderType, ParameterEntryVector &oResult)

Fills result with the parent compound and property header for shader parameters defined for the target and shader type within the inheritance hierarchy. Shallower definitions mask deeper ones (i.e. you’ll only get one entry for a given name)

void getNetworkTerminalTargetNames(std::vector<std::string> &iTargetNames)

network stuff

void getNetworkTerminalShaderTypesForTarget(const std::string &iTargetName, std::vector<std::string> &oShaderTypeNames)
bool getNetworkTerminal(const std::string &iTarget, const std::string &iShaderType, std::string &oNodeName, std::string &oOutputName)
size_t getNumNetworkNodes()
NetworkNode getNetworkNode(size_t iIndex)
NetworkNode getNetworkNode(const std::string &iNodeName)

Private Types

typedef std::map<std::string, StringMapPtr> StringMapMap

Private Functions

void flattenNetwork()

Private Members

SchemaVector m_schemas
bool m_networkFlattened
std::vector<std::string> m_nodeNames
StringMapMap m_nodesToInterfaceMappings
class NetworkNode

Public Functions

NetworkNode()
NetworkNode(Abc::ICompoundProperty iCompound)
NetworkNode(Abc::ICompoundProperty iParent, const std::string &iNodeName)
bool valid()
std::string getName()
bool getTarget(std::string &oResult)
bool getNodeType(std::string &oResult)
Abc::ICompoundProperty getParameters()
size_t getNumConnections()
bool getConnection(size_t iIndex, std::string &oInputName, std::string &oConnectedNodeName, std::string &oConnectedOutputName)
bool getConnection(const std::string &iInputName, std::string &oConnectedNodeName, std::string &oConnectedOutputName)

Private Functions

void splitConnectionValue(const std::string &v, std::string &a, std::string &b)

Private Members

Abc::ICompoundProperty m_compound
bool m_connectionsChecked
std::vector<std::string> m_connections
std::map<std::string, std::string> m_connectionsMap
class NetworkNode

Public Types

typedef std::vector<Connection> ConnectionVector

Public Functions

NetworkNode()
bool valid()
std::string getName()
bool getTarget(std::string &oResult)
bool getNodeType(std::string &oResult)
void getParameters(ParameterEntryVector &oResult)
void getConnections(ConnectionVector &oResult)

Private Functions

NetworkNode(const std::string &iName, SchemaVector &iSchemas, StringMapPtr iInterfaceMappings)

Private Members

std::string m_name
std::vector<IMaterialSchema::NetworkNode> m_nodes
std::vector<Abc::ICompoundProperty> m_networkParameters
StringMapPtr m_interfaceMappings

Friends

friend Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::MaterialFlatten
class OMaterialSchema
#include <OMaterial.h>

Schema for writing shader definitions as either an object or a compound property. Only “monolithic” shader definitions (i.e. non network) are presently supported in this implementation.

Public Types

typedef OMaterialSchema this_type

Public Functions

OMaterialSchema()
template <class CPROP_PTR>
OMaterialSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument(), const Abc::Argument &iArg2 = Abc::Argument())
template <class CPROP_PTR>
OMaterialSchema(CPROP_PTR iParent, const Abc::Argument &iArg0 = Abc::Argument(), const Abc::Argument &iArg1 = Abc::Argument(), const Abc::Argument &iArg2 = Abc::Argument())
OMaterialSchema(const OMaterialSchema &iCopy)

Copy constructor.

void setShader(const std::string &iTarget, const std::string &iShaderType, const std::string &iShaderName)

Declare shader for a given target and shaderType. “Target’s” value is an agreed upon convention for a renderer or application (i.e. “prman”) “ShaderType’s” value is an agreed upon convention for shader terminals such as “surface,” “displacement,” “light”, “coshader_somename.” “ShaderName’s” value is an identifier meaningful to the target application (i.e. “paintedplastic,” “fancy_spot_light”). It’s only valid to call this once per target/shaderType combo.

Abc::OCompoundProperty getShaderParameters(const std::string &iTarget, const std::string &iShaderType)

Declare and retrieve a container for storing properties representing parameters for the target and shaderType. You put them in there yourself since there are no restrictions on type or sampling other than what’s appropriate and meaningful for the target application. Repeated calls will return the same object.

void addNetworkNode(const std::string &iNodeName, const std::string &iTarget, const std::string &iNodeType)
void setNetworkNodeConnection(const std::string &iNodeName, const std::string &iInputName, const std::string &iConnectedNodeName, const std::string &iConnectedOutputName)
Abc::OCompoundProperty getNetworkNodeParameters(const std::string &iNodeName)
void setNetworkTerminal(const std::string &iTarget, const std::string &iShaderType, const std::string &iNodeName, const std::string &iOutputName = "")
void setNetworkInterfaceParameterMapping(const std::string &iInterfaceParamName, const std::string &iMapToNodeName, const std::string &iMapToParamName)
Abc::OCompoundProperty getNetworkInterfaceParameters()

Protected Functions

void init()
void createNodeCompound()

Protected Attributes

Abc::OCompoundProperty m_node
Util::shared_ptr<Data> m_data
struct ParameterEntry

Public Functions

ParameterEntry()
ParameterEntry(const std::string &iName, Abc::ICompoundProperty iParent, const AbcCoreAbstract::PropertyHeader *iHeader)
bool operator==(const ParameterEntry &iRhs) const

Public Members

std::string name
Abc::ICompoundProperty parent
const AbcCoreAbstract::PropertyHeader *header
namespace Alembic
namespace AbcMaterial
namespace ALEMBIC_VERSION_NS

Typedefs

typedef Abc::ISchemaObject<IMaterialSchema> IMaterial

Object declaration.

typedef Util::shared_ptr<IMaterial> IMaterialPtr
typedef Abc::OSchemaObject<OMaterialSchema> OMaterial

Object declaration.

typedef Util::shared_ptr<OMaterial> OMaterialPtr

Functions

Alembic::AbcMaterial::ALEMBIC_VERSION_NS::ALEMBIC_ABC_DECLARE_SCHEMA_INFO("AbcMaterial_Material_v1", "", ".material", MaterialSchemaInfo)
ALEMBIC_EXPORT void Alembic::AbcMaterial::ALEMBIC_VERSION_NS::addMaterialAssignment(Abc::OObject iObject, const std::string & iValue, const std::string & iPropName = MATERIALASSIGN_PROPNAME)

Adds a material assignment to an object. The value should be the absolute path to an Material object. (The default interpretation is that this path is to an object within the same archive.)

The default value for “propName” is officially supported convention of the library. You may provide an alternative value for custom solutions that want to make use of this convenience.

ALEMBIC_EXPORT void Alembic::AbcMaterial::ALEMBIC_VERSION_NS::addMaterialAssignment(Abc::OCompoundProperty iProp, const std::string & iValue, const std::string & iPropName = MATERIALASSIGN_PROPNAME)

Adds a material assignment within a compound property. The conventions and concerns are identical as with applying to an object. This exists primarily for custom solutions which want to make use of the convenience within nested compounds.

ALEMBIC_EXPORT OMaterialSchema Alembic::AbcMaterial::ALEMBIC_VERSION_NS::addMaterial(Abc::OObject iObject, const std::string & iPropName = MATERIAL_PROPNAME)

Adds a local material schema to any object. This is intended for “has-a” cases such as “this polymesh has a material locally defined.”

The default value for “propName” is officially supported convention of the library. You may provide an alternative value for custom solutions that want to make use of this convenience.

ALEMBIC_EXPORT OMaterialSchema Alembic::AbcMaterial::ALEMBIC_VERSION_NS::addMaterial(Abc::OCompoundProperty iProp, const std::string & iPropName = MATERIAL_PROPNAME)

Adds a local material schema within any compound. This is intended for the “has-a” cases for nested compound properties.

ALEMBIC_EXPORT bool Alembic::AbcMaterial::ALEMBIC_VERSION_NS::getMaterialAssignmentPath(Abc::IObject iObject, std::string & oResult, const std::string & iPropName = MATERIALASSIGN_PROPNAME)

Returns true and fills result with the value of previously defined material assignment path. The default interpretation of the value is as a full path to an IMaterial object within the same archive.

The default value for “propName” is officially supported convention of the library. You may provide an alternative value for custom solutions that want to make use of this convenience.

ALEMBIC_EXPORT bool Alembic::AbcMaterial::ALEMBIC_VERSION_NS::getMaterialAssignmentPath(Abc::ICompoundProperty iProp, std::string & oResult, const std::string & iPropName = MATERIALASSIGN_PROPNAME)

Returns true and fills result with the value of previously defined material assignment path within a given compound property.

The common case is at the object level but this is here as a convenince for custom solutions

ALEMBIC_EXPORT bool Alembic::AbcMaterial::ALEMBIC_VERSION_NS::hasMaterial(Abc::IObject iObject, IMaterialSchema & oResult, const std::string & iPropName = MATERIAL_PROPNAME)

Returns true and fills result a previously defined local material on this object following the “has a” pattern.

The default value for “propName” is officially supported convention of the library. You may provide an alternative value for custom solutions that want to make use of this convenience.

ALEMBIC_EXPORT bool Alembic::AbcMaterial::ALEMBIC_VERSION_NS::hasMaterial(Abc::ICompoundProperty iCompound, IMaterialSchema & oResult, const std::string & iPropName = MATERIAL_PROPNAME)

Returns true and fills result a previously defined local material within the given compound property. This is useful for solutions in which another schema wants to contain a material definition but not advertise it as such at the object level

file All.h
#include <Alembic/AbcMaterial/IMaterial.h>#include <Alembic/AbcMaterial/OMaterial.h>#include <Alembic/AbcMaterial/MaterialAssignment.h>#include <Alembic/AbcMaterial/MaterialFlatten.h>
file IMaterial.h
#include <Alembic/Abc/All.h>#include <Alembic/Util/Export.h>#include <Alembic/AbcMaterial/SchemaInfoDeclarations.h>
file MaterialAssignment.h
#include <Alembic/Util/Export.h>#include <Alembic/AbcMaterial/IMaterial.h>#include <Alembic/AbcMaterial/OMaterial.h>

Defines

MATERIALASSIGN_PROPNAME
MATERIAL_PROPNAME
file MaterialFlatten.h
#include <Alembic/Util/Export.h>#include <Alembic/AbcMaterial/IMaterial.h>
file OMaterial.h
#include <Alembic/Abc/All.h>#include <Alembic/Util/Export.h>#include <Alembic/AbcMaterial/SchemaInfoDeclarations.h>
file SchemaInfoDeclarations.h
#include <Alembic/Abc/OSchema.h>