[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [3315] contrib/py/scripts/addons/ space_view3d_paint_bprojection.py: BProjection: improvement of zoom view 3D , it zoom on the selected mesh and plan stay in the same location

geo kgeo kgeogeo at hotmail.com
Fri Apr 27 11:14:49 CEST 2012


Revision: 3315
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=3315
Author:   kgeogeo
Date:     2012-04-27 09:14:49 +0000 (Fri, 27 Apr 2012)
Log Message:
-----------
BProjection: improvement of zoom view 3D, it zoom on the selected mesh and plan stay in the same location

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	2012-04-26 18:24:51 UTC (rev 3314)
+++ contrib/py/scripts/addons/space_view3d_paint_bprojection.py	2012-04-27 09:14:49 UTC (rev 3315)
@@ -1072,9 +1072,36 @@
     def invoke(self, context, event):                   
         ob = context.object 
         sd = context.space_data
-        
+
+        width = context.area.regions[4].width
+        height = context.area.regions[4].height              
+                    
+        r3d =  sd.region_3d
+        v_init = Vector((0.0,0.0,1.0))
+
+        pos = [width,height]
+        vtr_b = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
+        pos = [0,0]
+        vbl_b = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
+        len_b = vtr_b - vbl_b
+       
         bpy.ops.view3d.zoom(delta = self.delta)
+        r3d.update()
+
+        pos = [width,height]
+        vtr_a = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init)
+        pos = [0,0]
+        vbl_a = view3d_utils.region_2d_to_location_3d(context.region, r3d, pos, v_init) 
+        len_a = vtr_a - vbl_a
         
+        fac = len_a.length/len_b.length
+        r3d.view_location -= ob.location
+        r3d.view_location *= fac
+        r3d.view_location += ob.location
+        vres = Vector((ob.custom_location.x*fac,ob.custom_location.y*fac,ob.custom_location.z))
+        ob.custom_location = vres
+        
+        
         align_to_view(context)
         
         return {'FINISHED'}



More information about the Bf-extensions-cvs mailing list