How to find if certain objects are visible from camera that may be behind other scene objects


#1

what is best way to find which sphere is visible from camera
Top view


view from camera,

only green and blue are visible ,red sphere not visible
Thanks


#2

shoot rays from this object vertices positions to camera
if any ray has no intersection with scene objects then this object is visible


#3

Keep in mind that shooting rays from vertices to camera won’t work for all cases.

(
	delete objects
	
	p1 = plane length:100 width:100 lengthsegs:1 widthsegs:1 pos:[  0,  0,  0] dir:[0,-1,0] wirecolor:green
	p2 = plane length:100 width:100 lengthsegs:1 widthsegs:1 pos:[ 80,-10, 80] dir:[0,-1,0] wirecolor:red
	p3 = plane length:100 width:100 lengthsegs:1 widthsegs:1 pos:[-80,-10, 80] dir:[0,-1,0] wirecolor:red
	p4 = plane length:100 width:100 lengthsegs:1 widthsegs:1 pos:[-80,-10,-80] dir:[0,-1,0] wirecolor:red
	p5 = plane length:100 width:100 lengthsegs:1 widthsegs:1 pos:[ 80,-10,-80] dir:[0,-1,0] wirecolor:red
	
	converttomesh #(p1,p2,p3,p4,p5)
	
	cam = freecamera pos:[0,-400,0] dir:[0,-1,0]
)

#4