Camera: boxInsideFrustum

boxInsideFrustum(Box)
  • Tests the given box against the view frustum

Return Values: 
  • INSIDE = Box is inside the camera's view frustum.
  • OUTSIDE = Box is outside the camera's view frustum.
     
  • INTERSECT = Part of the box is inside the camera's view frustum.  Part is outside

Box:
  • Box is an array that holds the Box's eight corner positions.  Uses world coordinates.
     
  • Type:  a matrix (float values)
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. 
     
  • Frustum culling removes game objects that are outside the viewing frustum from the rendering process.
Sample Code

####################### Test the given box against 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"]

################ Box to test

# create an empty array
Box = [ ]

# enter the position of the eight corner vertices (world coordinates)

Box.append([ -1.0, -1.0, -1.0])
Box.append([ -1.0, -1.0,  1.0])
Box.append([ -1.0,  1.0, -1.0])
Box.append([ -1.0,  1.0,  1.0])
Box.append([  1.0, -1.0, -1.0])
Box.append([  1.0, -1.0,  1.0])
Box.append([  1.0,  1.0, -1.0])
Box.append([  1.0,  1.0,  1.0])

# active camera inside box?
if cam.boxInsideFrustum(Box) == cam.INSIDE:

# box is inside
# your code here
else:
# box is outside
# your code here