HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GT_MaterialNode.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GT_MaterialNode.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef __GT_MaterialNode__
11 #define __GT_MaterialNode__
12 
13 #include "GT_API.h"
14 
15 #include <UT/UT_IntrusivePtr.h>
16 #include <UT/UT_Options.h>
17 #include <UT/UT_Set.h>
18 #include <UT/UT_StringMap.h>
19 
22 
23 /// An shallow abstraction of a shader node network
24 class GT_API GT_MaterialNode : public UT_IntrusiveRefCounter<GT_MaterialNode>
25 {
26 public:
28  GT_MaterialNode(const UT_StringRef &nodetype);
32 
33  // Actual name of the node
34  void setName(const UT_StringRef &name) { myName = name; }
35  // Simple name (n#) for shader references
36  void setTokenName(const UT_StringRef &name) { myToken = name; }
37 
38  void addInput(const UT_StringRef &input_name,
39  const UT_StringRef &output_name,
40  const GT_MaterialNodePtr &node);
41  void addOutputVar(const UT_StringRef &output, const UT_StringRef &varname);
42  void clearOutputVars();
43 
44  void copyParms(const GT_MaterialNodePtr &mat_node,
45  UT_Set<int> &visited);
46 
47  const UT_StringRef &name() const { return myName; }
48  const UT_StringRef &token() const { return myToken; }
49  const UT_StringHolder &type() const { return myTypeName; }
50  UT_Options &parms() { return myParms; }
51  const UT_Options &parms() const { return myParms; }
52 
54  inputs() const { return myInputs; }
55 
57  const UT_StringRef &getInputOutputName(const UT_StringRef &name) const;
58  int getInputOutputType(const UT_StringRef &name) const;
59  const UT_StringRef &getOutputVar(const UT_StringRef &output) const;
60 
61  bool isTimeDependent(bool inputs_too = true) const;
62  void setTimeDependent(bool time_dep) { myTimeDep = time_dep; }
63 
64  static void addNodeDefaults(const UT_StringRef &nodetype_name,
65  const UT_Options &parm_defaults,
66  const UT_StringMap<int> &outputs,
67  const UT_StringArray &textures);
68  static bool nodeTypeExists(const UT_StringRef &nodetype_name);
69 
70  static const UT_StringMap<int> &getNodeOutputs(const UT_StringRef &nodetype);
71  static const UT_StringArray &getNodeTextures(const UT_StringRef &nodetype);
72 
73  // Returns true if the network structure is the same as the network with
74  // root 'node'
75  bool networkMatch(const GT_MaterialNode *node,
76  UT_Set<int> &visited) const;
77 
78  int64 uniqueId() { return myID; }
79 
80 private:
82  UT_StringMap<UT_StringHolder> myOutputVars;
83  UT_Options myParms;
84  UT_StringHolder myTypeName;
85  UT_StringHolder myName;
86  UT_StringHolder myToken;
87  int64 myID;
88  bool myTimeDep = false;
89 };
90 
91 
92 #endif
UT_IntrusivePtr< GT_MaterialNode > GT_MaterialNodePtr
short * getInput(int size) override
void setTimeDependent(bool time_dep)
const UT_StringHolder & type() const
void setTokenName(const UT_StringRef &name)
#define GT_API
Definition: GT_API.h:13
const UT_StringMap< std::pair< GT_MaterialNodePtr, UT_StringHolder > > & inputs() const
A reference counter base class for use with UT_IntrusivePtr.
UT_IntrusiveRefCounter & operator=(const UT_IntrusiveRefCounter &) noexcept
Assignment operator: Does not modify counter.
An shallow abstraction of a shader node network.
void setName(const UT_StringRef &name)
Wrapper around hboost::intrusive_ptr.
long long int64
Definition: SYS_Types.h:116
const UT_StringRef & token() const
GLuint const GLchar * name
Definition: glcorearb.h:786
A map of string to various well defined value types.
Definition: UT_Options.h:84
GT_MaterialNode(const GT_MaterialNode &src)
const UT_StringRef & name() const
const GLuint * textures
Definition: glcorearb.h:416
UT_Options & parms()
const UT_Options & parms() const
GLenum src
Definition: glcorearb.h:1793