[Bf-extensions-cvs] [c1b173b] master: New Feature: Make groups for objects in camera and objects outer camera.

Eugenio Pignataro noreply at git.blender.org
Mon Aug 18 18:01:32 CEST 2014


Commit: c1b173bd38e38d3ae024915c16070b958b1a9a1c
Author: Eugenio Pignataro
Date:   Mon Aug 18 13:01:22 2014 -0300
Branches: master
https://developer.blender.org/rBACc1b173bd38e38d3ae024915c16070b958b1a9a1c

New Feature: Make groups for objects in camera and objects outer camera.

===================================================================

M	oscurart_tools/__init__.py
M	oscurart_tools/oscurart_objects.py

===================================================================

diff --git a/oscurart_tools/__init__.py b/oscurart_tools/__init__.py
index 7f99514..4c2057b 100644
--- a/oscurart_tools/__init__.py
+++ b/oscurart_tools/__init__.py
@@ -156,7 +156,8 @@ class OscPanelObject(OscPollObject, bpy.types.Panel):
         colrow = col.row(align=1)
         colrow.operator("object.modifiers_remove_osc", icon="MODIFIER", text="Remove Modifiers")
         colrow.operator("object.modifiers_apply_osc", icon="MODIFIER", text="Apply Modifiers")
-
+        colrow = col.row(align=1)
+        colrow.operator("group.group_in_out_camera", icon="RENDER_REGION", text="Make Groups in out Camera")
 
 class OscPanelMesh(OscPollMesh, bpy.types.Panel):
     bl_idname = "Oscurart Mesh Tools"
@@ -293,3 +294,5 @@ def unregister():
 
 if __name__ == "__main__":
     register()
+
+
diff --git a/oscurart_tools/oscurart_objects.py b/oscurart_tools/oscurart_objects.py
index 602912f..a1eb0a3 100644
--- a/oscurart_tools/oscurart_objects.py
+++ b/oscurart_tools/oscurart_objects.py
@@ -6,6 +6,7 @@ import stat
 import bmesh
 import time
 import random
+from bpy_extras.object_utils import world_to_camera_view
 
 ##------------------------ SEARCH AND SELECT ------------------------
 
@@ -283,4 +284,52 @@ class SetLayersToOtherScenes (bpy.types.Operator):
 
     def execute (self, context):
         DefSetLayersToOtherScenes()
-        return {'FINISHED'}
\ No newline at end of file
+        return {'FINISHED'}
+    
+    
+      
+## ======================== RENDER OBJECTS IN CAMERA =====================================
+
+
+def DefRenderOnlyInCamera():
+    #crea grupos
+    if "INCAMERA" not in bpy.data.groups:
+        bpy.data.groups.new("INCAMERA")
+    if "NOTINCAMERA" not in bpy.data.groups:
+        bpy.data.groups.new("NOTINCAMERA")
+        
+    #limpio grupos
+    for ob in bpy.data.objects:
+        if ob.name in bpy.data.groups["INCAMERA"].objects:
+            bpy.data.groups["INCAMERA"].objects.unlink(ob)
+        if ob.name in bpy.data.groups["NOTINCAMERA"].objects:    
+            bpy.data.groups["NOTINCAMERA"].objects.unlink(ob)
+
+    #ordeno grupos
+    for ob in bpy.data.objects:
+        obs = False    
+        if ob.type == "MESH":  
+            tm = ob.to_mesh(bpy.context.scene, True, "RENDER")      
+            for vert in tm.vertices:
+                cam = world_to_camera_view(bpy.context.scene,bpy.context.scene.camera,vert.co+ob.location)            
+                if cam[0] >= -0 and cam[0] <= 1 and cam[1] >= 0 and cam[1] <= 1:
+                    obs = True  
+            del(tm)          
+        else:
+            obs = True 
+        if obs:
+            bpy.data.groups["INCAMERA"].objects.link(ob)   
+        else:
+            bpy.data.groups["NOTINCAMERA"].objects.link(ob)      
+    
+    
+class RenderOnlyInCamera (bpy.types.Operator):
+    bl_idname = "group.group_in_out_camera"
+    bl_label = "Make a group for objects in outer camera"
+    bl_options = {"REGISTER", "UNDO"}
+
+
+    def execute (self, context):
+        DefRenderOnlyInCamera()
+        return {'FINISHED'}
+



More information about the Bf-extensions-cvs mailing list