diff options
author | Ton Roosendaal <ton@blender.org> | 2008-11-12 22:03:50 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2008-11-12 22:03:50 +0300 |
commit | 8030cb03fd41673b7d687128782a0e21417baaea (patch) | |
tree | b2e25d9a91ecf3713c45a4263f88a934e973e593 /source/blender/src/editnode.c | |
parent | 3fd3a13efc81ce3eafadd5ab31a154bbc25d6e58 (diff) |
Patch #7897 Texture Nodes!
Robin (Frrr) Allen did a decent job on this, so we can also welcome him
as a member in the svn committers team to maintain it!
I do the first commit with some minor fixes:
- get Makefiles work
- fix rounding issue with tiles on unit faces
- removed UI includes from tex node
A nice doc in wiki is here:
http://wiki.blender.org/index.php/User:Frr/TexnodeManual
On the todo for Robin is:
- When using one or more Texture-input nodes, you cannot edit them by activating
(as works now for Material nodes).
- The new "output node" option fails on the default case, when only one
output node is active. It then shows often a blank menu. Will get fixed asap.
- When using a NodeTree-Texture as input node, the menu for 'active output'
should not show. NodeTree should ignore other nodetrees to keep things sane
for now.
- On a future todo is proper usage of "Dxt" and "Dyt" texture vectors for
superior antialising of checkers/bricks.
General note; I know people are dying to get a full integrated shader system
with nodes. In theory we could merge this with Material Nodetrees... but I
rather wait for a solid and very well thought out design proposal for this,
also including design ideas for unifying with a shader language (GPU, CPU).
For the time being this is a nice extension of current textures. :)
Diffstat (limited to 'source/blender/src/editnode.c')
-rw-r--r-- | source/blender/src/editnode.c | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c index 23387673f95..8fb47510485 100644 --- a/source/blender/src/editnode.c +++ b/source/blender/src/editnode.c @@ -40,6 +40,7 @@ #include "DNA_ipo_types.h" #include "DNA_object_types.h" #include "DNA_material_types.h" +#include "DNA_texture_types.h" #include "DNA_node_types.h" #include "DNA_space_types.h" #include "DNA_screen_types.h" @@ -53,6 +54,7 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_material.h" +#include "BKE_texture.h" #include "BKE_scene.h" #include "BKE_utildefines.h" @@ -176,6 +178,9 @@ static void snode_handle_recalc(SpaceNode *snode) allqueue(REDRAWNODE, 1); } + else if(snode->treetype==NTREE_TEXTURE) { + ntreeTexUpdatePreviews(snode->nodetree); + } } static void shader_node_event(SpaceNode *snode, short event) @@ -423,6 +428,36 @@ static void composit_node_event(SpaceNode *snode, short event) } } +static void texture_node_event(SpaceNode *snode, short event) +{ + switch(event) { + case B_REDR: + allqueue(REDRAWNODE, 1); + break; + case B_NODE_LOADIMAGE: + { + bNode *node= nodeGetActive(snode->edittree); + char name[FILE_MAXDIR+FILE_MAXFILE]; + + if(node->id) + strcpy(name, ((Image *)node->id)->name); + else strcpy(name, U.textudir); + if (G.qual & LR_CTRLKEY) { + activate_imageselect(FILE_SPECIAL, "SELECT IMAGE", name, load_node_image); + } else { + activate_fileselect(FILE_SPECIAL, "SELECT IMAGE", name, load_node_image); + } + break; + } + default: + /* B_NODE_EXEC */ + ntreeTexCheckCyclics( snode->nodetree ); + snode_handle_recalc(snode); + allqueue(REDRAWNODE, 1); + break; + } +} + /* assumes nothing being done in ntree yet, sets the default in/out node */ /* called from shading buttons or header */ @@ -486,6 +521,36 @@ void node_composit_default(Scene *sce) ntreeCompositForceHidden(sce->nodetree); } +/* assumes nothing being done in ntree yet, sets the default in/out node */ +/* called from shading buttons or header */ +void node_texture_default(Tex *tx) +{ + bNode *in, *out; + bNodeSocket *fromsock, *tosock; + + /* but lets check it anyway */ + if(tx->nodetree) { + printf("error in texture initialize\n"); + return; + } + + tx->nodetree= ntreeAddTree(NTREE_TEXTURE); + + out= nodeAddNodeType(tx->nodetree, TEX_NODE_OUTPUT, NULL, NULL); + out->locx= 300.0f; out->locy= 300.0f; + + in= nodeAddNodeType(tx->nodetree, TEX_NODE_CHECKER, NULL, NULL); + in->locx= 10.0f; in->locy= 300.0f; + nodeSetActive(tx->nodetree, in); + + fromsock= in->outputs.first; + tosock= out->inputs.first; + nodeAddLink(tx->nodetree, in, fromsock, out, tosock); + + ntreeSolveOrder(tx->nodetree); /* needed for pointers */ + ntreeTexUpdatePreviews(tx->nodetree); +} + /* Here we set the active tree(s), even called for each redraw now, so keep it fast :) */ void snode_set_context(SpaceNode *snode) { @@ -516,6 +581,16 @@ void snode_set_context(SpaceNode *snode) snode->nodetree= G.scene->nodetree; } + else if(snode->treetype==NTREE_TEXTURE) { + if(ob) { + Tex *tx= give_current_texture(ob, ob->actcol); + if(tx) { + snode->from= (ID*)ob; /* please check this; i have no idea what 'from' is. */ + snode->id= &tx->id; + snode->nodetree= tx->nodetree; + } + } + } /* find editable group */ if(snode->nodetree) @@ -608,6 +683,12 @@ static void node_set_active(SpaceNode *snode, bNode *node) } } } + else if(snode->treetype==NTREE_TEXTURE) { + if(node->id) + BIF_preview_changed(-1); + allqueue(REDRAWBUTSSHADING, 1); + allqueue(REDRAWIPO, 0); + } } } @@ -1188,6 +1269,9 @@ static void scale_node(SpaceNode *snode, bNode *node) BIF_undo_push("Scale Node"); allqueue(REDRAWNODE, 1); + + if(snode->nodetree->type == NTREE_TEXTURE) + ntreeTexUpdatePreviews(snode->nodetree); } /* ******************** rename ******************* */ @@ -1702,6 +1786,12 @@ bNode *node_add_node(SpaceNode *snode, int type, float locx, float locy) NodeTagChanged(snode->edittree, node); } + + if(snode->nodetree->type==NTREE_TEXTURE) { + ntreeTexCheckCyclics(snode->edittree); + ntreeTexUpdatePreviews(snode->edittree); + } + return node; } @@ -2481,6 +2571,8 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt) shader_node_event(snode, val); else if(snode->treetype==NTREE_COMPOSIT) composit_node_event(snode, val); + else if(snode->treetype==NTREE_TEXTURE) + texture_node_event(snode, val); break; case RENDERPREVIEW: |