frustum module

View frustum modeling as series of clipping planes

The Frustum object itself is only responsible for extracting the clipping planes from an OpenGL model-view matrix. The bulk of the frustum-culling algorithm is implemented in the bounding volume objects found in the OpenGLContext.scenegraph.boundingvolume module.

Based on code from:
class frustum.Frustum[source]

Bases: object

Holder for frustum specification for intersection tests

the Frustum can include an arbitrary number of clipping planes, though the most common usage is to define 6 clipping planes from the OpenGL model-view matrices.
classmethod fromViewingMatrix(matrix=None, normalize=1)[source]

Extract and calculate frustum clipping planes from OpenGL

The default initializer allows you to create Frustum objects with arbitrary clipping planes, while this alternate initializer provides automatic clipping-plane extraction from the model-view matrix.

matrix – the combined model-view matrix normalize – whether to normalize the plane equations

to allow for sphere bounding-volumes and use of distance equations for LOD-style operations.
classmethod normalize(frustum)[source]

Normalize clipping plane equations

visible(points, radius)[source]

Determine whether this sphere is visible in frustum

frustum – Frustum object holding the clipping planes
for the view
matrix – a matrix which transforms the local
coordinates to the (world-space) coordinate system in which the frustum is defined.

This version of the method uses a pure-python loop to do the actual culling once the points are multiplied by the matrix. (i.e. it does not use the frustcullaccel C extension module)

visible1(point, radius)[source]
frustum.viewingMatrix(projection=None, model=None)[source]

Calculate the total viewing matrix from given data

projection – the projection matrix, if not provided
than the result of glGetDoublev( GL_PROJECTION_MATRIX) will be used.
model – the model-view matrix, if not provided
than the result of glGetDoublev( GL_MODELVIEW_MATRIX ) will be used.
Unless there is a valid projection and model-view matrix, the function will raise a RuntimeError