0
$\begingroup$

I'm wondering what's the most efficient way to detect whether or not an object is entirely within the current camera's field of view. For example, if I'd want to allow variations in camera rotation until the object is at the edge of the field of view, so to speak.

Is there an easy way to do this?

Thanks!

$\endgroup$
1
$\begingroup$

Yes there's an easy way, go to the BGE Documentation to look for more information. Since you dont specified if you are using bpy or bge i go for bge.

from bge import logic
cont = logic.getCurrentController()
cam = cont.owner

# Test point [0.0, 0.0, 0.0]
if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
  # Point is inside frustum !
  # Do something useful !
else:
  # Box is outside the frustum !
$\endgroup$
  • $\begingroup$ I was using bpy, but I should probably switch to bge anyway. Thanks! $\endgroup$ – Jack Lynch Apr 4 '17 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.