[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22579] branches/blender2.5/blender: Made texture nodes accessible in the interface.
Robin Allen
roblovski at gmail.com
Mon Aug 17 20:38:01 CEST 2009
Revision: 22579
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22579
Author: kakbarnf
Date: 2009-08-17 20:37:58 +0200 (Mon, 17 Aug 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/blender2.5/blender/release/ui/buttons_texture.py
branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c
branches/blender2.5/blender/source/blender/nodes/intern/TEX_nodes/TEX_output.c
branches/blender2.5/blender/source/blender/nodes/intern/TEX_util.c
Modified: branches/blender2.5/blender/release/ui/buttons_texture.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_texture.py 2009-08-17 18:07:40 UTC (rev 22578)
+++ branches/blender2.5/blender/release/ui/buttons_texture.py 2009-08-17 18:37:58 UTC (rev 22579)
@@ -7,7 +7,8 @@
__context__ = "texture"
def poll(self, context):
- return (context.texture and context.texture.type != 'NONE')
+ tex = context.texture
+ return (tex and (tex.type != 'NONE' or tex.use_nodes))
class TEXTURE_PT_preview(TextureButtonsPanel):
__label__ = "Preview"
@@ -31,7 +32,7 @@
layout.template_preview(tex, parent=br)
else:
layout.template_preview(tex)
-
+
class TEXTURE_PT_context_texture(TextureButtonsPanel):
__show_header__ = False
@@ -61,25 +62,62 @@
elif tex:
split.template_ID(space, "pin_id")
- if (not space.pin_id) and ( context.sculpt_object or \
- context.vertex_paint_object or \
- context.weight_paint_object or \
- context.texture_paint_object \
- ):
+ if (not space.pin_id) and (
+ context.sculpt_object or
+ context.vertex_paint_object or
+ context.weight_paint_object or
+ context.texture_paint_object
+ ):
split.itemR(space, "brush_texture", text="Brush", toggle=True)
if tex:
+ layout.itemR(tex, "use_nodes")
+
split = layout.split(percentage=0.2)
+
+ if tex.use_nodes:
+ slot = context.texture_slot
+ split.itemL(text="Output:")
+ split.itemR(slot, "output_node", text="")
+
+ else:
+ split.itemL(text="Type:")
+ split.itemR(tex, "type", text="")
+
+class TEXTURE_PT_colors(TextureButtonsPanel):
+ __label__ = "Colors"
+ __default_closed__ = True
+
+ def draw(self, context):
+ layout = self.layout
- split.itemL(text="Type:")
- split.itemR(tex, "type", text="")
+ tex = context.texture
-class TEXTURE_PT_mapping(TextureButtonsPanel):
+ layout.itemR(tex, "use_color_ramp", text="Ramp")
+ if tex.use_color_ramp:
+ layout.template_color_ramp(tex.color_ramp, expand=True)
+
+ split = layout.split()
+
+ split.itemR(tex, "rgb_factor", text="Multiply RGB")
+
+ col = split.column()
+ col.itemL(text="Adjust:")
+ col.itemR(tex, "brightness")
+ col.itemR(tex, "contrast")
+
+# Texture Slot Panels #
+
+class TextureSlotPanel(TextureButtonsPanel):
+ def poll(self, context):
+ return (
+ context.texture_slot and
+ TextureButtonsPanel.poll(self, context)
+ )
+
+class TEXTURE_PT_mapping(TextureSlotPanel):
__label__ = "Mapping"
- def poll(self, context):
- return (context.texture_slot and context.texture and context.texture.type != 'NONE')
-
def draw(self, context):
layout = self.layout
@@ -150,12 +188,9 @@
row.column().itemR(tex, "offset")
row.column().itemR(tex, "size")
-class TEXTURE_PT_influence(TextureButtonsPanel):
+class TEXTURE_PT_influence(TextureSlotPanel):
__label__ = "Influence"
- def poll(self, context):
- return (context.texture_slot and context.texture and context.texture.type != 'NONE' and (not context.brush))
-
def draw(self, context):
layout = self.layout
@@ -235,37 +270,17 @@
if ma or wo:
col.itemR(tex, "default_value", text="DVar", slider=True)
-class TEXTURE_PT_colors(TextureButtonsPanel):
- __label__ = "Colors"
- __default_closed__ = True
-
- def draw(self, context):
- layout = self.layout
-
- tex = context.texture
-
- layout.itemR(tex, "use_color_ramp", text="Ramp")
- if tex.use_color_ramp:
- layout.template_color_ramp(tex.color_ramp, expand=True)
-
- split = layout.split()
-
- split.itemR(tex, "rgb_factor", text="Multiply RGB")
-
- col = split.column()
- col.itemL(text="Adjust:")
- col.itemR(tex, "brightness")
- col.itemR(tex, "contrast")
-
# Texture Type Panels #
-class TEXTURE_PT_clouds(TextureButtonsPanel):
- __label__ = "Clouds"
-
+class TextureTypePanel(TextureButtonsPanel):
def poll(self, context):
tex = context.texture
- return (tex and tex.type == 'CLOUDS')
+ return (tex and tex.type == self.tex_type and not tex.use_nodes)
+class TEXTURE_PT_clouds(TextureTypePanel):
+ __label__ = "Clouds"
+ tex_type = 'CLOUDS'
+
def draw(self, context):
layout = self.layout
@@ -281,12 +296,9 @@
flow.itemR(tex, "noise_depth", text="Depth")
flow.itemR(tex, "nabla", text="Nabla")
-class TEXTURE_PT_wood(TextureButtonsPanel):
+class TEXTURE_PT_wood(TextureTypePanel):
__label__ = "Wood"
-
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'WOOD')
+ tex_type = 'WOOD'
def draw(self, context):
layout = self.layout
@@ -308,13 +320,10 @@
flow.itemR(tex, "turbulence")
flow.itemR(tex, "nabla")
-class TEXTURE_PT_marble(TextureButtonsPanel):
+class TEXTURE_PT_marble(TextureTypePanel):
__label__ = "Marble"
+ tex_type = 'MARBLE'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'MARBLE')
-
def draw(self, context):
layout = self.layout
@@ -332,13 +341,10 @@
flow.itemR(tex, "turbulence")
flow.itemR(tex, "nabla")
-class TEXTURE_PT_magic(TextureButtonsPanel):
+class TEXTURE_PT_magic(TextureTypePanel):
__label__ = "Magic"
+ tex_type = 'MAGIC'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'MAGIC')
-
def draw(self, context):
layout = self.layout
@@ -348,13 +354,10 @@
row.itemR(tex, "noise_depth", text="Depth")
row.itemR(tex, "turbulence")
-class TEXTURE_PT_blend(TextureButtonsPanel):
+class TEXTURE_PT_blend(TextureTypePanel):
__label__ = "Blend"
+ tex_type = 'BLEND'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'BLEND')
-
def draw(self, context):
layout = self.layout
@@ -363,13 +366,10 @@
layout.itemR(tex, "progression")
layout.itemR(tex, "flip_axis")
-class TEXTURE_PT_stucci(TextureButtonsPanel):
+class TEXTURE_PT_stucci(TextureTypePanel):
__label__ = "Stucci"
+ tex_type = 'STUCCI'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'STUCCI')
-
def draw(self, context):
layout = self.layout
@@ -384,13 +384,10 @@
row.itemR(tex, "noise_size", text="Size")
row.itemR(tex, "turbulence")
-class TEXTURE_PT_image(TextureButtonsPanel):
+class TEXTURE_PT_image(TextureTypePanel):
__label__ = "Image"
+ tex_type = 'IMAGE'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'IMAGE')
-
def draw(self, context):
layout = self.layout
@@ -398,14 +395,11 @@
layout.template_texture_image(tex)
-class TEXTURE_PT_image_sampling(TextureButtonsPanel):
+class TEXTURE_PT_image_sampling(TextureTypePanel):
__label__ = "Image Sampling"
__default_closed__ = True
+ tex_type = 'IMAGE'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'IMAGE')
-
def draw(self, context):
layout = self.layout
@@ -449,14 +443,11 @@
else:
col.itemR(tex, "filter_eccentricity", text="Eccentricity")
-class TEXTURE_PT_image_mapping(TextureButtonsPanel):
+class TEXTURE_PT_image_mapping(TextureTypePanel):
__label__ = "Image Mapping"
__default_closed__ = True
+ tex_type = 'IMAGE'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'IMAGE')
-
def draw(self, context):
layout = self.layout
@@ -499,13 +490,10 @@
col.itemR(tex, "crop_max_x", text="X")
col.itemR(tex, "crop_max_y", text="Y")
-class TEXTURE_PT_plugin(TextureButtonsPanel):
+class TEXTURE_PT_plugin(TextureTypePanel):
__label__ = "Plugin"
+ tex_type = 'PLUGIN'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'PLUGIN')
-
def draw(self, context):
layout = self.layout
@@ -513,13 +501,10 @@
layout.itemL(text="Nothing yet")
-class TEXTURE_PT_envmap(TextureButtonsPanel):
+class TEXTURE_PT_envmap(TextureTypePanel):
__label__ = "Environment Map"
+ tex_type = 'ENVIRONMENT_MAP'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'ENVIRONMENT_MAP')
-
def draw(self, context):
layout = self.layout
@@ -527,13 +512,10 @@
layout.itemL(text="Nothing yet")
-class TEXTURE_PT_musgrave(TextureButtonsPanel):
+class TEXTURE_PT_musgrave(TextureTypePanel):
__label__ = "Musgrave"
+ tex_type = 'MUSGRAVE'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'MUSGRAVE')
-
def draw(self, context):
layout = self.layout
@@ -563,12 +545,9 @@
row.itemR(tex, "noise_size", text="Size")
row.itemR(tex, "nabla")
-class TEXTURE_PT_voronoi(TextureButtonsPanel):
+class TEXTURE_PT_voronoi(TextureTypePanel):
__label__ = "Voronoi"
-
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'VORONOI')
+ tex_type = 'VORONOI'
def draw(self, context):
layout = self.layout
@@ -600,13 +579,10 @@
row.itemR(tex, "noise_size", text="Size")
row.itemR(tex, "nabla")
-class TEXTURE_PT_distortednoise(TextureButtonsPanel):
+class TEXTURE_PT_distortednoise(TextureTypePanel):
__label__ = "Distorted Noise"
+ tex_type = 'DISTORTED_NOISE'
- def poll(self, context):
- tex = context.texture
- return (tex and tex.type == 'DISTORTED_NOISE')
-
def draw(self, context):
layout = self.layout
Modified: branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c 2009-08-17 18:07:40 UTC (rev 22578)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_texture.c 2009-08-17 18:37:58 UTC (rev 22579)
@@ -36,7 +36,10 @@
#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"
static EnumPropertyItem texture_filter_items[] = {
@@ -107,6 +110,43 @@
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;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list