diff options
author | Robin Allen <roblovski@gmail.com> | 2009-08-17 22:37:58 +0400 |
---|---|---|
committer | Robin Allen <roblovski@gmail.com> | 2009-08-17 22:37:58 +0400 |
commit | 55b6230464a140c62ec4cea4e11a4a05c8910d13 (patch) | |
tree | 54c9b5dff1a1f20388275f9e450969406f2af864 /source/blender/makesrna | |
parent | 6aeb2f687ae1d41715351ef265a0e0a9af06121a (diff) |
Made texture nodes accessible in the interface.
* Exposed Tex.use_nodes, Tex.nodetree, MTex.which_output in RNA
* Added node controls to texture buttons (Use Nodes and Use Output)
* Made new texture outputs have unique names by default, though unique names still aren't required.
Note: The preview window in the texture buttons only takes which_output into account when in "material" mode, and in the material half of "both" mode; the plain texture display ignores the user's output choice.
This is because ED_preview_draw draws a Tex* and not an MTex* -- still some work to do here.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index ccb5e5b2f95..76cb9986306 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -36,6 +36,9 @@ #include "DNA_material_types.h" #include "DNA_texture_types.h" #include "DNA_world_types.h" +#include "DNA_node_types.h" + +#include "BKE_node.h" #include "WM_types.h" @@ -107,6 +110,43 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) strcpy(str, ""); } +static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerRNA *ptr, int *free) +{ + MTex *mtex= ptr->data; + Tex *tex= mtex->tex; + EnumPropertyItem *item= NULL; + int totitem= 0; + + if(tex) + { + bNodeTree *ntree= tex->nodetree; + if(ntree) + { + EnumPropertyItem tmp= {0, "", 0, "", ""}; + bNode *node; + + tmp.value = 0; + tmp.name = "Not Specified"; + tmp.identifier = "NOT_SPECIFIED"; + RNA_enum_item_add(&item, &totitem, &tmp); + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type == TEX_NODE_OUTPUT) { + tmp.value= node->custom1; + tmp.name= ((TexNodeOutput*)node->storage)->name; + tmp.identifier = tmp.name; + RNA_enum_item_add(&item, &totitem, &tmp); + } + } + } + } + + RNA_enum_item_end(&item, &totitem); + + *free = 1; + return item; +} + static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; @@ -118,6 +158,18 @@ static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) tex->coba= add_colorband(0); } +void rna_Texture_use_nodes_set(PointerRNA *ptr, int v) +{ + Tex *tex= (Tex*)ptr->data; + + tex->use_nodes = v; + tex->type = 0; + + if(v && tex->nodetree==NULL) { + node_texture_default(tex); + } +} + static void rna_ImageTexture_mipmap_set(PointerRNA *ptr, int value) { Tex *tex= (Tex*)ptr->data; @@ -287,6 +339,10 @@ static void rna_def_mtex(BlenderRNA *brna) {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, {0, NULL, 0, NULL, NULL}}; + static EnumPropertyItem output_node_items[] = { + {0, "DUMMY", 0, "Dummy", ""}, + {0, NULL, 0, NULL, NULL}}; + srna= RNA_def_struct(brna, "TextureSlot", NULL); RNA_def_struct_sdna(srna, "MTex"); RNA_def_struct_ui_text(srna, "Texture Slot", "Texture slot defining the mapping and influence of a texture."); @@ -373,6 +429,13 @@ static void rna_def_mtex(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 5, 10, 3); RNA_def_property_ui_text(prop, "Normal Factor", "Amount texture affects normal values."); RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "output_node", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "which_output"); + RNA_def_property_enum_items(prop, output_node_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_TextureSlot_output_node_itemf"); + RNA_def_property_ui_text(prop, "Output Node", "Which output node to use, for node-based textures."); + RNA_def_property_update(prop, NC_TEXTURE, NULL); } static void rna_def_filter_size_common(StructRNA *srna) @@ -1285,7 +1348,19 @@ static void rna_def_texture(BlenderRNA *brna) RNA_def_property_range(prop, 0, 2); RNA_def_property_ui_text(prop, "RGB Factor", ""); RNA_def_property_update(prop, NC_TEXTURE, NULL); - + + /* nodetree */ + prop= RNA_def_property(srna, "use_nodes", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); + RNA_def_property_boolean_funcs(prop, NULL, "rna_Texture_use_nodes_set"); + RNA_def_property_ui_text(prop, "Use Nodes", "Make this a node-based texture"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + + prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "nodetree"); + RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based textures"); + RNA_def_property_update(prop, NC_TEXTURE, NULL); + rna_def_animdata_common(srna); /* specific types */ |