ai_procedural.h
Go to the documentation of this file.
1// Copyright 2021 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_map.h"
14#include "ai_version.h"
15#ifdef AI_CPU_COMPILER
16
17// forward declaration
18struct AtBBox;
19struct AtNode;
20class AtUniverse;
21
73typedef int (*AtProcInit)(AtNode* node, void** user_ptr);
74
89typedef int (*AtProcCleanup)(const AtNode* node, void* user_ptr);
90
107typedef int (*AtProcNumNodes)(const AtNode* node, void* user_ptr);
108
127typedef AtNode* (*AtProcGetNode)(const AtNode* node, void* user_ptr, int i);
128
133{
134 AI_PROC_BOXES = 0,
135 AI_PROC_POINTS,
136 AI_PROC_POLYGONS,
137};
138
165typedef int (*AtProcViewport)(const AtNode* node, AtUniverse* universe, AtProcViewportMode mode, const AtParamValueMap* params);
166
173};
174
183typedef int (*AtProcFuncPtr)(AtProceduralNodeMethods* methods);
184
186#define AI_PROCEDURAL_NODE_EXPORT_METHODS(tag) \
187AI_INSTANCE_COMMON_SHAPE_METHODS \
188procedural_init; \
189procedural_cleanup; \
190procedural_num_nodes; \
191procedural_get_node; \
192static AtProceduralNodeMethods ai_proc_mtds = { \
193 ProceduralInit, \
194 ProceduralCleanup, \
195 ProceduralNumNodes, \
196 ProceduralGetNode, \
197 NULL, \
198}; \
199static AtNodeMethods ai_node_mtds = { \
200 &ai_common_mtds, \
201 &ai_proc_mtds \
202}; \
203const AtNodeMethods* tag = &ai_node_mtds;
204
205#define procedural_init \
206static int ProceduralInit(AtNode* node, void** user_ptr)
207
208#define procedural_cleanup \
209static int ProceduralCleanup(const AtNode* node, void* user_ptr)
210
211#define procedural_num_nodes \
212static int ProceduralNumNodes(const AtNode* node, void* user_ptr)
213
214#define procedural_get_node \
215static AtNode* ProceduralGetNode(const AtNode* node, void* user_ptr, int i)
216
217#define procedural_update \
218static void Update(AtRenderSession* render_session, AtNode* node); \
219AI_OPTIONAL_METHOD_INSTALL(ai_common_mtds, Update) \
220static void Update(AtRenderSession* render_session, AtNode* node)
221
222#define procedural_finish \
223static void Finish(AtNode* node); \
224AI_OPTIONAL_METHOD_INSTALL(ai_common_mtds, Finish) \
225static void Finish(AtNode* node)
226
227#define procedural_viewport \
228static int ProceduralViewport(const AtNode* node, AtUniverse* universe, AtProcViewportMode mode, const AtParamValueMap* params); \
229AI_OPTIONAL_METHOD_INSTALL(ai_proc_mtds, ProceduralViewport) \
230static int ProceduralViewport(const AtNode* node, AtUniverse* universe, AtProcViewportMode mode, const AtParamValueMap* params)
231
275AI_API int AiProceduralViewport(const AtNode* node, AtUniverse* universe, AtProcViewportMode mode = AI_PROC_BOXES, const AtParamValueMap* params = NULL);
276
286AI_API bool AiProceduralExpand(AtNode *node, const AtParamValueMap* params = NULL);
287/*\}*/
288#endif // AI_CPU_COMPILER
Key/Value storage.
Version number information and checking of backwards-compatibility.
AtProcViewport ProceduralViewport
This is called to get a viewport representation of the given procedural node.
Definition: ai_procedural.h:172
int(* AtProcNumNodes)(const AtNode *node, void *user_ptr)
Procedural node count method.
Definition: ai_procedural.h:107
AtProcViewportMode
Enum with the different modes available for a procedural viewport representation.
Definition: ai_procedural.h:133
int(* AtProcCleanup)(const AtNode *node, void *user_ptr)
Procedural cleanup method.
Definition: ai_procedural.h:89
AtProcCleanup Cleanup
This is called last and should clean up any (temporary) memory used by the procedural.
Definition: ai_procedural.h:169
int(* AtProcViewport)(const AtNode *node, AtUniverse *universe, AtProcViewportMode mode, const AtParamValueMap *params)
Procedural viewport representation method.
Definition: ai_procedural.h:165
int(* AtProcFuncPtr)(AtProceduralNodeMethods *methods)
Procedural function pointer entry-point symbol.
Definition: ai_procedural.h:183
AtNode *(* AtProcGetNode)(const AtNode *node, void *user_ptr, int i)
Procedural node fetching method.
Definition: ai_procedural.h:127
AI_API int AiProceduralViewport(const AtNode *node, AtUniverse *universe, AtProcViewportMode mode=AI_PROC_BOXES, const AtParamValueMap *params=NULL)
Procedural viewport representation method.
Definition: ai_procedural.cpp:6
AI_API bool AiProceduralExpand(AtNode *node, const AtParamValueMap *params=NULL)
Method to expand a procedural node on demand.
Definition: ai_procedural.cpp:11
AtProcInit Init
This is called before expanding the procedural.
Definition: ai_procedural.h:168
AtProcNumNodes NumNodes
This is called to find out how many nodes this procedural will generate.
Definition: ai_procedural.h:170
int(* AtProcInit)(AtNode *node, void **user_ptr)
Procedural init method.
Definition: ai_procedural.h:73
AtProcGetNode GetNode
This is called NumNodes times, once for each node the procedural creates.
Definition: ai_procedural.h:171
3D axis-aligned bounding box (uses single-precision)
Definition: ai_bbox.h:33
This represents a node in Arnold.
Definition: ai_procedural.h:167
This represents a universe in Arnold.

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