[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30550] branches/soc-2008-mxcurioni: A WIP commit for proof-of-concept implementations of line style modifiers.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Tue Jul 20 19:57:34 CEST 2010


Revision: 30550
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30550
Author:   kjym3
Date:     2010-07-20 19:57:33 +0200 (Tue, 20 Jul 2010)

Log Message:
-----------
A WIP commit for proof-of-concept implementations of line style modifiers.

A number of UI elements were newly introduced to control line color, alpha
transparency and line thickness by means of base color/alpha/thickness plus
modifiers that alter the base values.  To begin with, three basic modifiers
were prototyped with the aim of putting the new UI framework in practice
and evaluating if it works properly.

The Parameter Editor mode is still in a work-in-progress state and totally
useless from users' viewpoint.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
    branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h
    branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
    branches/soc-2008-mxcurioni/source/blender/blenloader/intern/readfile.c
    branches/soc-2008-mxcurioni/source/blender/blenloader/intern/writefile.c
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_intern.h
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_ops.c
    branches/soc-2008-mxcurioni/source/blender/editors/render/render_shading.c
    branches/soc-2008-mxcurioni/source/blender/freestyle/FRS_freestyle.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_freestyle_types.h
    branches/soc-2008-mxcurioni/source/blender/makesdna/intern/makesdna.c
    branches/soc-2008-mxcurioni/source/blender/makesrna/RNA_access.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/RNA_enum_types.h
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_linestyle.c
    branches/soc-2008-mxcurioni/source/blender/makesrna/intern/rna_scene.c

Added Paths:
-----------
    branches/soc-2008-mxcurioni/source/blender/makesdna/DNA_linestyle_types.h

Modified: branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-07-20 17:38:09 UTC (rev 30549)
+++ branches/soc-2008-mxcurioni/release/scripts/ui/properties_render.py	2010-07-20 17:57:33 UTC (rev 30550)
@@ -200,9 +200,7 @@
             col.label(text="Edge Detection Options:")
             col.prop(freestyle, "crease_angle")
             col.prop(freestyle, "sphere_radius")
-            sub = col.row()
-            sub.prop(freestyle, "dkr_epsilon")
-            sub.active = any(lineset.select_suggestive_contour for lineset in freestyle.linesets)
+            col.prop(freestyle, "dkr_epsilon")
 
             lineset = freestyle.active_lineset
 
@@ -293,6 +291,91 @@
             return freestyle.mode == "EDITOR" and freestyle.active_lineset
         return False
 
+    def draw_modifier_box_header(self, box, modifier):
+        row = box.row()
+        row.set_context_pointer("modifier", modifier)
+        if modifier.expanded:
+            icon = "TRIA_DOWN"
+        else:
+            icon = "TRIA_RIGHT"
+        row.operator("scene.freestyle_modifier_toggle_fold", icon=icon, text="", emboss=False)
+        row.label(text=modifier.rna_type.name)
+        row.prop(modifier, "name", text="")
+        row.prop(modifier, "enabled", text="")
+        sub = row.row(align=True)
+        sub.operator("scene.freestyle_modifier_move", icon='TRIA_UP', text="").direction = 'UP'
+        sub.operator("scene.freestyle_modifier_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+        row.operator("scene.freestyle_modifier_remove", icon='X', text="")
+
+    def draw_color_modifier(self, context, modifier):
+        layout = self.layout
+
+        col = layout.column(align=True)
+        self.draw_modifier_box_header(col.box(), modifier)
+        if modifier.expanded:
+            box = col.box()
+            row = box.row()
+            row.prop(modifier, "blend", text="")
+            row.prop(modifier, "influence")
+            if modifier.type == "DISTANCE_FROM_OBJECT":
+                box.prop(modifier, "target")
+            box.template_color_ramp(modifier, "color_ramp", expand=True)
+            if modifier.type not in ["ALONG_STROKE"]:
+                row = box.row(align=True)
+                row.prop(modifier, "range_min")
+                row.prop(modifier, "range_max")
+
+    def draw_alpha_modifier(self, context, modifier):
+        layout = self.layout
+
+        col = layout.column(align=True)
+        self.draw_modifier_box_header(col.box(), modifier)
+        if modifier.expanded:
+            box = col.box()
+            row = box.row()
+            row.prop(modifier, "blend", text="")
+            row.prop(modifier, "influence")
+            if modifier.type == "DISTANCE_FROM_OBJECT":
+                box.prop(modifier, "target")
+            row = box.row()
+            row.prop(modifier, "mapping", text="")
+            sub = row.column()
+            sub.prop(modifier, "invert")
+            if modifier.mapping == "CURVE":
+                sub.enabled = False
+                box.template_curve_mapping(modifier, "curve") # FIXME: not properly displayed
+            if modifier.type not in ["ALONG_STROKE"]:
+                row = box.row(align=True)
+                row.prop(modifier, "range_min")
+                row.prop(modifier, "range_max")
+
+    def draw_thickness_modifier(self, context, modifier):
+        layout = self.layout
+
+        col = layout.column(align=True)
+        self.draw_modifier_box_header(col.box(), modifier)
+        if modifier.expanded:
+            box = col.box()
+            row = box.row()
+            row.prop(modifier, "blend", text="")
+            row.prop(modifier, "influence")
+            if modifier.type == "DISTANCE_FROM_OBJECT":
+                box.prop(modifier, "target")
+            row = box.row()
+            row.prop(modifier, "mapping", text="")
+            sub = row.column()
+            sub.prop(modifier, "invert")
+            if modifier.mapping == "CURVE":
+                sub.enabled = False
+                box.template_curve_mapping(modifier, "curve") # FIXME: not properly displayed
+            if modifier.type not in ["ALONG_STROKE"]:
+                row = box.row(align=True)
+                row.prop(modifier, "range_min")
+                row.prop(modifier, "range_max")
+            row = box.row(align=True)
+            row.prop(modifier, "value_min")
+            row.prop(modifier, "value_max")
+
     def draw(self, context):
         layout = self.layout
 
@@ -305,7 +388,39 @@
         col = split.column()
         col.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new")
 
+        col.separator()
+        sub = col.row(align=True)
+        sub.prop(linestyle, "panel", expand=True)
 
+        if linestyle.panel == "COLOR":
+            col.label(text="Base Color:")
+            col.prop(linestyle, "color", text="")
+            col.label(text="Modifiers:")
+            layout.operator_menu_enum("scene.freestyle_color_modifier_add", "type", text="Add Modifier")
+            for modifier in linestyle.color_modifiers:
+                self.draw_color_modifier(context, modifier)
+        elif linestyle.panel == "ALPHA":
+            col.label(text="Base Transparency:")
+            col.prop(linestyle, "alpha")
+            col.label(text="Modifiers:")
+            layout.operator_menu_enum("scene.freestyle_alpha_modifier_add", "type", text="Add Modifier")
+            for modifier in linestyle.alpha_modifiers:
+                self.draw_alpha_modifier(context, modifier)
+        elif linestyle.panel == "THICKNESS":
+            col.label(text="Base Thickness:")
+            col.prop(linestyle, "thickness")
+            col.label(text="Modifiers:")
+            layout.operator_menu_enum("scene.freestyle_thickness_modifier_add", "type", text="Add Modifier")
+            for modifier in linestyle.thickness_modifiers:
+                self.draw_thickness_modifier(context, modifier)
+        elif linestyle.panel == "STROKES":
+            pass
+        elif linestyle.panel == "DISTORT":
+            pass
+        elif linestyle.panel == "MISC":
+            pass
+
+
 class RENDER_PT_shading(RenderButtonsPanel):
     bl_label = "Shading"
     COMPAT_ENGINES = {'BLENDER_RENDER'}

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h	2010-07-20 17:38:09 UTC (rev 30549)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/BKE_linestyle.h	2010-07-20 17:57:33 UTC (rev 30550)
@@ -32,11 +32,27 @@
 #ifndef BKE_LINESTYLE_H
 #define BKE_LINESTYLE_H
 
-#include "DNA_freestyle_types.h"
+#include "DNA_linestyle_types.h"
 
+#define LS_MODIFIER_TYPE_COLOR      1
+#define LS_MODIFIER_TYPE_ALPHA      2
+#define LS_MODIFIER_TYPE_THICKNESS  3
+
 struct Main;
 
 FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main);
 void FRS_free_linestyle(FreestyleLineStyle *linestyle);
 
+int FRS_add_linestyle_color_modifier(FreestyleLineStyle *linestyle, int type);
+int FRS_add_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, int type);
+int FRS_add_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, int type);
+
+void FRS_remove_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier);
+void FRS_remove_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier);
+void FRS_remove_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier);
+
+void FRS_move_linestyle_color_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction);
+void FRS_move_linestyle_alpha_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction);
+void FRS_move_linestyle_thickness_modifier(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction);
+
 #endif

Modified: branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c	2010-07-20 17:38:09 UTC (rev 30549)
+++ branches/soc-2008-mxcurioni/source/blender/blenkernel/intern/linestyle.c	2010-07-20 17:57:33 UTC (rev 30550)
@@ -33,14 +33,33 @@
 
 #include "MEM_guardedalloc.h"
 
+#include "DNA_material_types.h" /* for ramp blend */
+
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_linestyle.h"
 #include "BKE_main.h"
+#include "BKE_texture.h"
+#include "BKE_colortools.h"
 
+#include "BLI_blenlib.h"
+
+static char *modifier_name[LS_MODIFIER_NUM] = {
+	NULL,
+	"Along Stroke",
+	"Distance from Camera",
+	"Distance from Object"};
+
 static void default_linestyle_settings(FreestyleLineStyle *linestyle)
 {
+	linestyle->panel = LS_PANEL_COLOR;
+	linestyle->r = linestyle->g = linestyle->b = 1.0;
+	linestyle->alpha = 1.0;
+	linestyle->thickness = 1.0;
 
+	linestyle->color_modifiers.first = linestyle->color_modifiers.last = NULL;
+	linestyle->alpha_modifiers.first = linestyle->alpha_modifiers.last = NULL;
+	linestyle->thickness_modifiers.first = linestyle->thickness_modifiers.last = NULL;
 }
 
 FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main)
@@ -59,5 +78,233 @@
 
 void FRS_free_linestyle(FreestyleLineStyle *linestyle)
 {
+	LineStyleModifier *m;
 
+	while ((m = (LineStyleModifier *)linestyle->color_modifiers.first))
+		FRS_remove_linestyle_color_modifier(linestyle, m);
+	while ((m = (LineStyleModifier *)linestyle->alpha_modifiers.first))
+		FRS_remove_linestyle_alpha_modifier(linestyle, m);
+	while ((m = (LineStyleModifier *)linestyle->thickness_modifiers.first))
+		FRS_remove_linestyle_thickness_modifier(linestyle, m);
 }
+
+static LineStyleModifier *new_modifier(int type, size_t size)
+{
+	LineStyleModifier *m;
+
+	m = (LineStyleModifier *)MEM_callocN(size, "line style modifier");
+	if (m) {
+		m->type = type;
+		strcpy(m->name, modifier_name[type]);
+		m->influence = 1.0f;
+		m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED;
+	}
+	return m;
+}
+
+static void add_to_modifier_list(ListBase *lb, LineStyleModifier *m)
+{
+	BLI_addtail(lb, (void *)m);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list