[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39674] branches/soc-2008-mxcurioni/ release/scripts/startup: Added a button to the UI of "Distance from Object" color/alpha/thickness
Tamito Kajiyama
rd6t-kjym at asahi-net.or.jp
Wed Aug 24 17:47:06 CEST 2011
Revision: 39674
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39674
Author: kjym3
Date: 2011-08-24 15:47:05 +0000 (Wed, 24 Aug 2011)
Log Message:
-----------
Added a button to the UI of "Distance from Object" color/alpha/thickness
modifiers to fill the Range Min/Max entries by the min/max distance between
selected mesh objects and the target object.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/release/scripts/startup/bl_operators/freestyle.py
branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
Modified: branches/soc-2008-mxcurioni/release/scripts/startup/bl_operators/freestyle.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/startup/bl_operators/freestyle.py 2011-08-24 14:22:41 UTC (rev 39673)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_operators/freestyle.py 2011-08-24 15:47:05 UTC (rev 39674)
@@ -22,7 +22,7 @@
class SCENE_OT_freestyle_fill_range_by_selection(bpy.types.Operator):
- '''Fill the Range Min/Max entries by the min/max distance between selected mesh objects and the active camera.'''
+ '''Fill the Range Min/Max entries by the min/max distance between selected mesh objects and the source object (either a user-specified object or the active camera).'''
bl_idname = "scene.freestyle_fill_range_by_selection"
bl_label = "Fill Range by Selection"
@@ -43,17 +43,26 @@
m = linestyle.alpha_modifiers[self.name]
else:
m = linestyle.thickness_modifiers[self.name]
- # Find the active camera
- camera = context.scene.camera
+ # Find the source object
+ if m.type == 'DISTANCE_FROM_CAMERA':
+ source = context.scene.camera
+ elif m.type == 'DISTANCE_FROM_OBJECT':
+ if m.target is None:
+ self.report({'ERROR'}, "Target object not specified")
+ return {'CANCELLED'}
+ source = m.target
+ else:
+ self.report({'ERROR'}, "Unexpected modifier type: " + m.type)
+ return {'CANCELLED'}
# Find selected mesh objects
- selection = [ob for ob in context.scene.objects if ob.select and ob.type == 'MESH']
+ selection = [ob for ob in context.scene.objects if ob.select and ob.type == 'MESH' and ob.name != source.name]
if len(selection) > 0:
- # Compute the min/max distance between selected mesh objects and the camera
+ # Compute the min/max distance between selected mesh objects and the source
min_dist = float('inf')
max_dist = -min_dist
for ob in selection:
for vert in ob.data.vertices:
- dist = (ob.matrix_world * vert.co - camera.location).length
+ dist = (ob.matrix_world * vert.co - source.location).length
min_dist = min(dist, min_dist)
max_dist = max(dist, max_dist)
# Fill the Range Min/Max entries with the computed distances
Modified: branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py
===================================================================
--- branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py 2011-08-24 14:22:41 UTC (rev 39673)
+++ branches/soc-2008-mxcurioni/release/scripts/startup/bl_ui/properties_render.py 2011-08-24 15:47:05 UTC (rev 39674)
@@ -364,6 +364,9 @@
elif modifier.type == "DISTANCE_FROM_OBJECT":
box.prop(modifier, "target")
self.draw_modifier_color_ramp_common(box, modifier, True)
+ prop = box.operator("scene.freestyle_fill_range_by_selection")
+ prop.type = 'COLOR'
+ prop.name = modifier.name
elif modifier.type == "DISTANCE_FROM_CAMERA":
self.draw_modifier_color_ramp_common(box, modifier, True)
@@ -400,6 +403,9 @@
elif modifier.type == "DISTANCE_FROM_OBJECT":
box.prop(modifier, "target")
self.draw_modifier_curve_common(box, modifier, True, False)
+ prop = box.operator("scene.freestyle_fill_range_by_selection")
+ prop.type = 'ALPHA'
+ prop.name = modifier.name
elif modifier.type == "DISTANCE_FROM_CAMERA":
self.draw_modifier_curve_common(box, modifier, True, False)
@@ -426,6 +432,9 @@
elif modifier.type == "DISTANCE_FROM_OBJECT":
box.prop(modifier, "target")
self.draw_modifier_curve_common(box, modifier, True, True)
+ prop = box.operator("scene.freestyle_fill_range_by_selection")
+ prop.type = 'THICKNESS'
+ prop.name = modifier.name
elif modifier.type == "DISTANCE_FROM_CAMERA":
self.draw_modifier_curve_common(box, modifier, True, True)
More information about the Bf-blender-cvs
mailing list