Blender V2.61 - r43446

DNA_node_types.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, Xavier Thomas
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef DNA_NODE_TYPES_H
00033 #define DNA_NODE_TYPES_H
00034 
00035 #include "DNA_ID.h"
00036 #include "DNA_vec_types.h"
00037 #include "DNA_listBase.h"
00038 #include "DNA_texture_types.h"
00039 #include "DNA_scene_types.h"
00040 
00041 struct ID;
00042 struct ListBase;
00043 struct SpaceNode;
00044 struct bNodeLink;
00045 struct bNodeType;
00046 struct bNodeTreeExec;
00047 struct AnimData;
00048 struct bGPdata;
00049 struct uiBlock;
00050 struct Image;
00051 
00052 #define NODE_MAXSTR 64
00053 
00054 typedef struct bNodeStack {
00055     float vec[4];
00056     float min, max;
00057     void *data;
00058     short hasinput;         /* when input has link, tagged before executing */
00059     short hasoutput;        /* when output is linked, tagged before executing */
00060     short datatype;         /* type of data pointer */
00061     short sockettype;       /* type of socket stack comes from, to remap linking different sockets */
00062     short is_copy;          /* data is a copy of external data (no freeing) */
00063     short external;         /* data is used by external nodes (no freeing) */
00064     short pad[2];
00065 } bNodeStack;
00066 
00067 /* ns->datatype, shadetree only */
00068 #define NS_OSA_VECTORS      1
00069 #define NS_OSA_VALUES       2
00070 
00071 typedef struct bNodeSocket {
00072     struct bNodeSocket *next, *prev, *new_sock;
00073     
00074     char name[64];  /* MAX_NAME */
00075     
00076     void *storage;              /* custom storage */
00077     
00078     short type, flag;
00079     short limit;                /* max. number of links */
00080     short pad1;
00081     
00082     float locx, locy;
00083     
00084     void *default_value;        /* default input value used for unlinked sockets */
00085     
00086     /* execution data */
00087     short stack_index;          /* local stack index */
00088     short stack_type;           /* deprecated, kept for forward compatibility */
00089     int pad3;
00090     void *cache;                /* cached data from execution */
00091     
00092     /* internal data to retrieve relations and groups */
00093     int own_index;              /* group socket identifiers, to find matching pairs after reading files */
00094     int to_index  DNA_DEPRECATED;  /* XXX deprecated, only used for restoring old group node links */
00095     struct bNodeSocket *groupsock;
00096     
00097     struct bNodeLink *link;     /* a link pointer, set in ntreeUpdateTree */
00098 
00099     /* DEPRECATED only needed for do_versions */
00100     bNodeStack ns;              /* custom data for inputs, only UI writes in this */
00101 } bNodeSocket;
00102 
00103 /* sock->type */
00104 #define SOCK_FLOAT          0
00105 #define SOCK_VECTOR         1
00106 #define SOCK_RGBA           2
00107 #define SOCK_SHADER         3
00108 #define SOCK_BOOLEAN        4
00109 #define SOCK_MESH           5
00110 #define SOCK_INT            6
00111 #define NUM_SOCKET_TYPES    7   /* must be last! */
00112 
00113 /* socket side (input/output) */
00114 #define SOCK_IN     1
00115 #define SOCK_OUT    2
00116 
00117 /* sock->flag, first bit is select */
00118     /* hidden is user defined, to hide unused */
00119 #define SOCK_HIDDEN             2
00120     /* only used now for groups... */
00121 #define SOCK_IN_USE             4   /* XXX deprecated */
00122     /* unavailable is for dynamic sockets */
00123 #define SOCK_UNAVAIL            8
00124     /* dynamic socket (can be modified by user) */
00125 #define SOCK_DYNAMIC            16
00126     /* group socket should not be exposed */
00127 #define SOCK_INTERNAL           32
00128     /* socket collapsed in UI */
00129 #define SOCK_COLLAPSED          64
00130     /* hide socket value, if it gets auto default */
00131 #define SOCK_HIDE_VALUE         128
00132     /* socket hidden automatically, to distinguish from manually hidden */
00133 #define SOCK_AUTO_HIDDEN        256
00134 
00135 typedef struct bNodePreview {
00136     unsigned char *rect;
00137     short xsize, ysize;
00138     int pad;
00139 } bNodePreview;
00140 
00141 /* limit data in bNode to what we want to see saved? */
00142 typedef struct bNode {
00143     struct bNode *next, *prev, *new_node;
00144     
00145     char name[64];  /* MAX_NAME */
00146     short type, flag;
00147     short done, level;      /* both for dependency and sorting */
00148     short lasty, menunr;    /* lasty: check preview render status, menunr: browse ID blocks */
00149     short stack_index;      /* for groupnode, offset in global caller stack */
00150     short nr;               /* number of this node in list, used for UI exec events */
00151     
00152     ListBase inputs, outputs;
00153     struct bNode *parent;   /* parent node */
00154     struct ID *id;          /* optional link to libdata */
00155     void *storage;          /* custom data, must be struct, for storage in file */
00156     
00157     float locx, locy;       /* root offset for drawing */
00158     float width, height;    /* node custom width and height */
00159     float miniwidth;        /* node width if hidden */
00160     
00161     int update;             /* update flags */
00162     
00163     char label[64];         /* custom user-defined label, MAX_NAME */
00164     short custom1, custom2; /* to be abused for buttons */
00165     float custom3, custom4;
00166     
00167     short need_exec, exec;  /* need_exec is set as UI execution event, exec is flag during exec */
00168     void *threaddata;       /* optional extra storage for use in thread (read only then!) */
00169     
00170     rctf totr;              /* entire boundbox */
00171     rctf butr;              /* optional buttons area */
00172     rctf prvr;              /* optional preview area */
00173     bNodePreview *preview;  /* optional preview image */
00174     struct uiBlock *block;  /* runtime during drawing */
00175     
00176     struct bNodeType *typeinfo; /* lookup of callbacks and defaults */
00177 } bNode;
00178 
00179 /* node->flag */
00180 #define NODE_SELECT         1
00181 #define NODE_OPTIONS        2
00182 #define NODE_PREVIEW        4
00183 #define NODE_HIDDEN         8
00184 #define NODE_ACTIVE         16
00185 #define NODE_ACTIVE_ID      32
00186 #define NODE_DO_OUTPUT      64
00187 #define NODE_GROUP_EDIT     128
00188     /* free test flag, undefined */
00189 #define NODE_TEST           256
00190     /* composite: don't do node but pass on buffer(s) */
00191 #define NODE_MUTED          512
00192 #define NODE_CUSTOM_NAME    1024    /* deprecated! */
00193     /* group node types: use const outputs by default */
00194 #define NODE_CONST_OUTPUT   (1<<11)
00195     /* node is always behind others */
00196 #define NODE_BACKGROUND     (1<<12)
00197     /* automatic flag for nodes included in transforms */
00198 #define NODE_TRANSFORM      (1<<13)
00199     /* node is active texture */
00200 #define NODE_ACTIVE_TEXTURE (1<<14)
00201 
00202 /* node->update */
00203 /* XXX NODE_UPDATE is a generic update flag. More fine-grained updates
00204  * might be used in the future, but currently all work the same way.
00205  */
00206 #define NODE_UPDATE         0xFFFF  /* generic update flag (includes all others) */
00207 #define NODE_UPDATE_ID      1       /* associated id data block has changed */
00208 
00209 typedef struct bNodeLink {
00210     struct bNodeLink *next, *prev;
00211     
00212     bNode *fromnode, *tonode;
00213     bNodeSocket *fromsock, *tosock;
00214     
00215     int flag;
00216     int pad;
00217 } bNodeLink;
00218 
00219 /* link->flag */
00220 #define NODE_LINKFLAG_HILITE    1       /* link has been successfully validated */
00221 #define NODE_LINK_VALID         2
00222 
00223 /* the basis for a Node tree, all links and nodes reside internal here */
00224 /* only re-usable node trees are in the library though, materials and textures allocate own tree struct */
00225 typedef struct bNodeTree {
00226     ID id;
00227     struct AnimData *adt;       /* animation data (must be immediately after id for utilities to use it) */ 
00228     
00229     struct bGPdata *gpd;        /* grease pencil data */
00230     
00231     ListBase nodes, links;
00232     
00233     int type, init;                 /* set init on fileread */
00234     int cur_index;                  /* sockets in groups have unique identifiers, adding new sockets always 
00235                                        will increase this counter */
00236     int flag;
00237     int update;                     /* update flags */
00238     
00239     int nodetype;                   /* specific node type this tree is used for */
00240     
00241     ListBase inputs, outputs;       /* external sockets for group nodes */
00242     
00243     /* execution data */
00244     /* XXX It would be preferable to completely move this data out of the underlying node tree,
00245      * so node tree execution could finally run independent of the tree itself. This would allow node trees
00246      * to be merely linked by other data (materials, textures, etc.), as ID data is supposed to.
00247      * Execution data is generated from the tree once at execution start and can then be used
00248      * as long as necessary, even while the tree is being modified.
00249      */
00250     struct bNodeTreeExec *execdata;
00251     
00252     /* callbacks */
00253     void (*progress)(void *, float progress);
00254     void (*stats_draw)(void *, char *str);
00255     int (*test_break)(void *);
00256     void *tbh, *prh, *sdh;
00257     
00258 } bNodeTree;
00259 
00260 /* ntree->type, index */
00261 #define NTREE_SHADER        0
00262 #define NTREE_COMPOSIT      1
00263 #define NTREE_TEXTURE       2
00264 #define NUM_NTREE_TYPES     3
00265 
00266 /* ntree->init, flag */
00267 #define NTREE_TYPE_INIT     1
00268 
00269 /* ntree->flag */
00270 #define NTREE_DS_EXPAND     1   /* for animation editors */
00271 /* XXX not nice, but needed as a temporary flags
00272  * for group updates after library linking.
00273  */
00274 #define NTREE_DO_VERSIONS_GROUP_EXPOSE  1024
00275 
00276 /* ntree->update */
00277 #define NTREE_UPDATE            0xFFFF  /* generic update flag (includes all others) */
00278 #define NTREE_UPDATE_LINKS      1       /* links have been added or removed */
00279 #define NTREE_UPDATE_NODES      2       /* nodes or sockets have been added or removed */
00280 #define NTREE_UPDATE_GROUP_IN   16      /* group inputs have changed */
00281 #define NTREE_UPDATE_GROUP_OUT  32      /* group outputs have changed */
00282 #define NTREE_UPDATE_GROUP      48      /* group has changed (generic flag including all other group flags) */
00283 
00284 
00285 /* socket value structs for input buttons */
00286 
00287 typedef struct bNodeSocketValueInt {
00288     int subtype;                /* RNA subtype */
00289     int value;
00290     int min, max;
00291 } bNodeSocketValueInt;
00292 
00293 typedef struct bNodeSocketValueFloat {
00294     int subtype;                /* RNA subtype */
00295     float value;
00296     float min, max;
00297 } bNodeSocketValueFloat;
00298 
00299 typedef struct bNodeSocketValueBoolean {
00300     char value;
00301     char pad[3];
00302 } bNodeSocketValueBoolean;
00303 
00304 typedef struct bNodeSocketValueVector {
00305     int subtype;                /* RNA subtype */
00306     float value[3];
00307     float min, max;
00308 } bNodeSocketValueVector;
00309 
00310 typedef struct bNodeSocketValueRGBA {
00311     float value[4];
00312 } bNodeSocketValueRGBA;
00313 
00314 
00315 /* data structs, for node->storage */
00316 
00317 /* this one has been replaced with ImageUser, keep it for do_versions() */
00318 typedef struct NodeImageAnim {
00319     int frames, sfra, nr;
00320     char cyclic, movie;
00321     short pad;
00322 } NodeImageAnim;
00323 
00324 typedef struct NodeBlurData {
00325     short sizex, sizey;
00326     short samples, maxspeed, minspeed, relative, aspect;
00327     short curved;
00328     float fac, percentx, percenty;
00329     short filtertype;
00330     char bokeh, gamma;
00331     int image_in_width, image_in_height; /* needed for absolute/relative conversions */
00332 } NodeBlurData;
00333 
00334 typedef struct NodeDBlurData {
00335     float center_x, center_y, distance, angle, spin, zoom;
00336     short iter;
00337     char wrap, pad;
00338 } NodeDBlurData;
00339 
00340 typedef struct NodeBilateralBlurData {
00341     float sigma_color, sigma_space;
00342     short iter, pad;
00343 } NodeBilateralBlurData;
00344 
00345 typedef struct NodeHueSat {
00346     float hue, sat, val;
00347 } NodeHueSat;
00348 
00349 typedef struct NodeImageFile {
00350     char name[256];
00351     struct ImageFormatData im_format;
00352     int sfra, efra;
00353 } NodeImageFile;
00354 
00355 typedef struct NodeChroma {
00356     float t1,t2,t3;
00357     float fsize,fstrength,falpha;
00358     float key[4];
00359     short algorithm, channel;
00360 } NodeChroma;
00361 
00362 typedef struct NodeTwoXYs {
00363     short x1, x2, y1, y2;
00364     float fac_x1, fac_x2, fac_y1, fac_y2;
00365 } NodeTwoXYs;
00366 
00367 typedef struct NodeTwoFloats {
00368     float x, y;
00369 } NodeTwoFloats;
00370 
00371 typedef struct NodeGeometry {
00372     char uvname[64];    /* MAX_CUSTOMDATA_LAYER_NAME */
00373     char colname[64];
00374 } NodeGeometry;
00375 
00376 typedef struct NodeVertexCol {
00377     char name[64];
00378 } NodeVertexCol;
00379 
00380 /* qdn: Defocus blur node */
00381 typedef struct NodeDefocus {
00382     char bktype, pad_c1, preview, gamco;
00383     short samples, no_zbuf;
00384     float fstop, maxblur, bthresh, scale;
00385     float rotation, pad_f1;
00386 } NodeDefocus;
00387 
00388 typedef struct NodeScriptDict {
00389     void *dict; /* for PyObject *dict */
00390     void *node; /* for BPy_Node *node */
00391 } NodeScriptDict;
00392 
00393 /* qdn: glare node */
00394 typedef struct NodeGlare {
00395     char quality, type, iter;
00396     char angle, pad_c1, size, pad[2];
00397     float colmod, mix, threshold, fade;
00398     float angle_ofs, pad_f1;
00399 } NodeGlare;
00400 
00401 /* qdn: tonemap node */
00402 typedef struct NodeTonemap {
00403     float key, offset, gamma;
00404     float f, m, a, c;
00405     int type;
00406 } NodeTonemap;
00407 
00408 /* qdn: lens distortion node */
00409 typedef struct NodeLensDist {
00410     short jit, proj, fit, pad;
00411 } NodeLensDist;
00412 
00413 typedef struct NodeColorBalance {
00414     /* for processing */
00415     float slope[3];
00416     float offset[3];
00417     float power[3];
00418     
00419     /* for ui representation */
00420     float lift[3];
00421     float gamma[3];
00422     float gain[3];
00423 
00424     /* temp storage for inverted lift */
00425     float lift_lgg[3];
00426     float gamma_inv[3];
00427 } NodeColorBalance;
00428 
00429 typedef struct NodeColorspill {
00430     short limchan, unspill;
00431     float limscale;
00432     float uspillr, uspillg, uspillb;
00433 } NodeColorspill;
00434 
00435 typedef struct NodeTexBase {
00436     TexMapping tex_mapping;
00437     ColorMapping color_mapping;
00438 } NodeTexBase;
00439 
00440 typedef struct NodeTexSky {
00441     NodeTexBase base;
00442     float sun_direction[3];
00443     float turbidity;
00444 } NodeTexSky;
00445 
00446 typedef struct NodeTexImage {
00447     NodeTexBase base;
00448     int color_space, pad;
00449 } NodeTexImage;
00450 
00451 typedef struct NodeTexChecker {
00452     NodeTexBase base;
00453 } NodeTexChecker;
00454 
00455 typedef struct NodeTexEnvironment {
00456     NodeTexBase base;
00457     int color_space, pad;
00458 } NodeTexEnvironment;
00459 
00460 typedef struct NodeTexGradient {
00461     NodeTexBase base;
00462     int gradient_type;
00463     int pad;
00464 } NodeTexGradient;
00465 
00466 typedef struct NodeTexNoise {
00467     NodeTexBase base;
00468 } NodeTexNoise;
00469 
00470 typedef struct NodeTexVoronoi {
00471     NodeTexBase base;
00472     int coloring;
00473     int pad;
00474 } NodeTexVoronoi;
00475 
00476 typedef struct NodeTexMusgrave {
00477     NodeTexBase base;
00478     int musgrave_type;
00479     int pad;
00480 } NodeTexMusgrave;
00481 
00482 typedef struct NodeTexWave {
00483     NodeTexBase base;
00484     int wave_type;
00485     int pad;
00486 } NodeTexWave;
00487 
00488 typedef struct NodeTexMagic {
00489     NodeTexBase base;
00490     int depth;
00491     int pad;
00492 } NodeTexMagic;
00493 
00494 typedef struct NodeShaderAttribute {
00495     char name[64];
00496 } NodeShaderAttribute;
00497 
00498 /* TEX_output */
00499 typedef struct TexNodeOutput {
00500     char name[64];
00501 } TexNodeOutput;
00502 
00503 /* comp channel matte */
00504 #define CMP_NODE_CHANNEL_MATTE_CS_RGB   1
00505 #define CMP_NODE_CHANNEL_MATTE_CS_HSV   2
00506 #define CMP_NODE_CHANNEL_MATTE_CS_YUV   3
00507 #define CMP_NODE_CHANNEL_MATTE_CS_YCC   4
00508 
00509 /* glossy distributions */
00510 #define SHD_GLOSSY_BECKMANN 0
00511 #define SHD_GLOSSY_SHARP    1
00512 #define SHD_GLOSSY_GGX      2
00513 
00514 /* blend texture */
00515 #define SHD_BLEND_LINEAR            0
00516 #define SHD_BLEND_QUADRATIC         1
00517 #define SHD_BLEND_EASING            2
00518 #define SHD_BLEND_DIAGONAL          3
00519 #define SHD_BLEND_RADIAL            4
00520 #define SHD_BLEND_QUADRATIC_SPHERE  5
00521 #define SHD_BLEND_SPHERICAL         6
00522 
00523 /* noise basis for textures */
00524 #define SHD_NOISE_PERLIN            0
00525 #define SHD_NOISE_VORONOI_F1        1
00526 #define SHD_NOISE_VORONOI_F2        2
00527 #define SHD_NOISE_VORONOI_F3        3
00528 #define SHD_NOISE_VORONOI_F4        4
00529 #define SHD_NOISE_VORONOI_F2_F1     5
00530 #define SHD_NOISE_VORONOI_CRACKLE   6
00531 #define SHD_NOISE_CELL_NOISE        7
00532 
00533 #define SHD_NOISE_SOFT  0
00534 #define SHD_NOISE_HARD  1
00535 
00536 /* voronoi texture */
00537 #define SHD_VORONOI_DISTANCE_SQUARED    0
00538 #define SHD_VORONOI_ACTUAL_DISTANCE     1
00539 #define SHD_VORONOI_MANHATTAN           2
00540 #define SHD_VORONOI_CHEBYCHEV           3
00541 #define SHD_VORONOI_MINKOVSKY_H         4
00542 #define SHD_VORONOI_MINKOVSKY_4         5
00543 #define SHD_VORONOI_MINKOVSKY           6
00544 
00545 #define SHD_VORONOI_INTENSITY   0
00546 #define SHD_VORONOI_CELLS       1
00547 
00548 /* musgrave texture */
00549 #define SHD_MUSGRAVE_MULTIFRACTAL           0
00550 #define SHD_MUSGRAVE_FBM                    1
00551 #define SHD_MUSGRAVE_HYBRID_MULTIFRACTAL    2
00552 #define SHD_MUSGRAVE_RIDGED_MULTIFRACTAL    3
00553 #define SHD_MUSGRAVE_HETERO_TERRAIN         4
00554 
00555 /* wave texture */
00556 #define SHD_WAVE_BANDS      0
00557 #define SHD_WAVE_RINGS      1
00558 
00559 #define SHD_WAVE_SINE   0
00560 #define SHD_WAVE_SAW    1
00561 #define SHD_WAVE_TRI    2
00562 
00563 /* image/environment texture */
00564 #define SHD_COLORSPACE_LINEAR   0
00565 #define SHD_COLORSPACE_SRGB     1
00566 
00567 /* blur node */
00568 #define CMP_NODE_BLUR_ASPECT_NONE       0
00569 #define CMP_NODE_BLUR_ASPECT_Y          1
00570 #define CMP_NODE_BLUR_ASPECT_X          2
00571 
00572 #endif