Alembic 1.8.11
Loading...
Searching...
No Matches
MaterialFlatten.h
1//-*****************************************************************************
2//
3// Copyright (c) 2009-2015,
4// Sony Pictures Imageworks Inc. and
5// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
6//
7// All rights reserved.
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12// * Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14// * Redistributions in binary form must reproduce the above
15// copyright notice, this list of conditions and the following disclaimer
16// in the documentation and/or other materials provided with the
17// distribution.
18// * Neither the name of Sony Pictures Imageworks, nor
19// Industrial Light & Magic, nor the names of their contributors may be used
20// to endorse or promote products derived from this software without specific
21// prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34//
35//-*****************************************************************************
36
37#ifndef Alembic_AbcMaterial_MaterialFlatten_h
38#define Alembic_AbcMaterial_MaterialFlatten_h
39
40#include <Alembic/Util/Export.h>
41#include <Alembic/AbcMaterial/IMaterial.h>
42
43namespace Alembic {
44namespace AbcMaterial {
45namespace ALEMBIC_VERSION_NS {
46
49class ALEMBIC_EXPORT MaterialFlatten
50{
51public:
52
55
57 MaterialFlatten( IMaterialSchema iMaterialSchema );
58
61 MaterialFlatten( IMaterial iMaterialObject );
62
73 Abc::IArchive iAlternateSearchArchive=Abc::IArchive() );
74 //TODO: need an append equivalent!
75
77 void append( IMaterialSchema iMaterialSchema );
78
80 void append( IMaterial iMaterialObject );
81
82
84 bool empty();
85
88 void getTargetNames( std::vector<std::string> & oTargetNames );
89
92 void getShaderTypesForTarget( const std::string & iTargetName,
93 std::vector<std::string> & oShaderTypeNames );
94
98 bool getShader( const std::string & iTarget,
99 const std::string & iShaderType,
100 std::string & oResult );
101
102 struct ParameterEntry
103 {
104 ParameterEntry()
105 : header(0)
106 {
107 }
108
109 ParameterEntry( const std::string & iName,
111 const AbcCoreAbstract::PropertyHeader * iHeader )
112 : name(iName)
113 , parent(iParent)
114 , header(iHeader)
115 {
116 }
117
118 bool operator==( const ParameterEntry &iRhs ) const
119 {
120 return name == iRhs.name &&
121 parent == iRhs.parent &&
122 header == iRhs.header;
123 }
124
125 std::string name;
127 const AbcCoreAbstract::PropertyHeader * header;
128 // header is owned by parent, so it is safe to hold onto the pointer
129 };
130
131 typedef std::vector<ParameterEntry> ParameterEntryVector;
132
137 void getShaderParameters( const std::string & iTarget,
138 const std::string & iShaderType,
139 ParameterEntryVector & oResult );
140
143
144 void getNetworkTerminalTargetNames(std::vector<std::string> & iTargetNames);
145 void getNetworkTerminalShaderTypesForTarget(
146 const std::string & iTargetName,
147 std::vector<std::string> & oShaderTypeNames );
148
149 bool getNetworkTerminal( const std::string & iTarget,
150 const std::string & iShaderType,
151 std::string & oNodeName,
152 std::string & oOutputName );
153
154 typedef std::map<std::string, std::string> StringMap;
155 typedef Alembic::Util::shared_ptr<StringMap> StringMapPtr;
156 typedef std::vector<IMaterialSchema> SchemaVector;
157
158 class ALEMBIC_EXPORT NetworkNode
159 {
160 public:
161
162 NetworkNode();
163
164 bool valid();
165
166 std::string getName();
167 bool getTarget( std::string & oResult );
168 bool getNodeType( std::string & oResult );
169 void getParameters( ParameterEntryVector & oResult );
170
171 struct Connection
172 {
173 Connection( const std::string & iInputName,
174 const std::string & iConnectedNodeName,
175 const std::string & iConnectedOutputName )
176 : inputName( iInputName )
177 , connectedNodeName( iConnectedNodeName )
178 , connectedOutputName( iConnectedOutputName )
179 {
180 }
181
182 bool operator==( const Connection & iRhs ) const
183 {
184 return inputName == iRhs.inputName &&
185 connectedNodeName == iRhs.connectedNodeName &&
186 connectedOutputName == iRhs.connectedOutputName;
187 }
188
189 std::string inputName;
190 std::string connectedNodeName;
191 std::string connectedOutputName;
192 };
193
194 typedef std::vector<Connection> ConnectionVector;
195
196 void getConnections( ConnectionVector & oResult );
197
198 private:
199
200 friend class MaterialFlatten;
201
202 NetworkNode( const std::string & iName,
203 SchemaVector & iSchemas,
204 StringMapPtr iInterfaceMappings );
205
206 std::string m_name;
207 std::vector<IMaterialSchema::NetworkNode> m_nodes;
208 std::vector<Abc::ICompoundProperty> m_networkParameters;
209 StringMapPtr m_interfaceMappings;
210 };
211
212 size_t getNumNetworkNodes();
213 NetworkNode getNetworkNode( size_t iIndex );
214 NetworkNode getNetworkNode( const std::string & iNodeName );
215
216 // TODO: no method to get the node names?
217
218private:
219
220 SchemaVector m_schemas;
221
222 void flattenNetwork();
223
224 bool m_networkFlattened;
225
226 std::vector<std::string> m_nodeNames;
227 typedef std::map<std::string, StringMapPtr> StringMapMap;
228 StringMapMap m_nodesToInterfaceMappings;
229
230};
231
232}
233
234using namespace ALEMBIC_VERSION_NS;
235
236}
237}
238
239#endif
bool empty()
Returns true is there are no schema in the inheritance path.
Definition MaterialFlatten.cpp:178
bool getShader(const std::string &iTarget, const std::string &iShaderType, std::string &oResult)
Definition MaterialFlatten.cpp:221
MaterialFlatten()
Create empty. Use append to add material schema manually.
Definition MaterialFlatten.cpp:46
void append(IMaterialSchema iMaterialSchema)
Manually append a schema to the inheritance hierarchy.
Definition MaterialFlatten.cpp:146
void getShaderParameters(const std::string &iTarget, const std::string &iShaderType, ParameterEntryVector &oResult)
Definition MaterialFlatten.cpp:237
void getShaderTypesForTarget(const std::string &iTargetName, std::vector< std::string > &oShaderTypeNames)
Definition MaterialFlatten.cpp:202
void getTargetNames(std::vector< std::string > &oTargetNames)
Definition MaterialFlatten.cpp:183
void getNetworkTerminalTargetNames(std::vector< std::string > &iTargetNames)
network stuff
Definition MaterialFlatten.cpp:275
Alembic namespace ...
Definition ArchiveInfo.cpp:39