Blender V2.61 - r43446

BKE_node.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2005 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): Bob Holcomb.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00028 #ifndef BKE_NODE_H
00029 #define BKE_NODE_H
00030 
00035 #include "DNA_listBase.h"
00036 
00037 #include "RNA_types.h"
00038 
00039 /* not very important, but the stack solver likes to know a maximum */
00040 #define MAX_SOCKET  64
00041 
00042 struct bContext;
00043 struct bNode;
00044 struct bNodeLink;
00045 struct bNodeSocket;
00046 struct bNodeStack;
00047 struct bNodeTree;
00048 struct bNodeTreeExec;
00049 struct GPUMaterial;
00050 struct GPUNode;
00051 struct GPUNodeStack;
00052 struct ID;
00053 struct ListBase;
00054 struct Main;
00055 struct uiBlock;
00056 struct uiLayout;
00057 struct MTex;
00058 struct PointerRNA;
00059 struct rctf;
00060 struct RenderData;
00061 struct Scene;
00062 struct Tex;
00063 struct SpaceNode;
00064 struct ARegion;
00065 struct Object;
00066 
00067 /* ************** NODE TYPE DEFINITIONS ***** */
00068 
00077 typedef struct bNodeSocketTemplate {
00078     int type, limit;
00079     char name[64];  /* MAX_NAME */
00080     float val1, val2, val3, val4;   /* default alloc value for inputs */
00081     float min, max;
00082     PropertySubType subtype;
00083     int flag;
00084     
00085     /* after this line is used internal only */
00086     struct bNodeSocket *sock;       /* used to hold verified socket */
00087 } bNodeSocketTemplate;
00088 
00089 typedef void (*NodeSocketButtonFunction)(const struct bContext *C, struct uiBlock *block, 
00090                                          struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock,
00091                                          const char *name, int x, int y, int width);
00092 
00096 typedef struct bNodeSocketType {
00097     int type;
00098     char ui_name[64];   /* MAX_NAME */
00099     char ui_description[128];
00100     int ui_icon;
00101     char ui_color[4];
00102     
00103     const char *value_structname;
00104     int value_structsize;
00105     
00106     NodeSocketButtonFunction buttonfunc;
00107 } bNodeSocketType;
00108 
00112 typedef struct bNodeTemplate {
00113     int type;
00114     
00115     /* group tree */
00116     struct bNodeTree *ngroup;
00117 } bNodeTemplate;
00118 
00123 typedef struct bNodeType {
00124     void *next,*prev;
00125     short needs_free;       /* set for allocated types that need to be freed */
00126     
00127     int type;
00128     char name[64];  /* MAX_NAME */
00129     float width, minwidth, maxwidth;
00130     float height, minheight, maxheight;
00131     short nclass, flag, compatibility;
00132     
00133     /* templates for static sockets */
00134     bNodeSocketTemplate *inputs, *outputs;
00135     
00136     char storagename[64];           /* struct name for DNA */
00137     
00139     void (*drawfunc)(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode, struct bNodeTree *ntree, struct bNode *node);
00141     void (*drawupdatefunc)(const struct bContext *C, struct bNodeTree *ntree, struct bNode *node);
00143     void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
00145     void (*uifuncbut)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
00147     const char *(*labelfunc)(struct bNode *);
00149     int (*resize_area_func)(struct bNode *node, int x, int y);
00150     
00152     void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
00154     void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id);
00155     
00157     void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp);
00159     void (*freestoragefunc)(struct bNode *node);
00161     void (*copystoragefunc)(struct bNode *node, struct bNode *target);
00162     
00164     struct bNodeTemplate (*templatefunc)(struct bNode *);
00168     int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
00169     
00171     void (*inittreefunc)(struct bNodeTree *ntree);
00173     void (*updatetreefunc)(struct bNodeTree *ntree);
00174     
00175     /* group edit callbacks for operators */
00176     /* XXX this is going to be changed as required by the UI */
00177     struct bNodeTree *(*group_edit_get)(struct bNode *node);
00178     struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit);
00179     void (*group_edit_clear)(struct bNode *node);
00180     
00181     
00182     /* **** execution callbacks **** */
00183     void *(*initexecfunc)(struct bNode *node);
00184     void (*freeexecfunc)(struct bNode *node, void *nodedata);
00185     void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **);
00186     /* XXX this alternative exec function has been added to avoid changing all node types.
00187      * when a final generic version of execution code is defined, this will be changed anyway
00188      */
00189     void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **);
00190     /* This is the muting callback.
00191      * XXX Mimics the newexecfunc signature... Not sure all of this will be useful, we will see.
00192      */
00193     void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **);
00194     /* And the muting util.
00195      * Returns links as a ListBase, as pairs of bNodeStack* if in/out bNodeStacks were provided,
00196      * else as pairs of bNodeSocket* if node tree was provided.
00197      */
00198     ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **, struct bNodeStack **,
00199                               struct GPUNodeStack *, struct GPUNodeStack *);
00200     /* gpu */
00201     int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
00202     /* extended gpu function */
00203     int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out);
00204     /* This is the muting gpu callback.
00205      * XXX Mimics the gpuextfunc signature... Not sure all of this will be useful, we will see.
00206      */
00207     int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *, struct GPUNodeStack *, struct GPUNodeStack *);
00208 } bNodeType;
00209 
00210 /* node->exec, now in use for composites (#define for break is same as ready yes) */
00211 #define NODE_PROCESSING 1
00212 #define NODE_READY      2
00213 #define NODE_BREAK      2
00214 #define NODE_FINISHED   4
00215 #define NODE_FREEBUFS   8
00216 #define NODE_SKIPPED    16
00217 
00218 /* sim_exec return value */
00219 #define NODE_EXEC_FINISHED  0
00220 #define NODE_EXEC_SUSPEND   1
00221 
00222 /* nodetype->nclass, for add-menu and themes */
00223 #define NODE_CLASS_INPUT            0
00224 #define NODE_CLASS_OUTPUT           1
00225 #define NODE_CLASS_OP_COLOR         3
00226 #define NODE_CLASS_OP_VECTOR        4
00227 #define NODE_CLASS_OP_FILTER        5
00228 #define NODE_CLASS_GROUP            6
00229 #define NODE_CLASS_FILE             7
00230 #define NODE_CLASS_CONVERTOR        8
00231 #define NODE_CLASS_MATTE            9
00232 #define NODE_CLASS_DISTORT          10
00233 #define NODE_CLASS_OP_DYNAMIC       11
00234 #define NODE_CLASS_PATTERN          12
00235 #define NODE_CLASS_TEXTURE          13
00236 #define NODE_CLASS_EXECUTION        14
00237 #define NODE_CLASS_GETDATA          15
00238 #define NODE_CLASS_SETDATA          16
00239 #define NODE_CLASS_MATH             17
00240 #define NODE_CLASS_MATH_VECTOR      18
00241 #define NODE_CLASS_MATH_ROTATION    19
00242 #define NODE_CLASS_PARTICLES        25
00243 #define NODE_CLASS_TRANSFORM        30
00244 #define NODE_CLASS_COMBINE          31
00245 #define NODE_CLASS_SHADER           40
00246 #define NODE_CLASS_LAYOUT           100
00247 
00248 /* nodetype->compatibility */
00249 #define NODE_OLD_SHADING    1
00250 #define NODE_NEW_SHADING    2
00251 
00252 /* enum values for input/output */
00253 #define SOCK_IN     1
00254 #define SOCK_OUT    2
00255 
00256 struct bNodeTreeExec;
00257 
00258 typedef void (*bNodeTreeCallback)(void *calldata, struct ID *owner_id, struct bNodeTree *ntree);
00259 typedef void (*bNodeClassCallback)(void *calldata, int nclass, const char *name);
00260 typedef struct bNodeTreeType
00261 {
00262     int type;                       /* type identifier */
00263     char idname[64];                /* id name for RNA identification */
00264     
00265     ListBase node_types;            /* type definitions */
00266     
00267     /* callbacks */
00268     void (*free_cache)(struct bNodeTree *ntree);
00269     void (*free_node_cache)(struct bNodeTree *ntree, struct bNode *node);
00270     void (*foreach_nodetree)(struct Main *main, void *calldata, bNodeTreeCallback func);        /* iteration over all node trees */
00271     void (*foreach_nodeclass)(struct Scene *scene, void *calldata, bNodeClassCallback func);    /* iteration over all node classes */
00272 
00273     /* calls allowing threaded composite */
00274     void (*localize)(struct bNodeTree *localtree, struct bNodeTree *ntree);
00275     void (*local_sync)(struct bNodeTree *localtree, struct bNodeTree *ntree);
00276     void (*local_merge)(struct bNodeTree *localtree, struct bNodeTree *ntree);
00277 
00278     /* Tree update. Overrides nodetype->updatetreefunc! */
00279     void (*update)(struct bNodeTree *ntree);
00280     /* Node update. Overrides nodetype->updatefunc! */
00281     void (*update_node)(struct bNodeTree *ntree, struct bNode *node);
00282     
00283     int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link);
00284 
00285     /* Default muting pointers. */
00286     void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **);
00287     ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **, struct bNodeStack **,
00288                               struct GPUNodeStack *, struct GPUNodeStack *);
00289     /* gpu */
00290     int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *, struct GPUNodeStack *, struct GPUNodeStack *);
00291 } bNodeTreeType;
00292 
00293 /* ************** GENERIC API, TREES *************** */
00294 
00295 struct bNodeTreeType *ntreeGetType(int type);
00296 struct bNodeType *ntreeGetNodeType(struct bNodeTree *ntree);
00297 struct bNodeSocketType *ntreeGetSocketType(int type);
00298 
00299 struct bNodeTree *ntreeAddTree(const char *name, int type, int nodetype);
00300 void            ntreeInitTypes(struct bNodeTree *ntree);
00301 
00302 void            ntreeFreeTree(struct bNodeTree *ntree);
00303 struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree);
00304 void            ntreeSwitchID(struct bNodeTree *ntree, struct ID *sce_from, struct ID *sce_to);
00305 void            ntreeMakeLocal(struct bNodeTree *ntree);
00306 int             ntreeHasType(struct bNodeTree *ntree, int type);
00307 
00308 void            ntreeUpdateTree(struct bNodeTree *ntree);
00309 /* XXX Currently each tree update call does call to ntreeVerifyNodes too.
00310  * Some day this should be replaced by a decent depsgraph automatism!
00311  */
00312 void            ntreeVerifyNodes(struct Main *main, struct ID *id);
00313 
00314 void            ntreeGetDependencyList(struct bNodeTree *ntree, struct bNode ***deplist, int *totnodes);
00315 
00316 /* XXX old trees handle output flags automatically based on special output node types and last active selection.
00317  * new tree types have a per-output socket flag to indicate the final output to use explicitly.
00318  */
00319 void            ntreeSetOutput(struct bNodeTree *ntree);
00320 void            ntreeInitPreview(struct bNodeTree *, int xsize, int ysize);
00321 void            ntreeClearPreview(struct bNodeTree *ntree);
00322 
00323 void            ntreeFreeCache(struct bNodeTree *ntree);
00324 
00325 int             ntreeNodeExists(struct bNodeTree *ntree, struct bNode *testnode);
00326 int             ntreeOutputExists(struct bNode *node, struct bNodeSocket *testsock);
00327 struct bNodeTree *ntreeLocalize(struct bNodeTree *ntree);
00328 void            ntreeLocalSync(struct bNodeTree *localtree, struct bNodeTree *ntree);
00329 void            ntreeLocalMerge(struct bNodeTree *localtree, struct bNodeTree *ntree);
00330 
00331 /* ************** GENERIC API, NODES *************** */
00332 
00333 struct bNodeSocket *nodeAddSocket(struct bNodeTree *ntree, struct bNode *node, int in_out, const char *name, int type);
00334 struct bNodeSocket *nodeInsertSocket(struct bNodeTree *ntree, struct bNode *node, int in_out, struct bNodeSocket *next_sock, const char *name, int type);
00335 void nodeRemoveSocket(struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *sock);
00336 void nodeRemoveAllSockets(struct bNodeTree *ntree, struct bNode *node);
00337 
00338 void            nodeAddToPreview(struct bNode *, float *, int, int, int);
00339 
00340 struct bNode    *nodeAddNode(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
00341 void            nodeUnlinkNode(struct bNodeTree *ntree, struct bNode *node);
00342 void            nodeUniqueName(struct bNodeTree *ntree, struct bNode *node);
00343 
00344 void            nodeRegisterType(struct bNodeTreeType *ttype, struct bNodeType *ntype) ;
00345 void            nodeMakeDynamicType(struct bNode *node);
00346 int             nodeDynamicUnlinkText(struct ID *txtid);
00347 
00348 void            nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
00349 struct bNode    *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
00350 
00351 struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
00352 void            nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
00353 void            nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
00354 
00355 void            nodeSpaceCoords(struct bNode *node, float *locx, float *locy);
00356 void            nodeAttachNode(struct bNode *node, struct bNode *parent);
00357 void            nodeDetachNode(struct bNode *node);
00358 
00359 struct bNode    *nodeFindNodebyName(struct bNodeTree *ntree, const char *name);
00360 int             nodeFindNode(struct bNodeTree *ntree, struct bNodeSocket *sock, struct bNode **nodep, int *sockindex, int *in_out);
00361 
00362 struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
00363 int             nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
00364 
00365 void            nodeSetActive(struct bNodeTree *ntree, struct bNode *node);
00366 struct bNode    *nodeGetActive(struct bNodeTree *ntree);
00367 struct bNode    *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
00368 int             nodeSetActiveID(struct bNodeTree *ntree, short idtype, struct ID *id);
00369 void            nodeClearActiveID(struct bNodeTree *ntree, short idtype);
00370 struct bNode    *nodeGetActiveTexture(struct bNodeTree *ntree);
00371 
00372 void            nodeUpdate(struct bNodeTree *ntree, struct bNode *node);
00373 int             nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
00374 
00375 void            nodeFreePreview(struct bNode *node);
00376 
00377 int             nodeSocketIsHidden(struct bNodeSocket *sock);
00378 
00379 /* ************** NODE TYPE ACCESS *************** */
00380 
00381 struct bNodeTemplate nodeMakeTemplate(struct bNode *node);
00382 int             nodeValid(struct bNodeTree *ntree, struct bNodeTemplate *ntemp);
00383 const char*     nodeLabel(struct bNode *node);
00384 struct bNodeTree *nodeGroupEditGet(struct bNode *node);
00385 struct bNodeTree *nodeGroupEditSet(struct bNode *node, int edit);
00386 void            nodeGroupEditClear(struct bNode *node);
00387 
00388 /* Init a new node type struct with default values and callbacks */
00389 void            node_type_base(struct bNodeTreeType *ttype, struct bNodeType *ntype, int type,
00390                                const char *name, short nclass, short flag);
00391 void            node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs);
00392 void            node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth);
00393 void            node_type_init(struct bNodeType *ntype, void (*initfunc)(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp));
00394 void            node_type_valid(struct bNodeType *ntype, int (*validfunc)(struct bNodeTree *ntree, struct bNodeTemplate *ntemp));
00395 void            node_type_storage(struct bNodeType *ntype,
00396                                   const char *storagename,
00397                                   void (*freestoragefunc)(struct bNode *),
00398                                   void (*copystoragefunc)(struct bNode *, struct bNode *));
00399 void            node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *));
00400 void            node_type_template(struct bNodeType *ntype, struct bNodeTemplate (*templatefunc)(struct bNode *));
00401 void            node_type_update(struct bNodeType *ntype,
00402                                  void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node),
00403                                  void (*verifyfunc)(struct bNodeTree *ntree, struct bNode *node, struct ID *id));
00404 void            node_type_tree(struct bNodeType *ntype,
00405                                void (*inittreefunc)(struct bNodeTree *),
00406                                void (*updatetreefunc)(struct bNodeTree *));
00407 void            node_type_group_edit(struct bNodeType *ntype,
00408                                      struct bNodeTree *(*group_edit_get)(struct bNode *node),
00409                                      struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit),
00410                                      void (*group_edit_clear)(struct bNode *node));
00411 
00412 void            node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **,
00413                                                                          struct bNodeStack **));
00414 void            node_type_exec_new(struct bNodeType *ntype,
00415                                    void *(*initexecfunc)(struct bNode *node),
00416                                    void (*freeexecfunc)(struct bNode *node, void *nodedata),
00417                                    void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata,
00418                                                        struct bNodeStack **, struct bNodeStack **));
00419 void            node_type_mute(struct bNodeType *ntype,
00420                                void (*mutefunc)(void *data, int thread, struct bNode *, void *nodedata,
00421                                                 struct bNodeStack **, struct bNodeStack **),
00422                                ListBase (*mutelinksfunc)(struct bNodeTree *, struct bNode *, struct bNodeStack **,
00423                                                          struct bNodeStack **, struct GPUNodeStack*, struct GPUNodeStack*));
00424 void            node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node,
00425                                                                       struct GPUNodeStack *in, struct GPUNodeStack *out));
00426 void            node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node,
00427                                                                              void *nodedata, struct GPUNodeStack *in,
00428                                                                              struct GPUNodeStack *out));
00429 void            node_type_gpu_mute(struct bNodeType *ntype, int (*gpumutefunc)(struct GPUMaterial *, struct bNode *, void *,
00430                                                                                struct GPUNodeStack *, struct GPUNodeStack *));
00431 void            node_type_compatibility(struct bNodeType *ntype, short compatibility);
00432 
00433 /* ************** COMMON NODES *************** */
00434 
00435 #define NODE_GROUP      2
00436 #define NODE_FORLOOP    3
00437 #define NODE_WHILELOOP  4
00438 #define NODE_FRAME      5
00439 #define NODE_GROUP_MENU     10000
00440 #define NODE_DYNAMIC_MENU   20000
00441 
00442 /* look up a socket on a group node by the internal group socket */
00443 struct bNodeSocket *node_group_find_input(struct bNode *gnode, struct bNodeSocket *gsock);
00444 struct bNodeSocket *node_group_find_output(struct bNode *gnode, struct bNodeSocket *gsock);
00445 
00446 struct bNodeSocket *node_group_add_socket(struct bNodeTree *ngroup, const char *name, int type, int in_out);
00447 struct bNodeSocket *node_group_expose_socket(struct bNodeTree *ngroup, struct bNodeSocket *sock, int in_out);
00448 void node_group_expose_all_sockets(struct bNodeTree *ngroup);
00449 void node_group_remove_socket(struct bNodeTree *ngroup, struct bNodeSocket *gsock, int in_out);
00450 
00451 struct bNode    *node_group_make_from_selected(struct bNodeTree *ntree);
00452 int             node_group_ungroup(struct bNodeTree *ntree, struct bNode *gnode);
00453 
00454 /* in node_common.c */
00455 void register_node_type_frame(struct bNodeTreeType *ttype);
00456 
00457 /* ************** SHADER NODES *************** */
00458 
00459 struct ShadeInput;
00460 struct ShadeResult;
00461 
00462 /* note: types are needed to restore callbacks, don't change values */
00463 /* range 1 - 100 is reserved for common nodes */
00464 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
00465 
00466 #define SH_NODE_OUTPUT      1
00467 
00468 #define SH_NODE_MATERIAL    100
00469 #define SH_NODE_RGB         101
00470 #define SH_NODE_VALUE       102
00471 #define SH_NODE_MIX_RGB     103
00472 #define SH_NODE_VALTORGB    104
00473 #define SH_NODE_RGBTOBW     105
00474 #define SH_NODE_TEXTURE     106
00475 #define SH_NODE_NORMAL      107
00476 #define SH_NODE_GEOMETRY    108
00477 #define SH_NODE_MAPPING     109
00478 #define SH_NODE_CURVE_VEC   110
00479 #define SH_NODE_CURVE_RGB   111
00480 #define SH_NODE_CAMERA      114
00481 #define SH_NODE_MATH        115
00482 #define SH_NODE_VECT_MATH   116
00483 #define SH_NODE_SQUEEZE     117
00484 #define SH_NODE_MATERIAL_EXT    118
00485 #define SH_NODE_INVERT      119
00486 #define SH_NODE_SEPRGB      120
00487 #define SH_NODE_COMBRGB     121
00488 #define SH_NODE_HUE_SAT     122
00489 #define NODE_DYNAMIC        123
00490 
00491 #define SH_NODE_OUTPUT_MATERIAL         124
00492 #define SH_NODE_OUTPUT_WORLD            125
00493 #define SH_NODE_OUTPUT_LAMP             126
00494 #define SH_NODE_FRESNEL                 127
00495 #define SH_NODE_MIX_SHADER              128
00496 #define SH_NODE_ATTRIBUTE               129
00497 #define SH_NODE_BACKGROUND              130
00498 #define SH_NODE_BSDF_ANISOTROPIC        131
00499 #define SH_NODE_BSDF_DIFFUSE            132
00500 #define SH_NODE_BSDF_GLOSSY             133
00501 #define SH_NODE_BSDF_GLASS              134
00502 #define SH_NODE_BSDF_TRANSLUCENT        137
00503 #define SH_NODE_BSDF_TRANSPARENT        138
00504 #define SH_NODE_BSDF_VELVET             139
00505 #define SH_NODE_EMISSION                140
00506 #define SH_NODE_NEW_GEOMETRY            141
00507 #define SH_NODE_LIGHT_PATH              142
00508 #define SH_NODE_TEX_IMAGE               143
00509 #define SH_NODE_TEX_SKY                 145
00510 #define SH_NODE_TEX_GRADIENT            146
00511 #define SH_NODE_TEX_VORONOI             147
00512 #define SH_NODE_TEX_MAGIC               148
00513 #define SH_NODE_TEX_WAVE                149
00514 #define SH_NODE_TEX_NOISE               150
00515 #define SH_NODE_TEX_MUSGRAVE            152
00516 #define SH_NODE_TEX_COORD               155
00517 #define SH_NODE_ADD_SHADER              156
00518 #define SH_NODE_TEX_ENVIRONMENT         157
00519 #define SH_NODE_OUTPUT_TEXTURE          158
00520 #define SH_NODE_HOLDOUT                 159
00521 #define SH_NODE_LAYER_WEIGHT            160
00522 #define SH_NODE_VOLUME_TRANSPARENT      161
00523 #define SH_NODE_VOLUME_ISOTROPIC        162
00524 #define SH_NODE_GAMMA               163
00525 #define SH_NODE_TEX_CHECKER         164
00526 
00527 /* custom defines options for Material node */
00528 #define SH_NODE_MAT_DIFF   1
00529 #define SH_NODE_MAT_SPEC   2
00530 #define SH_NODE_MAT_NEG    4
00531 /* custom defines: states for Script node. These are bit indices */
00532 #define NODE_DYNAMIC_READY  0 /* 1 */
00533 #define NODE_DYNAMIC_LOADED 1 /* 2 */
00534 #define NODE_DYNAMIC_NEW    2 /* 4 */
00535 #define NODE_DYNAMIC_UPDATED    3 /* 8 */
00536 #define NODE_DYNAMIC_ADDEXIST   4 /* 16 */
00537 #define NODE_DYNAMIC_ERROR  5 /* 32 */
00538 #define NODE_DYNAMIC_REPARSE    6 /* 64 */
00539 #define NODE_DYNAMIC_SET    15 /* sign */
00540 
00541 /* API */
00542 
00543 struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
00544 void            ntreeShaderEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
00545 void            ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
00546 void            ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
00547 void            nodeShaderSynchronizeID(struct bNode *node, int copyto);
00548 
00549                 /* switch material render loop */
00550 extern void (*node_shader_lamp_loop)(struct ShadeInput *, struct ShadeResult *);
00551 void            set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
00552 
00553 void            ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMaterial *mat);
00554 
00555 
00556 /* ************** COMPOSITE NODES *************** */
00557 
00558 /* output socket defines */
00559 #define RRES_OUT_IMAGE      0
00560 #define RRES_OUT_ALPHA      1
00561 #define RRES_OUT_Z          2
00562 #define RRES_OUT_NORMAL     3
00563 #define RRES_OUT_UV         4
00564 #define RRES_OUT_VEC        5
00565 #define RRES_OUT_RGBA       6
00566 #define RRES_OUT_DIFF       7
00567 #define RRES_OUT_SPEC       8
00568 #define RRES_OUT_SHADOW     9
00569 #define RRES_OUT_AO         10
00570 #define RRES_OUT_REFLECT    11
00571 #define RRES_OUT_REFRACT    12
00572 #define RRES_OUT_INDIRECT   13
00573 #define RRES_OUT_INDEXOB    14
00574 #define RRES_OUT_INDEXMA    15
00575 #define RRES_OUT_MIST       16
00576 #define RRES_OUT_EMIT       17
00577 #define RRES_OUT_ENV        18
00578 
00579 /* note: types are needed to restore callbacks, don't change values */
00580 #define CMP_NODE_VIEWER     201
00581 #define CMP_NODE_RGB        202
00582 #define CMP_NODE_VALUE      203
00583 #define CMP_NODE_MIX_RGB    204
00584 #define CMP_NODE_VALTORGB   205
00585 #define CMP_NODE_RGBTOBW    206
00586 #define CMP_NODE_NORMAL     207
00587 #define CMP_NODE_CURVE_VEC  208
00588 #define CMP_NODE_CURVE_RGB  209
00589 #define CMP_NODE_ALPHAOVER  210
00590 #define CMP_NODE_BLUR       211
00591 #define CMP_NODE_FILTER     212
00592 #define CMP_NODE_MAP_VALUE  213
00593 #define CMP_NODE_TIME       214
00594 #define CMP_NODE_VECBLUR    215
00595 #define CMP_NODE_SEPRGBA    216
00596 #define CMP_NODE_SEPHSVA    217
00597 #define CMP_NODE_SETALPHA   218
00598 #define CMP_NODE_HUE_SAT    219
00599 #define CMP_NODE_IMAGE      220
00600 #define CMP_NODE_R_LAYERS   221
00601 #define CMP_NODE_COMPOSITE  222
00602 #define CMP_NODE_OUTPUT_FILE    223
00603 #define CMP_NODE_TEXTURE    224
00604 #define CMP_NODE_TRANSLATE  225
00605 #define CMP_NODE_ZCOMBINE   226
00606 #define CMP_NODE_COMBRGBA   227
00607 #define CMP_NODE_DILATEERODE    228
00608 #define CMP_NODE_ROTATE     229
00609 #define CMP_NODE_SCALE      230
00610 #define CMP_NODE_SEPYCCA    231
00611 #define CMP_NODE_COMBYCCA   232
00612 #define CMP_NODE_SEPYUVA    233
00613 #define CMP_NODE_COMBYUVA   234
00614 #define CMP_NODE_DIFF_MATTE 235
00615 #define CMP_NODE_COLOR_SPILL    236
00616 #define CMP_NODE_CHROMA_MATTE   237
00617 #define CMP_NODE_CHANNEL_MATTE  238
00618 #define CMP_NODE_FLIP       239
00619 #define CMP_NODE_SPLITVIEWER    240
00620 #define CMP_NODE_INDEX_MASK 241
00621 #define CMP_NODE_MAP_UV     242
00622 #define CMP_NODE_ID_MASK    243
00623 #define CMP_NODE_DEFOCUS    244
00624 #define CMP_NODE_DISPLACE   245
00625 #define CMP_NODE_COMBHSVA   246
00626 #define CMP_NODE_MATH       247
00627 #define CMP_NODE_LUMA_MATTE 248
00628 #define CMP_NODE_BRIGHTCONTRAST 249
00629 #define CMP_NODE_GAMMA      250
00630 #define CMP_NODE_INVERT     251
00631 #define CMP_NODE_NORMALIZE      252
00632 #define CMP_NODE_CROP       253
00633 #define CMP_NODE_DBLUR      254
00634 #define CMP_NODE_BILATERALBLUR  255
00635 #define CMP_NODE_PREMULKEY  256
00636 #define CMP_NODE_DIST_MATTE 257
00637 #define CMP_NODE_VIEW_LEVELS    258
00638 #define CMP_NODE_COLOR_MATTE 259
00639 #define CMP_NODE_COLORBALANCE 260
00640 #define CMP_NODE_HUECORRECT 261
00641 #define CMP_NODE_MOVIECLIP  262
00642 #define CMP_NODE_STABILIZE2D    263
00643 #define CMP_NODE_TRANSFORM  264
00644 #define CMP_NODE_MOVIEDISTORTION    265
00645 #define CMP_NODE_DOUBLEEDGEMASK    266
00646 
00647 #define CMP_NODE_GLARE      301
00648 #define CMP_NODE_TONEMAP    302
00649 #define CMP_NODE_LENSDIST   303
00650 
00651 /* channel toggles */
00652 #define CMP_CHAN_RGB        1
00653 #define CMP_CHAN_A          2
00654 #define CMP_CHAN_R          4
00655 #define CMP_CHAN_G          8
00656 #define CMP_CHAN_B          16
00657 
00658 /* filter types */
00659 #define CMP_FILT_SOFT       0
00660 #define CMP_FILT_SHARP      1
00661 #define CMP_FILT_LAPLACE    2
00662 #define CMP_FILT_SOBEL      3
00663 #define CMP_FILT_PREWITT    4
00664 #define CMP_FILT_KIRSCH     5
00665 #define CMP_FILT_SHADOW     6
00666 
00667 /* scale node type, in custom1 */
00668 #define CMP_SCALE_RELATIVE      0
00669 #define CMP_SCALE_ABSOLUTE      1
00670 #define CMP_SCALE_SCENEPERCENT  2
00671 #define CMP_SCALE_RENDERPERCENT 3
00672 
00673 
00674 /* API */
00675 struct CompBuf;
00676 struct bNodeTreeExec *ntreeCompositBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
00677 void ntreeCompositEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
00678 void ntreeCompositExecTree(struct bNodeTree *ntree, struct RenderData *rd, int do_previews);
00679 void ntreeCompositTagRender(struct Scene *sce);
00680 int ntreeCompositTagAnimated(struct bNodeTree *ntree);
00681 void ntreeCompositTagGenerators(struct bNodeTree *ntree);
00682 void ntreeCompositForceHidden(struct bNodeTree *ntree, struct Scene *scene);
00683 void ntreeCompositClearTags(struct bNodeTree *ntree);
00684 
00685 
00686 /* ************** TEXTURE NODES *************** */
00687 
00688 struct TexResult;
00689 
00690 #define TEX_NODE_OUTPUT     401
00691 #define TEX_NODE_CHECKER    402
00692 #define TEX_NODE_TEXTURE    403
00693 #define TEX_NODE_BRICKS     404
00694 #define TEX_NODE_MATH       405
00695 #define TEX_NODE_MIX_RGB    406
00696 #define TEX_NODE_RGBTOBW    407
00697 #define TEX_NODE_VALTORGB   408
00698 #define TEX_NODE_IMAGE      409
00699 #define TEX_NODE_CURVE_RGB  410
00700 #define TEX_NODE_INVERT     411
00701 #define TEX_NODE_HUE_SAT    412
00702 #define TEX_NODE_CURVE_TIME 413
00703 #define TEX_NODE_ROTATE     414
00704 #define TEX_NODE_VIEWER     415
00705 #define TEX_NODE_TRANSLATE  416
00706 #define TEX_NODE_COORD      417
00707 #define TEX_NODE_DISTANCE   418
00708 #define TEX_NODE_COMPOSE    419
00709 #define TEX_NODE_DECOMPOSE  420
00710 #define TEX_NODE_VALTONOR   421
00711 #define TEX_NODE_SCALE      422
00712 #define TEX_NODE_AT         423
00713 
00714 /* 501-599 reserved. Use like this: TEX_NODE_PROC + TEX_CLOUDS, etc */
00715 #define TEX_NODE_PROC      500
00716 #define TEX_NODE_PROC_MAX  600
00717 
00718 /* API */
00719 int  ntreeTexTagAnimated(struct bNodeTree *ntree);
00720 void ntreeTexSetPreviewFlag(int);
00721 void ntreeTexCheckCyclics(struct bNodeTree *ntree);
00722 char* ntreeTexOutputMenu(struct bNodeTree *ntree);
00723 
00724 struct bNodeTreeExec *ntreeTexBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
00725 void ntreeTexEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
00726 int ntreeTexExecTree(struct bNodeTree *ntree, struct TexResult *target, float *coord, float *dxt, float *dyt, int osatex, short thread, struct Tex *tex, short which_output, int cfra, int preview, struct ShadeInput *shi, struct MTex *mtex);
00727 
00728 
00729 /*************************************************/
00730 
00731 void init_nodesystem(void);
00732 void free_nodesystem(void);
00733 
00734 void clear_scene_in_nodes(struct Main *bmain, struct Scene *sce);
00735 
00736 #endif