ai_nodes.h
Go to the documentation of this file.
1// Copyright 2023 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
19class AtUniverse;
20class AtRenderSession;
21struct AtList;
22struct AtNodeEntry;
23struct AtUserParamEntry;
24struct AtUserParamIterator;
25
64struct AtNode;
65
72#define node_parameters \
73static void Parameters(AtList* params, AtNodeEntry* nentry)
74
76#define node_plugin_initialize \
77static bool PluginInitialize(void** plugin_data); \
78AI_OPTIONAL_METHOD_INSTALL(ai_common_mtds, PluginInitialize) \
79static bool PluginInitialize(void** plugin_data)
80
82#define node_plugin_cleanup \
83static void PluginCleanup(void* plugin_data); \
84AI_OPTIONAL_METHOD_INSTALL(ai_common_mtds, PluginCleanup) \
85static void PluginCleanup(void* plugin_data)
86
102#define node_initialize \
103static void Initialize(AtRenderSession* render_session, AtNode* node)
104
116#define node_update \
117static void Update(AtRenderSession* render_session, AtNode* node)
118
131#define node_finish \
132static void Finish(AtNode* node)
133
135#define node_loader \
136AI_EXPORT_LIB bool NodeLoader(int i, AtNodeLib* node)
137/* \}*/
138
140#define AI_INSTANCE_COMMON_METHODS \
141node_parameters; \
142node_initialize; \
143node_update; \
144node_finish; \
145static AtCommonMethods ai_common_mtds = { \
146 NULL, \
147 NULL, \
148 Parameters, \
149 Initialize, \
150 Update, \
151 Finish \
152};
153
155#define AI_INSTANCE_COMMON_SHAPE_METHODS \
156node_parameters; \
157static AtCommonMethods ai_common_mtds = { \
158 NULL, \
159 NULL, \
160 Parameters, \
161 NULL, \
162 NULL, \
163 NULL \
164};
165
170AI_API AtNode* AiNode (AtUniverse* universe, const AtString nentry_name, const AtString name = AtString(), const AtNode* parent = NULL);
171AI_API AI_PURE AtNode* AiNodeLookUpByName (const AtUniverse* universe, const AtString name, const AtNode* parent = NULL);
172AI_API bool AiNodeDeclare (AtNode* node, const AtString param, const char* declaration);
173AI_API AI_PURE const AtUserParamEntry* AiNodeLookUpUserParameter (const AtNode* node, const AtString param);
174AI_API AI_PURE bool AiNodeIs (const AtNode* node, AtString str);
175AI_API void AiNodeReset (AtNode* node);
176AI_API void AiNodeResetParameter (AtNode* node, const char* param);
177AI_API AtNode* AiNodeClone (const AtNode* node, const AtString new_name = AtString(), const AtNode* parent = NULL);
178AI_API bool AiNodeDestroy (AtNode* node);
179AI_API void AiNodeReplace (AtNode* old_node, AtNode* new_node, bool remove);
180AI_API bool AiNodeLink (AtNode* src, const char* input, AtNode* target);
181AI_API bool AiNodeLinkOutput (AtNode* src, const char* output, AtNode* target, const char* input);
182AI_API bool AiNodeUnlink (AtNode* node, const char* input);
183AI_API AI_PURE bool AiNodeIsLinked (const AtNode* node, const char* input);
184AI_API AtNode* AiNodeGetLink (const AtNode* node, const char* input, int* comp = NULL);
185AI_API AtNode* AiNodeGetLinkOutput (const AtNode* node, const char* input, int& output_param, int& output_comp);
186AI_API AI_PURE const char* AiNodeGetName (const AtNode* node);
187AI_API AI_PURE const AtNodeEntry* AiNodeGetNodeEntry (const AtNode* node);
188AI_API AI_PURE void* AiNodeGetLocalData (const AtNode* node);
189AI_API void AiNodeSetLocalData (AtNode* node, void* data);
190AI_API AI_PURE void* AiNodeGetPluginData (const AtNode* node);
191AI_API void AiNodeSetDisabled (AtNode* node, bool disabled);
192AI_API AI_PURE bool AiNodeIsDisabled (const AtNode* node);
193AI_API AI_PURE AtNode* AiNodeGetParent (const AtNode* node);
194AI_API AI_PURE AtUniverse* AiNodeGetUniverse (const AtNode* node);
195AI_API AtUserParamIterator* AiNodeGetUserParamIterator(const AtNode* node);
196AI_API AtNode* AiNodeGetProcessedGeometry(AtNode* source_node, AtUniverse* dest_universe);
197AI_API void AiNodeAddDependencyParam (AtNode* consumer, const AtNode* producer, const AtString param);
198AI_API AI_DEPRECATED void AiNodeAddDependency (AtNode* consumer, const AtNode* producer);
199AI_API void AiNodeClearDependency (AtNode* consumer, const AtNode* producer);
200
201inline void AiNodeAddDependency(AtNode* consumer, const AtNode* producer, const AtString param)
202{
203 AiNodeAddDependencyParam(consumer, producer, param);
204}
205
206#ifdef AI_CPU_COMPILER
207
208// these are slower than the AtString versions
209inline 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); }
210inline AI_DEPRECATED AtNode* AiNodeLookUpByName (const AtUniverse* universe, const char* name, const AtNode* parent = NULL) { return AiNodeLookUpByName(universe, AtString(name), parent); }
211inline AI_DEPRECATED bool AiNodeDeclare (AtNode* node, const char* param, const char* declaration) { return AiNodeDeclare(node, AtString(param), declaration); }
212inline AI_DEPRECATED const AtUserParamEntry* AiNodeLookUpUserParameter (const AtNode* node, const char* param) { return AiNodeLookUpUserParameter(node, AtString(param)); }
213#endif
214/* \}*/
215
220AI_API void AiUserParamIteratorDestroy(AtUserParamIterator* iter);
221AI_API const AtUserParamEntry* AiUserParamIteratorGetNext(AtUserParamIterator* iter);
222AI_API bool AiUserParamIteratorFinished(const AtUserParamIterator* iter);
223/* \}*/
224
229AI_API void AiNodeSetByte (AtNode* node, const AtString param, uint8_t val);
230AI_API void AiNodeSetInt (AtNode* node, const AtString param, int val);
231AI_API void AiNodeSetUInt (AtNode* node, const AtString param, unsigned int val);
232AI_API void AiNodeSetBool (AtNode* node, const AtString param, bool val);
233AI_API void AiNodeSetFlt (AtNode* node, const AtString param, float val);
234AI_API void AiNodeSetPtr (AtNode* node, const AtString param, void* val);
235AI_API void AiNodeSetArray (AtNode* node, const AtString param, AtArray* val);
236AI_API void AiNodeSetMatrix(AtNode* node, const AtString param, AtMatrix val);
237AI_API void AiNodeSetStr (AtNode* node, const AtString param, const AtString str);
238AI_API void AiNodeSetRGB (AtNode* node, const AtString param, float r, float g, float b);
239AI_API void AiNodeSetRGBA (AtNode* node, const AtString param, float r, float g, float b, float a);
240AI_API void AiNodeSetVec (AtNode* node, const AtString param, float x, float y, float z);
241AI_API void AiNodeSetVec2 (AtNode* node, const AtString param, float x, float y);
242
243#ifdef AI_CPU_COMPILER
244// these are slower than the AtString versions
245inline AI_DEPRECATED void AiNodeSetByte (AtNode* node, const char* param, uint8_t val) { AiNodeSetByte (node, AtString(param), val); }
246inline AI_DEPRECATED void AiNodeSetInt (AtNode* node, const char* param, int val) { AiNodeSetInt (node, AtString(param), val); }
247inline AI_DEPRECATED void AiNodeSetUInt (AtNode* node, const char* param, unsigned int val) { AiNodeSetUInt (node, AtString(param), val); }
248inline AI_DEPRECATED void AiNodeSetBool (AtNode* node, const char* param, bool val) { AiNodeSetBool (node, AtString(param), val); }
249inline AI_DEPRECATED void AiNodeSetFlt (AtNode* node, const char* param, float val) { AiNodeSetFlt (node, AtString(param), val); }
250inline AI_DEPRECATED void AiNodeSetPtr (AtNode* node, const char* param, void* val) { AiNodeSetPtr (node, AtString(param), val); }
251inline AI_DEPRECATED void AiNodeSetArray (AtNode* node, const char* param, AtArray* val) { AiNodeSetArray (node, AtString(param), val); }
252inline AI_DEPRECATED void AiNodeSetMatrix(AtNode* node, const char* param, AtMatrix val) { AiNodeSetMatrix(node, AtString(param), val); }
253inline AI_DEPRECATED void AiNodeSetStr (AtNode* node, const char* param, const char* str) { AiNodeSetStr (node, AtString(param), AtString(str)); }
254inline AI_DEPRECATED void AiNodeSetRGB (AtNode* node, const char* param, float r, float g, float b) { AiNodeSetRGB (node, AtString(param), r, g, b); }
255inline 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); }
256inline AI_DEPRECATED void AiNodeSetVec (AtNode* node, const char* param, float x, float y, float z) { AiNodeSetVec (node, AtString(param), x, y, z); }
257inline AI_DEPRECATED void AiNodeSetVec2 (AtNode* node, const char* param, float x, float y) { AiNodeSetVec2 (node, AtString(param), x, y); }
258#endif
259
260AI_API void AiNodeSetAttributes(AtNode *node, const char* attributes);
261
262/* \}*/
263
268AI_API uint8_t AiNodeGetByte (const AtNode* node, const AtString param);
269AI_API int AiNodeGetInt (const AtNode* node, const AtString param);
270AI_API unsigned int AiNodeGetUInt (const AtNode* node, const AtString param);
271AI_API bool AiNodeGetBool (const AtNode* node, const AtString param);
272AI_API float AiNodeGetFlt (const AtNode* node, const AtString param);
273AI_API AtRGB AiNodeGetRGB (const AtNode* node, const AtString param);
274AI_API AtRGBA AiNodeGetRGBA (const AtNode* node, const AtString param);
275AI_API AtVector AiNodeGetVec (const AtNode* node, const AtString param);
276AI_API AtVector2 AiNodeGetVec2 (const AtNode* node, const AtString param);
277AI_API AtString AiNodeGetStr (const AtNode* node, const AtString param);
278AI_API void* AiNodeGetPtr (const AtNode* node, const AtString param);
279AI_API AtArray* AiNodeGetArray (const AtNode* node, const AtString param);
280AI_API AtMatrix AiNodeGetMatrix(const AtNode* node, const AtString param);
281
282#ifdef AI_CPU_COMPILER
283// these are slower than the AtString versions
284inline AI_DEPRECATED uint8_t AiNodeGetByte (const AtNode* node, const char* param) { return AiNodeGetByte (node, AtString(param)); }
285inline AI_DEPRECATED int AiNodeGetInt (const AtNode* node, const char* param) { return AiNodeGetInt (node, AtString(param)); }
286inline AI_DEPRECATED unsigned int AiNodeGetUInt (const AtNode* node, const char* param) { return AiNodeGetUInt (node, AtString(param)); }
287inline AI_DEPRECATED bool AiNodeGetBool (const AtNode* node, const char* param) { return AiNodeGetBool (node, AtString(param)); }
288inline AI_DEPRECATED float AiNodeGetFlt (const AtNode* node, const char* param) { return AiNodeGetFlt (node, AtString(param)); }
289inline AI_DEPRECATED AtRGB AiNodeGetRGB (const AtNode* node, const char* param) { return AiNodeGetRGB (node, AtString(param)); }
290inline AI_DEPRECATED AtRGBA AiNodeGetRGBA (const AtNode* node, const char* param) { return AiNodeGetRGBA (node, AtString(param)); }
291inline AI_DEPRECATED AtVector AiNodeGetVec (const AtNode* node, const char* param) { return AiNodeGetVec (node, AtString(param)); }
292inline AI_DEPRECATED AtVector2 AiNodeGetVec2 (const AtNode* node, const char* param) { return AiNodeGetVec2 (node, AtString(param)); }
293inline AI_DEPRECATED AtString AiNodeGetStr (const AtNode* node, const char* param) { return AiNodeGetStr (node, AtString(param)); }
294inline AI_DEPRECATED void* AiNodeGetPtr (const AtNode* node, const char* param) { return AiNodeGetPtr (node, AtString(param)); }
295inline AI_DEPRECATED AtArray* AiNodeGetArray (const AtNode* node, const char* param) { return AiNodeGetArray (node, AtString(param)); }
296inline AI_DEPRECATED AtMatrix AiNodeGetMatrix(const AtNode* node, const char* param) { return AiNodeGetMatrix(node, AtString(param)); }
297
298/* \}*/
299
300/*\}*/
301
302#define AiNodeDeclareGPULocalData(type) namespace {}
303#endif
DLL export prefix for API functions (necessary for multi-platform development)
AtNodeEntry type and methods.
Node parameters.
AtString class for fast comparisons.
Arnold String allows for fast string comparisons.
Definition: ai_string.h:54
AI_API void AiNodeClearDependency(AtNode *consumer, const AtNode *producer)
Removes any update dependency between a specific consumer and producer nodes.
Definition: ai_nodes.cpp:1174
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:281
AI_API void AiNodeSetLocalData(AtNode *node, void *data)
Sets local data pointer in the node.
Definition: ai_nodes.cpp:232
AI_API AtNode * AiNodeGetProcessedGeometry(AtNode *source_node, AtUniverse *dest_universe)
Returns a node representing the final processed/baked geometry which Arnold renders.
Definition: ai_nodes.cpp:1042
AI_API AtNode * AiNodeGetLinkOutput(const AtNode *node, const char *input, int &output_param, int &output_comp)
Returns the node, node output, and output component connected to a given node input parameter.
Definition: ai_nodes.cpp:515
AI_API AI_PURE AtNode * AiNodeGetParent(const AtNode *node)
Returns the procedural parent of a node.
Definition: ai_nodes.cpp:997
AI_API bool AiNodeUnlink(AtNode *node, const char *input)
Removes a connection from a node input parameter.
Definition: ai_nodes.cpp:433
AI_API AI_PURE const char * AiNodeGetName(const AtNode *node)
Return the node's name.
Definition: ai_nodes.cpp:191
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:164
AI_API AI_PURE bool AiNodeIs(const AtNode *node, AtString str)
Compare the node type against a string.
Definition: ai_nodes.cpp:542
AI_API bool AiNodeLink(AtNode *src, const char *input, AtNode *target)
Creates a connection between two shader nodes.
Definition: ai_nodes.cpp:349
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:485
AI_API AI_PURE bool AiNodeIsDisabled(const AtNode *node)
Check if a node has been disabled or not.
Definition: ai_nodes.cpp:978
AI_API bool AiUserParamIteratorFinished(const AtUserParamIterator *iter)
Returns true if there are no more user parameters to iterate over.
Definition: ai_nodes.cpp:175
AI_API AI_PURE bool AiNodeIsLinked(const AtNode *node, const char *input)
Returns true if the input parameter is linked.
Definition: ai_nodes.cpp:460
AI_API void AiNodeAddDependencyParam(AtNode *consumer, const AtNode *producer, const AtString param)
Use AiNodeAddDependency instead.
Definition: ai_nodes.cpp:1146
AI_API AtUserParamIterator * AiNodeGetUserParamIterator(const AtNode *node)
Creates and returns a new AtUserParamIterator for this node.
Definition: ai_nodes.cpp:123
AI_API AI_PURE AtUniverse * AiNodeGetUniverse(const AtNode *node)
Returns the universe a node belongs to.
Definition: ai_nodes.cpp:1010
AI_API void AiNodeSetArray(AtNode *node, const AtString param, AtArray *val)
Set the value of an array parameter.
Definition: ai_nodes.cpp:877
AI_API void AiNodeSetAttributes(AtNode *node, const char *attributes)
Set the parameters of a node through an attributes string.
Definition: ai_nodes.cpp:946
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:664
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:56
AI_API AI_DEPRECATED void AiNodeAddDependency(AtNode *consumer, const AtNode *producer)
This version of the AiNodeAddDependency API is deprecated.
Definition: ai_nodes.cpp:1161
AI_API int AiNodeGetInt(const AtNode *node, const AtString param)
Return the value of an integer parameter.
Definition: ai_nodes.cpp:758
AI_API void AiUserParamIteratorDestroy(AtUserParamIterator *iter)
Destroys a user param iterator when it is no longer needed.
Definition: ai_nodes.cpp:133
AI_API AI_PURE void * AiNodeGetLocalData(const AtNode *node)
Returns a pointer to the local data in the node.
Definition: ai_nodes.cpp:213
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:111
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:616
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:250
AI_API bool AiNodeDeclare(AtNode *node, const AtString param, const char *declaration)
Declare a user-defined parameter for this node.
Definition: ai_nodes.cpp:720
AI_API bool AiNodeDestroy(AtNode *node)
Destroy an existing node.
Definition: ai_nodes.cpp:640
AI_API AI_PURE const AtNodeEntry * AiNodeGetNodeEntry(const AtNode *node)
Return the node entry for this node.
Definition: ai_nodes.cpp:202
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:578
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:408
AI_API void AiNodeReset(AtNode *node)
Reset all node parameters to their default values and remove any input links.
Definition: ai_nodes.cpp:557
AI_API void AiNodeSetDisabled(AtNode *node, bool disabled)
Disable or enable any node in the scene.
Definition: ai_nodes.cpp:966
AI_API void AiNodeSetInt(AtNode *node, const AtString param, int val)
Set the value of an integer parameter.
Definition: ai_nodes.cpp:746
Definition: ai_matrix.h:30
This represents a node type in Arnold.
This represents a node in Arnold.
RGB color + alpha.
Definition: ai_color.h:267
RGB color.
Definition: ai_color.h:32
This represents a universe in Arnold.
2D point
Definition: ai_vector.h:255
3D point (single precision)
Definition: ai_vector.h:30

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