[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4328] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: a lot of change, add turnable to rotate the view, all the shortcut are now separated
geo kgeo
kgeogeo at hotmail.com
Tue Feb 26 00:07:32 CET 2013
Revision: 4328
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4328
Author: kgeogeo
Date: 2013-02-25 23:07:31 +0000 (Mon, 25 Feb 2013)
Log Message:
-----------
BProjection: a lot of change, add turnable to rotate the view, all the shortcut are now separated
Modified Paths:
--------------
contrib/py/scripts/addons/space_view3d_paint_bprojection.py
Modified: contrib/py/scripts/addons/space_view3d_paint_bprojection.py
===================================================================
--- contrib/py/scripts/addons/space_view3d_paint_bprojection.py 2013-02-25 23:06:49 UTC (rev 4327)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py 2013-02-25 23:07:31 UTC (rev 4328)
@@ -3,7 +3,7 @@
"description": "Help Clone tool",
"author": "kgeogeo",
"version": (1, 0),
- "blender": (2, 63, 0),
+ "blender": (2, 6, 3),
"wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/3D_interaction/bprojection",
"tracker_url":"http://projects.blender.org/tracker/index.php?func=detail&aid=30521&group_id=153&atid=468",
"category": "Paint"}
@@ -31,7 +31,7 @@
z = em.custom_location.z
pos = [em.custom_location.x, em.custom_location.y]
- reg = context.area.regions[4]
+ reg = context.region
width = reg.width
height = reg.height
@@ -231,8 +231,7 @@
else:
align_to_view(context)
-
-
+
em.custom_old_scale = em.custom_scale
def update_PropScale(self, context):
@@ -638,10 +637,11 @@
row.prop(em, "custom_linkscaleuv",text="",icon='UNLINKED')
if matBProjection:
- row = box.column(align =True)
- row.prop(matBProjection,'alpha', slider = True)
- row = box.column(align =True)
-
+ if context.scene.game_settings.material_mode == 'GLSL' and context.space_data.viewport_shade == 'TEXTURED':
+ row = box.column(align =True)
+ row.prop(matBProjection,'alpha', slider = True)
+
+ row = box.column(align =True)
row.prop(ob,"custom_fnlevel")
row = box.column(align =True)
@@ -843,7 +843,12 @@
km = context.window_manager.keyconfigs.default.keymaps['Image Paint']
kmi = km.keymap_items.new("object.intuitivescale", 'LEFTMOUSE', 'PRESS', shift=True)
-
+ kmi = km.keymap_items.new("object.bp_grab", 'G', 'PRESS')
+ kmi = km.keymap_items.new("object.bp_rotate", 'R', 'PRESS')
+ kmi = km.keymap_items.new("object.bp_scale", 'S', 'PRESS')
+ kmi = km.keymap_items.new("object.bp_scaleuv", 'U', 'PRESS')
+ kmi = km.keymap_items.new("object.bp_offsetuv", 'Y', 'PRESS')
+ kmi = km.keymap_items.new("object.bp_clear_prop", 'C', 'PRESS')
align_to_view(context)
context.space_data.cursor_location = em.location
@@ -954,7 +959,7 @@
km = bpy.context.window_manager.keyconfigs.default.keymaps['Image Paint']
#to do
- for kmi in (kmi for kmi in km.keymap_items if kmi.idname in {"object.intuitivescale", }):
+ for kmi in (kmi for kmi in km.keymap_items if kmi.idname in {"object.intuitivescale", "object.bp_grab", "object.bp_rotate", "object.bp_scale", "object.bp_scaleuv", "object.bp_clear_prop", "object.bp_offsetuv", }):
km.keymap_items.remove(kmi)
# Oprerator Class to remove what is no more needed
@@ -1064,24 +1069,415 @@
return {'FINISHED'}
+#reinit the values of the bp_plane
+class BP_Clear_Props(Operator):
+ bl_idname = "object.bp_clear_prop"
+ bl_label = "Clear Props BProjection Plane"
+
+ def execute(self, context):
+ clear_props(context)
+
+ return{'FINISHED'}
+
+#Move the UV of the bp_plane
+class BP_OffsetUV(bpy.types.Operator):
+ bl_idname = "object.bp_offsetuv"
+ bl_label = "OffsetUV BProjection Plane"
+
+ axe_x = True
+ axe_y = True
+
+ first_mouse = Vector((0,0))
+ first_offsetuv = Vector((0,0))
+
+ @classmethod
+ def poll(cls, context):
+ return 1
+
+ def modal(self, context, event):
+ em = bpy.data.objects['Empty for BProjection']
+
+ if event.shift:
+ fac = 0.1
+ else:
+ fac = 1
+
+ if event.type == 'X' and event.value == 'PRESS':
+ if self.axe_x == True and self.axe_y == True:
+ self.axe_y = False
+ elif self.axe_x == True and self.axe_y == False:
+ self.axe_y = True
+ elif self.axe_x == False and self.axe_y == True:
+ self.axe_y = False
+ self.axe_x = True
+
+ if event.type == 'Y' and event.value == 'PRESS':
+ if self.axe_x == True and self.axe_y == True:
+ self.axe_x = False
+ elif self.axe_x == False and self.axe_y == True:
+ self.axe_x = True
+ elif self.axe_x == True and self.axe_y == False:
+ self.axe_y = True
+ self.axe_x = False
+
+ deltax = (event.mouse_region_x - self.first_mouse.x)*fac
+ deltay = (event.mouse_region_y - self.first_mouse.y)*fac
+
+ if event.type == 'MOUSEMOVE':
+
+ if not self.axe_y:
+ deltay = 0
+ if not self.axe_x:
+ deltax = 0
+
+ ouv = em.custom_offsetuv
+ em.custom_offsetuv = [ouv[0] - deltax/50,ouv[1] - deltay/50]
+
+ self.first_mouse.x = event.mouse_region_x
+ self.first_mouse.y = event.mouse_region_y
+
+ if event.type == 'LEFTMOUSE':
+ return {'FINISHED'}
+
+ if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
+ em.custom_offsetuv = self.first_offsetuv
+ return {'FINISHED'}
+
+ return {'RUNNING_MODAL'}
+
+ def invoke(self, context, event):
+ em = bpy.data.objects['Empty for BProjection']
+ context.window_manager.modal_handler_add(self)
+ self.first_mouse.x = event.mouse_region_x
+ self.first_mouse.y = event.mouse_region_y
+ self.first_offsetuv = em.custom_offsetuv.copy()
+
+ return {'RUNNING_MODAL'}
+
+#Scale the UV of the bp_plane
+class BP_ScaleUV(bpy.types.Operator):
+ bl_idname = "object.bp_scaleuv"
+ bl_label = "ScaleUV BProjection Plane"
+
+ axe_x = True
+ axe_y = True
+
+ first_mouse = Vector((0,0))
+ first_scaleuv = Vector((0,0))
+
+ @classmethod
+ def poll(cls, context):
+ return 1
+
+ def modal(self, context, event):
+ em = bpy.data.objects['Empty for BProjection']
+
+ if event.shift:
+ fac = 0.1
+ else:
+ fac = 1
+
+ if event.type == 'X' and event.value == 'PRESS':
+ if self.axe_x == True and self.axe_y == True:
+ self.axe_y = False
+ elif self.axe_x == True and self.axe_y == False:
+ self.axe_y = True
+ elif self.axe_x == False and self.axe_y == True:
+ self.axe_y = False
+ self.axe_x = True
+
+ if event.type == 'Y' and event.value == 'PRESS':
+ if self.axe_x == True and self.axe_y == True:
+ self.axe_x = False
+ elif self.axe_x == False and self.axe_y == True:
+ self.axe_x = True
+ elif self.axe_x == True and self.axe_y == False:
+ self.axe_y = True
+ self.axe_x = False
+
+ deltax = (event.mouse_region_x - self.first_mouse.x)*fac
+ deltay = (event.mouse_region_y - self.first_mouse.y)*fac
+
+ if event.type == 'MOUSEMOVE':
+
+ if not self.axe_y:
+ deltay = 0
+ if not self.axe_x:
+ deltax = 0
+
+ if self.axe_x and self.axe_y:
+ fac = em.custom_scaleuv[1]/em.custom_scaleuv[0]
+ deltay = deltax * fac
+ else:
+ em.custom_linkscaleuv = False
+
+ s = em.custom_scaleuv
+ em.custom_scaleuv = [s[0] + deltax/50, s[1] + deltay/50]
+
+ self.first_mouse.x = event.mouse_region_x
+ self.first_mouse.y = event.mouse_region_y
+
+ if event.type == 'LEFTMOUSE':
+ return {'FINISHED'}
+
+ if event.type == 'ESC' or event.type == 'RIGHTMOUSE':
+ em.custom_scaleuv = self.first_scaleuv
+ return {'FINISHED'}
+
+ return {'RUNNING_MODAL'}
+
+ def invoke(self, context, event):
+ em = bpy.data.objects['Empty for BProjection']
+ context.window_manager.modal_handler_add(self)
+ self.first_mouse.x = event.mouse_region_x
+ self.first_mouse.y = event.mouse_region_y
+ self.first_scaleuv = em.custom_scaleuv.copy()
+
+ return {'RUNNING_MODAL'}
+
+#Scale the bp_plane
+class BP_Scale(bpy.types.Operator):
+ bl_idname = "object.bp_scale"
+ bl_label = "Scale BProjection Plane"
+
+ axe_x = True
+ axe_y = True
+
+ first_mouse = Vector((0,0))
+ first_scale = Vector((0,0,0))
+
+ @classmethod
+ def poll(cls, context):
+ return 1
+
+ def modal(self, context, event):
+ em = bpy.data.objects['Empty for BProjection']
+ sd = context.space_data
+
+ if event.shift:
+ fac = 0.1
+ else:
+ fac = 1
+
+ if event.type == 'X' and event.value == 'PRESS':
+ if self.axe_x == True and self.axe_y == True:
+ self.axe_y = False
+ elif self.axe_x == True and self.axe_y == False:
+ self.axe_y = True
+ elif self.axe_x == False and self.axe_y == True:
+ self.axe_y = False
+ self.axe_x = True
+
+ if event.type == 'Y' and event.value == 'PRESS':
+ if self.axe_x == True and self.axe_y == True:
+ self.axe_x = False
+ elif self.axe_x == False and self.axe_y == True:
+ self.axe_x = True
+ elif self.axe_x == True and self.axe_y == False:
+ self.axe_y = True
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list