HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
IMaterial.h
Go to the documentation of this file.
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_IMaterial_h_
38 #define _Alembic_AbcMaterial_IMaterial_h_
39 
40 #include <Alembic/Abc/All.h>
41 #include <Alembic/Util/Export.h>
43 
44 namespace Alembic {
45 namespace AbcMaterial {
46 namespace ALEMBIC_VERSION_NS {
47 
48 //! Schema for reading and querying shader definitions from either an object or
49 //! compound property.
50 //! Only "monolithic" shader definitions (i.e. non network) are presently
51 //! supported in this implementation.
53  : public Abc::ISchema<MaterialSchemaInfo>
54 {
55 public:
56 
57  //-------------------------------------------------------------------------
58  //BOILERPLATE
59 
61 
63 
64  template <class CPROP_PTR>
65  IMaterialSchema( CPROP_PTR iParent,
66  const std::string &iName,
67  const Abc::Argument &iArg0 = Abc::Argument(),
68  const Abc::Argument &iArg1 = Abc::Argument() )
69 
70  : Abc::ISchema<MaterialSchemaInfo>( iParent, iName, iArg0, iArg1 )
71  {
72  init();
73  }
74 
75  //! This constructor is the same as above, but with default
76  //! schema name used.
77  template <class CPROP_PTR>
78  explicit IMaterialSchema( CPROP_PTR iParent,
79  const Abc::Argument &iArg0 = Abc::Argument(),
80  const Abc::Argument &iArg1 = Abc::Argument() )
81  : Abc::ISchema<MaterialSchemaInfo>( iParent, iArg0, iArg1 )
82  {
83  init();
84  }
85 
86  //! Wrap an existing schema object
87  template <class CPROP_PTR>
88  IMaterialSchema( CPROP_PTR iThis,
90  const Abc::Argument &iArg0 = Abc::Argument(),
91  const Abc::Argument &iArg1 = Abc::Argument() )
92  : Abc::ISchema<MaterialSchemaInfo>( iThis, iFlag, iArg0, iArg1 )
93  {
94  init();
95  }
96 
97  //! Copy constructor.
99  : Abc::ISchema<MaterialSchemaInfo>()
100  {
101  *this = iCopy;
102  }
103 
104  //-------------------------------------------------------------------------
105  //ACTUAL STUFF
106 
107  //! Fills a list of target name strings for which either shader or
108  //! parameter definitions are locally present.
109  //! Target name values match an upon convention for a renderer
110  //! or application (i.e. "prman")
111  //! This gets the target names for the monolithic shaders
112  void getTargetNames( std::vector<std::string> & iTargetNames );
113 
114  //! Fills a list of shader type strings for which either shader or
115  //! parameter definitions are locally present for a given target.
116  //! Shader type names match an agreed upon convention for shader terminals
117  //! such as "surface," "displacement," "light", "coshader_somename."
118  void getShaderTypesForTarget( const std::string & iTargetName,
119  std::vector<std::string> & oShaderTypeNames );
120 
121  //! Returns true and fills result with the shader name for a given
122  //! target and shaderType if locally defined
123  bool getShader( const std::string & iTarget,
124  const std::string & iShaderType,
125  std::string & oResult );
126 
127  //! Returns the enclosing compound property for the given target and
128  //! shader type. Call .valid() on the result to determine whether it's
129  //! locally defined or not.
130  Abc::ICompoundProperty getShaderParameters(
131  const std::string & iTarget, const std::string & iShaderType );
132 
133  //-------------------------------------------------------------------------
134 
136  {
137  public:
138 
139  NetworkNode();
140  NetworkNode( Abc::ICompoundProperty iCompound );
142  const std::string & iNodeName );
143 
144  bool valid();
145 
146  std::string getName();
147 
148  bool getTarget( std::string & oResult );
149  bool getNodeType( std::string & oResult );
150 
151  Abc::ICompoundProperty getParameters();
152 
153  size_t getNumConnections();
154  bool getConnection( size_t iIndex,
155  std::string & oInputName,
156  std::string & oConnectedNodeName,
157  std::string & oConnectedOutputName );
158 
159  bool getConnection( const std::string & iInputName,
160  std::string & oConnectedNodeName,
161  std::string & oConnectedOutputName );
162 
163  private:
164  Abc::ICompoundProperty m_compound;
165 
166  bool m_connectionsChecked;
167  std::vector< std::string > m_connections;
168  std::map< std::string, std::string > m_connectionsMap;
169 
170  void splitConnectionValue( const std::string & v,
171  std::string & a,
172  std::string & b );
173  };
174 
175  size_t getNumNetworkNodes();
176  void getNetworkNodeNames( std::vector<std::string> & oNames );
177 
178  NetworkNode getNetworkNode( size_t iIndex );
179  NetworkNode getNetworkNode( const std::string & iNodeName );
180 
181  void getNetworkTerminalTargetNames(
182  std::vector<std::string> & oTargetNames );
183 
184  void getNetworkTerminalShaderTypesForTarget(
185  const std::string & iTargetName,
186  std::vector<std::string> & oShaderTypeNames );
187 
188  bool getNetworkTerminal( const std::string & iTarget,
189  const std::string & iShaderType,
190  std::string & oNodeName,
191  std::string & oOutputName );
192 
193  size_t getNumNetworkInterfaceParameterMappings();
194  bool getNetworkInterfaceParameterMapping( size_t iIndex,
195  std::string & oInterfaceParamName,
196  std::string & oMapToNodeName,
197  std::string & oMapToParamName );
198 
199  void getNetworkInterfaceParameterMappingNames(
200  std::vector<std::string> & oNames );
201 
202  bool getNetworkInterfaceParameterMapping(
203  const std::string & iInterfaceParamName,
204  std::string & oMapToNodeName,
205  std::string & oMapToParamName );
206 
207  Abc::ICompoundProperty getNetworkInterfaceParameters();
208 
209 protected:
210 
211 private:
212 
213  void init();
214 
215  std::map<std::string, std::string> m_shaderNames;
216  std::map<std::string, std::string> m_terminals;
217  std::map<std::string, std::string> m_interfaceMap;
218  std::vector<std::string> m_interface;
219 
220  Abc::ICompoundProperty m_interfaceParams;
221  Abc::ICompoundProperty m_node;
222 };
223 
224 //! Object declaration
226 
227 typedef Util::shared_ptr< IMaterial > IMaterialPtr;
228 
229 } // End namespace ALEMBIC_VERSION_NS
230 
231 using namespace ALEMBIC_VERSION_NS;
232 
233 } // End namespace AbcMaterial
234 } // End namespace Alembic
235 
236 #endif
const GLdouble * v
Definition: glcorearb.h:836
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
IMaterialSchema(CPROP_PTR iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IMaterial.h:65
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1221
IMaterialSchema(const IMaterialSchema &iCopy)
Copy constructor.
Definition: IMaterial.h:98
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
IMaterialSchema(CPROP_PTR iThis, Abc::WrapExistingFlag iFlag, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Wrap an existing schema object.
Definition: IMaterial.h:88
Abc::ISchemaObject< IMaterialSchema > IMaterial
Object declaration.
Definition: IMaterial.h:225
IMaterialSchema(CPROP_PTR iParent, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument())
Definition: IMaterial.h:78
Util::shared_ptr< IMaterial > IMaterialPtr
Definition: IMaterial.h:227
#define ALEMBIC_EXPORT
Definition: Export.h:51
#define ALEMBIC_VERSION_NS
Definition: Foundation.h:104