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 #include <UT/UT_VectorTypes.h>
20 
21 class UT_TokenString;
22 
25 
26 /// An shallow abstraction of a shader node network
27 class GT_API GT_MaterialNode : public UT_IntrusiveRefCounter<GT_MaterialNode>
28 {
29 public:
31  GT_MaterialNode(const UT_StringRef &nodetype, int64 index);
35 
36  // Actual name of the node
37  void setName(const UT_StringRef &name) { myName = name; }
38  // Simple name (n#) for shader references
39  void setTokenName(const UT_StringRef &name) { myToken = name; }
40 
41  void addInput(const UT_StringRef &input_name,
42  const UT_StringRef &output_name,
43  const GT_MaterialNodePtr &node);
44  void addOutputVar(const UT_StringRef &output, const UT_StringRef &varname);
45  void clearOutputVars();
46 
47  void copyParms(const GT_MaterialNodePtr &mat_node,
48  UT_Set<int> &visited);
49 
50  const UT_StringRef &name() const { return myName; }
51  const UT_StringRef &token() const { return myToken; }
52  const UT_StringHolder &type() const { return myTypeName; }
53  UT_Options &parms() { return myParms; }
54  const UT_Options &parms() const { return myParms; }
55 
57  inputs() const { return myInputs; }
58 
60  const UT_StringRef &getInputOutputName(const UT_StringRef &name) const;
61  int getInputOutputType(const UT_StringRef &name) const;
62  int getInputOutputIndex(const UT_StringRef &name) const;
63  const UT_StringRef &getOutputVar(const UT_StringRef &output) const;
64 
65  bool isTimeDependent(bool inputs_too = true) const;
66  void setTimeDependent(bool time_dep) { myTimeDep = time_dep; }
67 
68  static void addNodeDefaults(const UT_StringRef &nodetype_name,
69  const UT_Options &parm_defaults,
70  const UT_StringMap<UT_Vector2i> &outputs,
71  const UT_StringArray &textures);
72  static bool addExtraParms(const UT_StringRef &nodetype_name,
73  const UT_Options &extra_parms);
74 
75  static bool nodeTypeExists(const UT_StringRef &nodetype_name);
76 
77  static const UT_StringMap<UT_Vector2i> &
78  getNodeOutputs(const UT_StringRef &nodetype);
79  static const UT_StringArray &getNodeTextures(const UT_StringRef &nodetype);
80 
81  // Returns true if the network structure is the same as the network with
82  // root 'node'
83  bool networkMatch(const GT_MaterialNode *node,
84  UT_Set<int> &visited) const;
85  void copyNameToken(const GT_MaterialNode *node,
86  UT_Set<int> &visited);
87 
88  int64 index() const { return myIndex; }
89  int64 uniqueId() const { return myID; }
90 
91  void createUniqueString(UT_TokenString &ts, UT_Set<int> &visited) const;
92 
93  void print();
94 
95 private:
96  void internalPrint(UT_Set<int64> &visited);
97 
99  UT_StringMap<UT_StringHolder> myOutputVars;
100  UT_Options myParms;
101  UT_StringHolder myTypeName;
102  UT_StringHolder myName;
103  UT_StringHolder myToken;
104  int64 myID;
105  int64 myIndex = 0;
106  bool myTimeDep = false;
107 };
108 
109 
110 #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
int64 uniqueId() const
const UT_StringMap< std::pair< GT_MaterialNodePtr, UT_StringHolder > > & inputs() const
A reference counter base class for use with UT_IntrusivePtr.
int64 index() const
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:87
GT_MaterialNode(const GT_MaterialNode &src)
GLuint index
Definition: glcorearb.h:786
const UT_StringRef & name() const
const GLuint * textures
Definition: glcorearb.h:416
FMT_INLINE void print(format_string< T...> fmt, T &&...args)
Definition: core.h:2903
UT_Options & parms()
const UT_Options & parms() const
GLenum src
Definition: glcorearb.h:1793