Loading...
Searching...
No Matches
MaterialFlatten.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2015,
// Sony Pictures Imageworks Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic, nor the names of their contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//-*****************************************************************************
#ifndef Alembic_AbcMaterial_MaterialFlatten_h
#define Alembic_AbcMaterial_MaterialFlatten_h
#include <Alembic/Util/Export.h>
#include <Alembic/AbcMaterial/IMaterial.h>
namespace Alembic {
namespace AbcMaterial {
namespace ALEMBIC_VERSION_NS {
class ALEMBIC_EXPORT MaterialFlatten
{
public:
MaterialFlatten();
MaterialFlatten( IMaterialSchema iMaterialSchema );
MaterialFlatten( IMaterial iMaterialObject );
MaterialFlatten( Abc::IObject iObject,
Abc::IArchive iAlternateSearchArchive=Abc::IArchive() );
//TODO: need an append equivalent!
void append( IMaterialSchema iMaterialSchema );
void append( IMaterial iMaterialObject );
bool empty();
void getTargetNames( std::vector<std::string> & oTargetNames );
void getShaderTypesForTarget( const std::string & iTargetName,
std::vector<std::string> & oShaderTypeNames );
bool getShader( const std::string & iTarget,
const std::string & iShaderType,
std::string & oResult );
struct ParameterEntry
{
ParameterEntry()
: header(0)
{
}
ParameterEntry( const std::string & iName,
Abc::ICompoundProperty iParent,
const AbcCoreAbstract::PropertyHeader * iHeader )
: name(iName)
, parent(iParent)
, header(iHeader)
{
}
bool operator==( const ParameterEntry &iRhs ) const
{
return name == iRhs.name &&
parent == iRhs.parent &&
header == iRhs.header;
}
std::string name;
Abc::ICompoundProperty parent;
const AbcCoreAbstract::PropertyHeader * header;
// header is owned by parent, so it is safe to hold onto the pointer
};
typedef std::vector<ParameterEntry> ParameterEntryVector;
void getShaderParameters( const std::string & iTarget,
const std::string & iShaderType,
ParameterEntryVector & oResult );
void getNetworkTerminalTargetNames(std::vector<std::string> & iTargetNames);
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 );
typedef std::map<std::string, std::string> StringMap;
typedef Alembic::Util::shared_ptr<StringMap> StringMapPtr;
typedef std::vector<IMaterialSchema> SchemaVector;
class ALEMBIC_EXPORT NetworkNode
{
public:
NetworkNode();
bool valid();
std::string getName();
bool getTarget( std::string & oResult );
bool getNodeType( std::string & oResult );
void getParameters( ParameterEntryVector & oResult );
struct Connection
{
Connection( const std::string & iInputName,
const std::string & iConnectedNodeName,
const std::string & iConnectedOutputName )
: inputName( iInputName )
, connectedNodeName( iConnectedNodeName )
, connectedOutputName( iConnectedOutputName )
{
}
bool operator==( const Connection & iRhs ) const
{
return inputName == iRhs.inputName &&
connectedNodeName == iRhs.connectedNodeName &&
connectedOutputName == iRhs.connectedOutputName;
}
std::string inputName;
std::string connectedNodeName;
std::string connectedOutputName;
};
typedef std::vector<Connection> ConnectionVector;
void getConnections( ConnectionVector & oResult );
private:
friend class MaterialFlatten;
NetworkNode( const std::string & iName,
SchemaVector & iSchemas,
StringMapPtr iInterfaceMappings );
std::string m_name;
std::vector<IMaterialSchema::NetworkNode> m_nodes;
std::vector<Abc::ICompoundProperty> m_networkParameters;
StringMapPtr m_interfaceMappings;
};
size_t getNumNetworkNodes();
NetworkNode getNetworkNode( size_t iIndex );
NetworkNode getNetworkNode( const std::string & iNodeName );
// TODO: no method to get the node names?
private:
SchemaVector m_schemas;
void flattenNetwork();
bool m_networkFlattened;
std::vector<std::string> m_nodeNames;
typedef std::map<std::string, StringMapPtr> StringMapMap;
StringMapMap m_nodesToInterfaceMappings;
};
}
using namespace ALEMBIC_VERSION_NS;
}
}
#endif
Export.h
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition Export.h:51
IMaterial.h
Alembic::AbcCoreAbstract::ALEMBIC_VERSION_NS::PropertyHeader
Definition PropertyHeader.h:79
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::IMaterialSchema
Definition IMaterial.h:54
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode
Definition MaterialFlatten.h:159
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::valid
bool valid()
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::getNodeType
bool getNodeType(std::string &oResult)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::MaterialFlatten
friend class MaterialFlatten
Definition MaterialFlatten.h:200
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::getConnections
void getConnections(ConnectionVector &oResult)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::getName
std::string getName()
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::NetworkNode
NetworkNode()
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::getTarget
bool getTarget(std::string &oResult)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::getParameters
void getParameters(ParameterEntryVector &oResult)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::ConnectionVector
std::vector< Connection > ConnectionVector
Definition MaterialFlatten.h:194
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNetworkTerminal
bool getNetworkTerminal(const std::string &iTarget, const std::string &iShaderType, std::string &oNodeName, std::string &oOutputName)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::empty
bool empty()
Returns true is there are no schema in the inheritance path.
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::StringMapPtr
Alembic::Util::shared_ptr< StringMap > StringMapPtr
Definition MaterialFlatten.h:155
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::append
void append(IMaterial iMaterialObject)
Append the schemas of matching parent material objects.
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNetworkTerminalShaderTypesForTarget
void getNetworkTerminalShaderTypesForTarget(const std::string &iTargetName, std::vector< std::string > &oShaderTypeNames)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getShader
bool getShader(const std::string &iTarget, const std::string &iShaderType, std::string &oResult)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::MaterialFlatten
MaterialFlatten()
Create empty. Use append to add material schema manually.
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNetworkNode
NetworkNode getNetworkNode(const std::string &iNodeName)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::append
void append(IMaterialSchema iMaterialSchema)
Manually append a schema to the inheritance hierarchy.
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getShaderParameters
void getShaderParameters(const std::string &iTarget, const std::string &iShaderType, ParameterEntryVector &oResult)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::MaterialFlatten
MaterialFlatten(IMaterial iMaterialObject)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::StringMap
std::map< std::string, std::string > StringMap
Definition MaterialFlatten.h:154
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getShaderTypesForTarget
void getShaderTypesForTarget(const std::string &iTargetName, std::vector< std::string > &oShaderTypeNames)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::MaterialFlatten
MaterialFlatten(IMaterialSchema iMaterialSchema)
Create with a single materialSchema.
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getTargetNames
void getTargetNames(std::vector< std::string > &oTargetNames)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::MaterialFlatten
MaterialFlatten(Abc::IObject iObject, Abc::IArchive iAlternateSearchArchive=Abc::IArchive())
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNetworkNode
NetworkNode getNetworkNode(size_t iIndex)
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNetworkTerminalTargetNames
void getNetworkTerminalTargetNames(std::vector< std::string > &iTargetNames)
network stuff
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntryVector
std::vector< ParameterEntry > ParameterEntryVector
Definition MaterialFlatten.h:131
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNumNetworkNodes
size_t getNumNetworkNodes()
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::SchemaVector
std::vector< IMaterialSchema > SchemaVector
Definition MaterialFlatten.h:156
Alembic::Abc::ALEMBIC_VERSION_NS::IArchive
Definition IArchive.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::ICompoundProperty
Definition ICompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::IObject
Definition IObject.h:54
Alembic::AbcMaterial::ALEMBIC_VERSION_NS
Definition IMaterial.h:46
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::IMaterial
Abc::ISchemaObject< IMaterialSchema > IMaterial
Object declaration.
Definition IMaterial.h:220
Alembic::AbcMaterial
Definition IMaterial.h:45
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::Connection::connectedOutputName
std::string connectedOutputName
Definition MaterialFlatten.h:191
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::Connection::Connection
Connection(const std::string &iInputName, const std::string &iConnectedNodeName, const std::string &iConnectedOutputName)
Definition MaterialFlatten.h:173
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::Connection::operator==
bool operator==(const Connection &iRhs) const
Definition MaterialFlatten.h:182
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::Connection::connectedNodeName
std::string connectedNodeName
Definition MaterialFlatten.h:190
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::NetworkNode::Connection::inputName
std::string inputName
Definition MaterialFlatten.h:189
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntry::name
std::string name
Definition MaterialFlatten.h:125
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntry::header
const AbcCoreAbstract::PropertyHeader * header
Definition MaterialFlatten.h:127
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntry::ParameterEntry
ParameterEntry(const std::string &iName, Abc::ICompoundProperty iParent, const AbcCoreAbstract::PropertyHeader *iHeader)
Definition MaterialFlatten.h:109
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntry::parent
Abc::ICompoundProperty parent
Definition MaterialFlatten.h:126
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntry::ParameterEntry
ParameterEntry()
Definition MaterialFlatten.h:104
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::ParameterEntry::operator==
bool operator==(const ParameterEntry &iRhs) const
Definition MaterialFlatten.h:118