Camera: sphereInsideFrustum

sphereInsideFrustum(center, radius)
  • Tests whether or not a sphere is inside the camera's view frustum.

Returns: 
  • INSIDE = Sphere is inside the camera's view frustum.
  • OUTSIDE = Sphere is outside the camera's view frustum.
  • INTERSECT = Part of the sphere is inside the camera's view frustum.  Part is outside.

center:

  • Center of the sphere in World Coordinates.
  • Type:  float List [ x, y, z]
radius:
  • Radius of the sphere
  • Type:  float number
Note:
  • Frustum definition:  A camera frustum is a truncated pyramid.  It is the part that is left when the top of the  pyramid is cut off and removed.
Sample Code

################## find out if the sphere is inside the view frustum

# import bge
import bge

# get current scene
scene = bge.logic.getCurrentScene()

# get a list of the cameras
camList = scene.cameras

# get camera
# my camera is named security_cam
cam = camList["security_cam"]

# location of sphere center
center = [ 0.0, 0.0, 0.0]

# radius of sphere
radius = 4.5

# check if sphere is inside view frustum
sphereInside = cam.sphereInsideFrustum( center, radius)

if  sphereInside == cam.INSIDE:
    # your code here

if  sphereInside == cam.OUTSIDE:
    # your code here

if  sphereInside == cam.INTERSECT:
    # your code here