ai_nodes.h
Go to the documentation of this file.
1 // Copyright 2020 Autodesk, Inc. All rights reserved.
2 //
3 // Use of this software is subject to the terms of the Autodesk license
4 // agreement provided at the time of installation or download, or which
5 // otherwise accompanies this software in either electronic or hard copy form.
6 
12 #pragma once
13 #include "ai_node_entry.h"
14 #include "ai_params.h"
15 #include "ai_api.h"
16 #include "ai_string.h"
17 
18 // forward declarations
19 class AtUniverse;
20 struct AtList;
21 struct AtNodeEntry;
22 struct AtUserParamEntry;
23 struct AtUserParamIterator;
24 
63 struct AtNode;
64 
71 #define node_parameters \
72 static void Parameters(AtList* params, AtNodeEntry* nentry)
73 
75 #define node_plugin_initialize \
76 static bool PluginInitialize(void** plugin_data); \
77 AI_OPTIONAL_METHOD_INSTALL(ai_common_mtds, PluginInitialize) \
78 static bool PluginInitialize(void** plugin_data)
79 
81 #define node_plugin_cleanup \
82 static void PluginCleanup(void* plugin_data); \
83 AI_OPTIONAL_METHOD_INSTALL(ai_common_mtds, PluginCleanup) \
84 static void PluginCleanup(void* plugin_data)
85 
87 #define node_initialize \
88 static void Initialize(AtNode* node)
89 
91 #define node_update \
92 static void Update(AtNode* node)
93 
95 #define node_finish \
96 static void Finish(AtNode* node)
97 
99 #define node_loader \
100 AI_EXPORT_LIB bool NodeLoader(int i, AtNodeLib* node)
101 /* \}*/
102 
104 #define AI_INSTANCE_COMMON_METHODS \
105 node_parameters; \
106 node_initialize; \
107 node_update; \
108 node_finish; \
109 static AtCommonMethods ai_common_mtds = { \
110  NULL, \
111  NULL, \
112  Parameters, \
113  Initialize, \
114  Update, \
115  Finish \
116 };
117 
119 #define AI_INSTANCE_COMMON_SHAPE_METHODS \
120 node_parameters; \
121 static AtCommonMethods ai_common_mtds = { \
122  NULL, \
123  NULL, \
124  Parameters, \
125  NULL, \
126  NULL, \
127  NULL \
128 };
129 
134 AI_API AtNode* AiNode (AtUniverse* universe, const AtString nentry_name, const AtString name = AtString(), const AtNode* parent = NULL);
135 AI_API AI_PURE AtNode* AiNodeLookUpByName (const AtUniverse* universe, const AtString name, const AtNode* parent = NULL);
136 AI_API bool AiNodeDeclare (AtNode* node, const AtString param, const char* declaration);
137 AI_API AI_PURE const AtUserParamEntry* AiNodeLookUpUserParameter (const AtNode* node, const AtString param);
138 AI_API AI_PURE bool AiNodeIs (const AtNode* node, AtString str);
139 AI_API void AiNodeReset (AtNode* node);
140 AI_API void AiNodeResetParameter (AtNode* node, const char* param);
141 AI_API AtNode* AiNodeClone (const AtNode* node, const AtString new_name = AtString(), const AtNode* parent = NULL);
142 AI_API bool AiNodeDestroy (AtNode* node);
143 AI_API void AiNodeReplace (AtNode* old_node, AtNode* new_node, bool remove);
144 AI_API bool AiNodeLink (AtNode* src, const char* input, AtNode* target);
145 AI_API bool AiNodeLinkOutput (AtNode* src, const char* output, AtNode* target, const char* input);
146 AI_API bool AiNodeUnlink (AtNode* node, const char* input);
147 AI_API AI_PURE bool AiNodeIsLinked (const AtNode* node, const char* input);
148 AI_API AtNode* AiNodeGetLink (const AtNode* node, const char* input, int* comp = NULL);
149 AI_API AI_PURE const char* AiNodeGetName (const AtNode* node);
150 AI_API AI_PURE const AtNodeEntry* AiNodeGetNodeEntry (const AtNode* node);
151 AI_API AI_PURE void* AiNodeGetLocalData (const AtNode* node);
152 AI_API void AiNodeSetLocalData (AtNode* node, void* data);
153 AI_API AI_PURE void* AiNodeGetPluginData (const AtNode* node);
154 AI_API void AiNodeSetDisabled (AtNode* node, bool disabled);
155 AI_API AI_PURE bool AiNodeIsDisabled (const AtNode* node);
156 AI_API AI_PURE AtNode* AiNodeGetParent (const AtNode* node);
157 AI_API AI_PURE AtUniverse* AiNodeGetUniverse (const AtNode* node);
158 AI_API AtUserParamIterator* AiNodeGetUserParamIterator(const AtNode* node);
159 
160 #ifdef AI_CPU_COMPILER
161 // old API (assuming default universe) is deprecated
162 inline AI_DEPRECATED AtNode* AiNode (const AtString nentry_name, const AtString name = AtString(), const AtNode* parent = NULL) { return AiNode(NULL, nentry_name, name, parent); }
163 inline AI_DEPRECATED AtNode* AiNodeLookUpByName (const AtString name, const AtNode* parent = NULL) { return AiNodeLookUpByName(NULL, name, parent); }
164 
165 // these are slower than the AtString versions
166 inline AI_DEPRECATED AtNode* AiNode (AtUniverse* universe, const char* nentry_name, const char* name = "", const AtNode* parent = NULL) { return AiNode(universe, AtString(nentry_name), AtString(name), parent); }
167 inline AI_DEPRECATED AtNode* AiNode (const char* nentry_name, const char* name = "", const AtNode* parent = NULL) { return AiNode(NULL, AtString(nentry_name), AtString(name), parent); }
168 inline AI_DEPRECATED AtNode* AiNodeLookUpByName (const AtUniverse* universe, const char* name, const AtNode* parent = NULL) { return AiNodeLookUpByName(universe, AtString(name), parent); }
169 inline AI_DEPRECATED AtNode* AiNodeLookUpByName (const char* name, const AtNode* parent = NULL) { return AiNodeLookUpByName(NULL, AtString(name), parent); }
170 inline AI_DEPRECATED bool AiNodeDeclare (AtNode* node, const char* param, const char* declaration) { return AiNodeDeclare(node, AtString(param), declaration); }
171 inline AI_DEPRECATED const AtUserParamEntry* AiNodeLookUpUserParameter (const AtNode* node, const char* param) { return AiNodeLookUpUserParameter(node, AtString(param)); }
172 #endif
173 /* \}*/
174 
179 AI_API void AiUserParamIteratorDestroy(AtUserParamIterator* iter);
180 AI_API const AtUserParamEntry* AiUserParamIteratorGetNext(AtUserParamIterator* iter);
181 AI_API bool AiUserParamIteratorFinished(const AtUserParamIterator* iter);
182 /* \}*/
183 
188 AI_API void AiNodeSetByte (AtNode* node, const AtString param, uint8_t val);
189 AI_API void AiNodeSetInt (AtNode* node, const AtString param, int val);
190 AI_API void AiNodeSetUInt (AtNode* node, const AtString param, unsigned int val);
191 AI_API void AiNodeSetBool (AtNode* node, const AtString param, bool val);
192 AI_API void AiNodeSetFlt (AtNode* node, const AtString param, float val);
193 AI_API void AiNodeSetPtr (AtNode* node, const AtString param, void* val);
194 AI_API void AiNodeSetArray (AtNode* node, const AtString param, AtArray* val);
195 AI_API void AiNodeSetMatrix(AtNode* node, const AtString param, AtMatrix val);
196 AI_API void AiNodeSetStr (AtNode* node, const AtString param, const AtString str);
197 AI_API void AiNodeSetRGB (AtNode* node, const AtString param, float r, float g, float b);
198 AI_API void AiNodeSetRGBA (AtNode* node, const AtString param, float r, float g, float b, float a);
199 AI_API void AiNodeSetVec (AtNode* node, const AtString param, float x, float y, float z);
200 AI_API void AiNodeSetVec2 (AtNode* node, const AtString param, float x, float y);
201 
202 #ifdef AI_CPU_COMPILER
203 // these are slower than the AtString versions
204 inline AI_DEPRECATED void AiNodeSetByte (AtNode* node, const char* param, uint8_t val) { AiNodeSetByte (node, AtString(param), val); }
205 inline AI_DEPRECATED void AiNodeSetInt (AtNode* node, const char* param, int val) { AiNodeSetInt (node, AtString(param), val); }
206 inline AI_DEPRECATED void AiNodeSetUInt (AtNode* node, const char* param, unsigned int val) { AiNodeSetUInt (node, AtString(param), val); }
207 inline AI_DEPRECATED void AiNodeSetBool (AtNode* node, const char* param, bool val) { AiNodeSetBool (node, AtString(param), val); }
208 inline AI_DEPRECATED void AiNodeSetFlt (AtNode* node, const char* param, float val) { AiNodeSetFlt (node, AtString(param), val); }
209 inline AI_DEPRECATED void AiNodeSetPtr (AtNode* node, const char* param, void* val) { AiNodeSetPtr (node, AtString(param), val); }
210 inline AI_DEPRECATED void AiNodeSetArray (AtNode* node, const char* param, AtArray* val) { AiNodeSetArray (node, AtString(param), val); }
211 inline AI_DEPRECATED void AiNodeSetMatrix(AtNode* node, const char* param, AtMatrix val) { AiNodeSetMatrix(node, AtString(param), val); }
212 inline AI_DEPRECATED void AiNodeSetStr (AtNode* node, const char* param, const char* str) { AiNodeSetStr (node, AtString(param), AtString(str)); }
213 inline AI_DEPRECATED void AiNodeSetRGB (AtNode* node, const char* param, float r, float g, float b) { AiNodeSetRGB (node, AtString(param), r, g, b); }
214 inline AI_DEPRECATED void AiNodeSetRGBA (AtNode* node, const char* param, float r, float g, float b, float a) { AiNodeSetRGBA (node, AtString(param), r, g, b, a); }
215 inline AI_DEPRECATED void AiNodeSetVec (AtNode* node, const char* param, float x, float y, float z) { AiNodeSetVec (node, AtString(param), x, y, z); }
216 inline AI_DEPRECATED void AiNodeSetVec2 (AtNode* node, const char* param, float x, float y) { AiNodeSetVec2 (node, AtString(param), x, y); }
217 #endif
218 
219 AI_API void AiNodeSetAttributes(AtNode *node, const char* attributes);
220 /* \}*/
221 
226 AI_API uint8_t AiNodeGetByte (const AtNode* node, const AtString param);
227 AI_API int AiNodeGetInt (const AtNode* node, const AtString param);
228 AI_API unsigned int AiNodeGetUInt (const AtNode* node, const AtString param);
229 AI_API bool AiNodeGetBool (const AtNode* node, const AtString param);
230 AI_API float AiNodeGetFlt (const AtNode* node, const AtString param);
231 AI_API AtRGB AiNodeGetRGB (const AtNode* node, const AtString param);
232 AI_API AtRGBA AiNodeGetRGBA (const AtNode* node, const AtString param);
233 AI_API AtVector AiNodeGetVec (const AtNode* node, const AtString param);
234 AI_API AtVector2 AiNodeGetVec2 (const AtNode* node, const AtString param);
235 AI_API AtString AiNodeGetStr (const AtNode* node, const AtString param);
236 AI_API void* AiNodeGetPtr (const AtNode* node, const AtString param);
237 AI_API AtArray* AiNodeGetArray (const AtNode* node, const AtString param);
238 AI_API AtMatrix AiNodeGetMatrix(const AtNode* node, const AtString param);
239 
240 #ifdef AI_CPU_COMPILER
241 // these are slower than the AtString versions
242 inline AI_DEPRECATED uint8_t AiNodeGetByte (const AtNode* node, const char* param) { return AiNodeGetByte (node, AtString(param)); }
243 inline AI_DEPRECATED int AiNodeGetInt (const AtNode* node, const char* param) { return AiNodeGetInt (node, AtString(param)); }
244 inline AI_DEPRECATED unsigned int AiNodeGetUInt (const AtNode* node, const char* param) { return AiNodeGetUInt (node, AtString(param)); }
245 inline AI_DEPRECATED bool AiNodeGetBool (const AtNode* node, const char* param) { return AiNodeGetBool (node, AtString(param)); }
246 inline AI_DEPRECATED float AiNodeGetFlt (const AtNode* node, const char* param) { return AiNodeGetFlt (node, AtString(param)); }
247 inline AI_DEPRECATED AtRGB AiNodeGetRGB (const AtNode* node, const char* param) { return AiNodeGetRGB (node, AtString(param)); }
248 inline AI_DEPRECATED AtRGBA AiNodeGetRGBA (const AtNode* node, const char* param) { return AiNodeGetRGBA (node, AtString(param)); }
249 inline AI_DEPRECATED AtVector AiNodeGetVec (const AtNode* node, const char* param) { return AiNodeGetVec (node, AtString(param)); }
250 inline AI_DEPRECATED AtVector2 AiNodeGetVec2 (const AtNode* node, const char* param) { return AiNodeGetVec2 (node, AtString(param)); }
251 inline AI_DEPRECATED AtString AiNodeGetStr (const AtNode* node, const char* param) { return AiNodeGetStr (node, AtString(param)); }
252 inline AI_DEPRECATED void* AiNodeGetPtr (const AtNode* node, const char* param) { return AiNodeGetPtr (node, AtString(param)); }
253 inline AI_DEPRECATED AtArray* AiNodeGetArray (const AtNode* node, const char* param) { return AiNodeGetArray (node, AtString(param)); }
254 inline AI_DEPRECATED AtMatrix AiNodeGetMatrix(const AtNode* node, const char* param) { return AiNodeGetMatrix(node, AtString(param)); }
255 
256 /* \}*/
257 
258 /*\}*/
259 
260 #define AiNodeDeclareGPULocalData(type) namespace {}
261 #endif
AI_API void AiUserParamIteratorDestroy(AtUserParamIterator *iter)
Destroys a user param iterator when it is no longer needed.
Definition: ai_nodes.cpp:162
AI_API bool AiNodeUnlink(AtNode *node, const char *input)
Removes a connection from a node input parameter.
Definition: ai_nodes.cpp:456
AI_API AtNode * AiNodeGetLink(const AtNode *node, const char *input, int *comp=NULL)
Returns the node connected to a given node input parameter.
Definition: ai_nodes.cpp:508
This represents a universe in Arnold.
RGB color.
Definition: ai_color.h:31
AI_API bool AiUserParamIteratorFinished(const AtUserParamIterator *iter)
Returns true if there are no more user parameters to iterate over.
Definition: ai_nodes.cpp:204
AI_API const AtUserParamEntry * AiUserParamIteratorGetNext(AtUserParamIterator *iter)
Returns current user param entry and points user param iterator to the next one.
Definition: ai_nodes.cpp:193
AI_API bool AiNodeDeclare(AtNode *node, const AtString param, const char *declaration)
Declare a user-defined parameter for this node.
Definition: ai_nodes.cpp:719
AI_API void AiNodeSetLocalData(AtNode *node, void *data)
Sets local data pointer in the node.
Definition: ai_nodes.cpp:261
AI_API void AiNodeResetParameter(AtNode *node, const char *param)
Reset a node parameter to its default value and remove any links to that parameter.
Definition: ai_nodes.cpp:576
AI_API bool AiNodeLinkOutput(AtNode *src, const char *output, AtNode *target, const char *input)
Creates a connection between two shader nodes.
Definition: ai_nodes.cpp:431
AI_API void AiNodeSetAttributes(AtNode *node, const char *attributes)
Set the parameters of a node through an attributes string.
Definition: ai_nodes.cpp:921
AI_API AI_PURE bool AiNodeIs(const AtNode *node, AtString str)
Compare the node type against a string.
Definition: ai_nodes.cpp:540
AI_API AI_PURE void * AiNodeGetLocalData(const AtNode *node)
Returns a pointer to the local data in the node.
Definition: ai_nodes.cpp:242
This represents a node in Arnold.
AI_API bool AiNodeLink(AtNode *src, const char *input, AtNode *target)
Creates a connection between two shader nodes.
Definition: ai_nodes.cpp:374
Arnold String allows for fast string comparisons.
Definition: ai_string.h:46
3D point (single precision)
Definition: ai_vector.h:29
AI_API AI_PURE const AtUserParamEntry * AiNodeLookUpUserParameter(const AtNode *node, const AtString param)
Return the user-defined parameter entry that matches a given name.
Definition: ai_nodes.cpp:140
AI_API void AiNodeSetDisabled(AtNode *node, bool disabled)
Disable or enable any node in the scene.
Definition: ai_nodes.cpp:941
Definition: ai_matrix.h:30
DLL export prefix for API functions (necessary for multi-platform development)
2D point
Definition: ai_vector.h:254
AI_API void AiNodeReset(AtNode *node)
Reset all node parameters to their default values and remove any input links.
Definition: ai_nodes.cpp:555
AI_API AI_PURE bool AiNodeIsLinked(const AtNode *node, const char *input)
Returns true if the input parameter is linked.
Definition: ai_nodes.cpp:483
AI_API AI_PURE const AtNodeEntry * AiNodeGetNodeEntry(const AtNode *node)
Return the node entry for this node.
Definition: ai_nodes.cpp:231
AI_API int AiNodeGetInt(const AtNode *node, const AtString param)
Return the value of an integer parameter.
Definition: ai_nodes.cpp:757
This represents a node type in Arnold.
AI_API bool AiNodeDestroy(AtNode *node)
Destroy an existing node.
Definition: ai_nodes.cpp:637
AI_API void AiNodeSetArray(AtNode *node, const AtString param, AtArray *val)
Set the value of an array parameter.
Definition: ai_nodes.cpp:876
AI_API AI_PURE AtUniverse * AiNodeGetUniverse(const AtNode *node)
Returns the universe a node belongs to.
Definition: ai_nodes.cpp:985
RGB color + alpha.
Definition: ai_color.h:266
AI_API AI_PURE void * AiNodeGetPluginData(const AtNode *node)
Returns a pointer to the per plugin data for the node type, as created in the node_plugin_initialize ...
Definition: ai_nodes.cpp:279
AI_API AI_PURE bool AiNodeIsDisabled(const AtNode *node)
Check if a node has been disabled or not.
Definition: ai_nodes.cpp:953
AtNodeEntry type and methods.
AI_API AI_PURE AtNode * AiNodeGetParent(const AtNode *node)
Returns the procedural parent of a node.
Definition: ai_nodes.cpp:972
Node parameters.
AI_API AI_PURE AtNode * AiNodeLookUpByName(const AtUniverse *universe, const AtString name, const AtNode *parent=NULL)
Search for a specific node in the given universe using the specified name string (which can be a simp...
Definition: ai_nodes.cpp:85
AI_API AtUserParamIterator * AiNodeGetUserParamIterator(const AtNode *node)
Creates and returns a new AtUserParamIterator for this node.
Definition: ai_nodes.cpp:152
AI_API AtNode * AiNode(AtUniverse *universe, const AtString nentry_name, const AtString name=AtString(), const AtNode *parent=NULL)
Create a fresh instantiation of a node in a specific Arnold universe.
Definition: ai_nodes.cpp:310
AI_API AtNode * AiNodeClone(const AtNode *node, const AtString new_name=AtString(), const AtNode *parent=NULL)
Return an exact clone of a source node.
Definition: ai_nodes.cpp:614
AI_API void AiNodeReplace(AtNode *old_node, AtNode *new_node, bool remove)
Replace an existing node with another, updating all references to that node.
Definition: ai_nodes.cpp:660
AI_API void AiNodeSetInt(AtNode *node, const AtString param, int val)
Set the value of an integer parameter.
Definition: ai_nodes.cpp:745
AI_API AI_PURE const char * AiNodeGetName(const AtNode *node)
Return the node's name.
Definition: ai_nodes.cpp:220
AtString class for fast comparisons.

© 2020 Autodesk, Inc. · All rights reserved · www.arnoldrenderer.com