Loading...
Searching...
No Matches
MaterialFlatten.h
//-*****************************************************************************
//
// 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
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::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::empty
bool empty()
Returns true is there are no schema in the inheritance path.
Definition MaterialFlatten.cpp:178
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getShader
bool getShader(const std::string &iTarget, const std::string &iShaderType, std::string &oResult)
Definition MaterialFlatten.cpp:221
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::MaterialFlatten
MaterialFlatten()
Create empty. Use append to add material schema manually.
Definition MaterialFlatten.cpp:46
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::append
void append(IMaterialSchema iMaterialSchema)
Manually append a schema to the inheritance hierarchy.
Definition MaterialFlatten.cpp:146
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getShaderParameters
void getShaderParameters(const std::string &iTarget, const std::string &iShaderType, ParameterEntryVector &oResult)
Definition MaterialFlatten.cpp:237
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getShaderTypesForTarget
void getShaderTypesForTarget(const std::string &iTargetName, std::vector< std::string > &oShaderTypeNames)
Definition MaterialFlatten.cpp:202
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getTargetNames
void getTargetNames(std::vector< std::string > &oTargetNames)
Definition MaterialFlatten.cpp:183
Alembic::AbcMaterial::ALEMBIC_VERSION_NS::MaterialFlatten::getNetworkTerminalTargetNames
void getNetworkTerminalTargetNames(std::vector< std::string > &iTargetNames)
network stuff
Definition MaterialFlatten.cpp:275
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39