Christmas coding work!
********* Node editor work:
- To enable Nodes for Materials, you have to set the "Use Nodes"
button, in the new Material buttons "Nodes" Panel or in header
of the Node editor. Doing this will disable Material-Layers.
- Nodes now execute materials ("shaders"), but still only using the
previewrender code.
- Nodes have (optional) previews for rendered images.
- Node headers allow to hide buttons and/or preview image
- Nodes can be dragged larger/smaller (right-bottom corner)
- Nodes can be hidden (minimized) with hotkey H
- CTRL+click on an Input Socket gives a popup with default values.
- Changing Material/Texture or Mix node will adjust Node title.
- Click-drag outside of a Node changes cursor to "Knife' and allows to
draw a rect where to cut Links.
- Added new node types RGBtoBW, Texture, In/Output, ColorRamp
- Material Nodes have options to ouput diffuse or specular, or to use
a negative normal. The input socket 'Normal' will force the material
to use that normal, otherwise it uses the normal from the Material
that has the node tree.
- When drawing a link between two not-matching sockets, Blender inserts
a converting node (now only for value/rgb combos)
- When drawing a link to an input socket that's already in use, the
old link will either disappear or flip to another unused socket.
- A click on a Material Node will activate it, and show all its settings
in the Material Buttons. Active Material Nodes draw the material icon
in red.
- A click on any node will show its options in the Node Panel in the
Material buttons.
- Multiple Output Nodes can be used, to sample contents of a tree, but
only one Output is the real one, which is indicated in a different
color and red material icon.
- Added ThemeColors for node types
- ALT+C will convert existing Material-Layers to Node... this currently
only adds the material/mix nodes and connects them. Dunno if this is
worth a lot of coding work to make perfect?
- Press C to call another "Solve order", which will show all possible
cyclic conflicts (if there are).
- Technical: nodes now use "Type" structs which define the
structure of nodes and in/output sockets. The Type structs store all
fixed info, callbacks, and allow to reconstruct saved Nodes to match
what is required by Blender.
- Defining (new) nodes now is as simple as filling in a fixed
Type struct, plus code some callbacks. A doc will be made!
- Node preview images are by default float
********* Icon drawing:
- Cleanup of how old icons were implemented in new system, making
them 16x16 too, correctly centered *and* scaled.
- Made drawing Icons use float coordinates
- Moved BIF_calcpreview_image() into interface_icons.c, renamed it
icon_from_image(). Removed a lot of unneeded Imbuf magic here! :)
- Skipped scaling and imbuf copying when icons are OK size
********* Preview render:
- Huge cleanup of code....
- renaming BIF_xxx calls that only were used internally
- BIF_previewrender() now accepts an argument for rendering method,
so it supports icons, buttonwindow previewrender and node editor
- Only a single BIF_preview_changed() call now exists, supporting all
signals as needed for buttos and node editor
********* More stuff:
- glutil.c, glaDrawPixelsSafe() and glaDrawPixelsTex() now accept format
argument for GL_FLOAT rects
- Made the ColorBand become a built-in button for interface.c
Was a load of cleanup work in buttons_shading.c...
- removed a load of unneeded glBlendFunc() calls
- Fixed bug in calculating text length for buttons (ancient!)
This commit is contained in:
@@ -37,40 +37,113 @@ struct bNodeTree;
|
||||
struct bNode;
|
||||
struct bNodeLink;
|
||||
struct bNodeSocket;
|
||||
struct bNodeStack;
|
||||
struct uiBlock;
|
||||
struct rctf;
|
||||
struct ListBase;
|
||||
|
||||
#define SOCK_IN 1
|
||||
#define SOCK_OUT 2
|
||||
|
||||
/* ************** NODE TYPE DEFINITIONS ***** */
|
||||
|
||||
/* ************** GENERIC API *************** */
|
||||
typedef struct bNodeSocketType {
|
||||
int type, limit;
|
||||
char *name;
|
||||
float val1, val2, val3, val4; /* default alloc value for inputs */
|
||||
float min, max; /* default range for inputs */
|
||||
|
||||
/* after this line is used internal only */
|
||||
struct bNodeSocket *sock; /* to verify */
|
||||
|
||||
} bNodeSocketType;
|
||||
|
||||
typedef struct bNodeType {
|
||||
int type;
|
||||
char *name;
|
||||
float width, minwidth, maxwidth;
|
||||
short nclass, flag;
|
||||
|
||||
bNodeSocketType *inputs, *outputs;
|
||||
|
||||
char storagename[64]; /* struct name for DNA */
|
||||
|
||||
void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **);
|
||||
|
||||
/* after this line is set on startup of blender */
|
||||
int (*butfunc)(struct uiBlock *, struct bNode *, rctf *);
|
||||
|
||||
} bNodeType;
|
||||
|
||||
/* nodetype->nclass, also for themes */
|
||||
#define NODE_CLASS_INPUT 0
|
||||
#define NODE_CLASS_OUTPUT 1
|
||||
#define NODE_CLASS_GENERATOR 2
|
||||
#define NODE_CLASS_OPERATOR 3
|
||||
|
||||
/* ************** GENERIC API, TREES *************** */
|
||||
|
||||
struct bNodeTree *ntreeAddTree(int type);
|
||||
void ntreeInitTypes(struct bNodeTree *ntree);
|
||||
void ntreeFreeTree(struct bNodeTree *ntree);
|
||||
struct bNodeTree *ntreeCopyTree(struct bNodeTree *ntree, int internal_select);
|
||||
|
||||
void ntreeSolveOrder(struct bNodeTree *ntree);
|
||||
|
||||
void ntreeBeginExecTree(struct bNodeTree *ntree, int xsize, int ysize);
|
||||
void ntreeExecTree(struct bNodeTree *ntree);
|
||||
void ntreeEndExecTree(struct bNodeTree *ntree);
|
||||
void ntreeClearPixelTree(struct bNodeTree *, int, int);
|
||||
|
||||
/* ************** GENERIC API, NODES *************** */
|
||||
|
||||
void nodeAddToPreview(struct bNode *, float *, int, int);
|
||||
|
||||
struct bNode *nodeAddNodeType(struct bNodeTree *ntree, int type);
|
||||
void nodeFreeNode(struct bNodeTree *ntree, struct bNode *node);
|
||||
void nodeFreeTree(struct bNodeTree *ntree);
|
||||
|
||||
struct bNode *nodeAddNode(struct bNodeTree *ntree, char *name);
|
||||
struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
|
||||
struct bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node);
|
||||
|
||||
struct bNodeSocket *nodeAddSocket(struct bNode *node, int type, int where, int limit, char *name);
|
||||
struct bNodeLink *nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock);
|
||||
void nodeRemLink(struct bNodeTree *ntree, struct bNodeLink *link);
|
||||
|
||||
struct bNodeLink *nodeFindLink(struct bNodeTree *ntree, struct bNodeSocket *from, struct bNodeSocket *to);
|
||||
int nodeCountSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock);
|
||||
|
||||
void nodeSolveOrder(struct bNodeTree *ntree);
|
||||
void nodeExecTree(struct bNodeTree *ntree);
|
||||
struct bNode *nodeGetActive(struct bNodeTree *ntree);
|
||||
struct bNode *nodeGetActiveID(struct bNodeTree *ntree, short idtype);
|
||||
|
||||
/* ************** SHADER NODES *************** */
|
||||
|
||||
/* types are needed to restore callbacks */
|
||||
#define SH_NODE_TEST 0
|
||||
#define SH_NODE_RGB 1
|
||||
#define SH_NODE_VALUE 2
|
||||
#define SH_NODE_MIX_RGB 3
|
||||
#define SH_NODE_SHOW_RGB 4
|
||||
struct ShadeInput;
|
||||
struct ShadeResult;
|
||||
|
||||
struct bNode *node_shader_add(struct bNodeTree *ntree, int type);
|
||||
void node_shader_set_execfunc(struct bNode *node);
|
||||
/* note: types are needed to restore callbacks, don't change values */
|
||||
#define SH_NODE_INPUT 0
|
||||
#define SH_NODE_OUTPUT 1
|
||||
|
||||
#define SH_NODE_MATERIAL 100
|
||||
#define SH_NODE_RGB 101
|
||||
#define SH_NODE_VALUE 102
|
||||
#define SH_NODE_MIX_RGB 103
|
||||
#define SH_NODE_VALTORGB 104
|
||||
#define SH_NODE_RGBTOBW 105
|
||||
#define SH_NODE_TEXTURE 106
|
||||
|
||||
/* custom defines: options for Material node */
|
||||
#define SH_NODE_MAT_DIFF 1
|
||||
#define SH_NODE_MAT_SPEC 2
|
||||
#define SH_NODE_MAT_NEG 4
|
||||
|
||||
/* the type definitions array */
|
||||
extern bNodeType *node_all_shaders[];
|
||||
|
||||
/* API */
|
||||
struct bNode *nodeShaderAdd(struct bNodeTree *ntree, int type);
|
||||
void nodeShaderSetExecfunc(struct bNode *node);
|
||||
|
||||
void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
|
||||
|
||||
/* switch material render loop */
|
||||
void set_node_shader_lamp_loop(void (*lamp_loop_func)(struct ShadeInput *, struct ShadeResult *));
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user