Previously, I've asked this question: How can I see if an object is inside the volume rendering of the camera? and I had found the solution thanks to this post: Does Camera.view_frame() return the correct size of near clip plane?
The line code
x, y, z = world_to_camera_view(sce, cam, mat * v.co) is perfect for found the objects are visible from the central camera but it excludes items that are only visible from a single camera (camera L or R). I want to find the objects visible only from the right camera and objects visible only from the left camera.
A possible solution would be:
- Delete stereoscopy
- Move the camera to the right of intercular distance / 2
- Incline the camera to the z-axis of angle of convergence (easy calculation)
- Check the visible item with
- Repeat for simulate the left camera (move to right and rotate z -angle)
- Set True the stereoscopy
But how to eliminate the stereoscopy and have a camera equal to that of the left and right?
I solved my issue by following the steps I listed. Now I have this problem:
If I place the camera on the right of a value (even higher) and then use
world_to_camera_view the result I get is the same. That tells me that the camera always sees the same objects.
import bpy from bpy_extras.object_utils import world_to_camera_view context = bpy.context scene = bpy.context.scene scene.update def checkIfIsInCameraView(cam, obj): for v in obj.data.vertices: x, y, z = world_to_camera_view(context.scene, cam, obj.matrix_world * v.co) if (0.0 <= x <= 1.0 and 0.0 <= y <= 1.0): return True return False #set off stereo scene.render.use_multiview = False #creo nuova camera per simulare camera laterale cameraNormal = scene.camera #change camera position cameraNormal.location.x = cameraNormal.location.x - 50.0 for obj in scene.objects: if obj.type == 'MESH': #print if in camera view if checkIfIsInCameraView(cameraNormal, obj): print(obj) #change camera position cameraNormal.location.x = cameraNormal.location.x + 100.0 for obj in scene.objects: if obj.type == 'MESH': #print if in camera view if checkIfIsInCameraView(cameraNormal, obj): print(obj) #set on stereo scene.render.use_multiview = True scene.update