Represents a camera's frustum. More...
#import <CC3Camera.h>
Public Member Functions | |
(void) | - DEPRECATED_ATTRIBUTE |
(BOOL) | - doesIntersectPointAt: |
(BOOL) | - doesIntersectSphereAt:withRadius: |
(id) | - initOnModelviewMatrix: |
(void) | - populateFrom:andAspect:andNearClip:andFarClip:andZoom: |
Static Public Member Functions | |
(id) | + frustumOnModelviewMatrix: |
Protected Attributes | |
CC3Plane | planes [6] |
CC3Vector | vertices [8] |
Properties | |
GLfloat | bottom |
CC3Plane | bottomPlane |
GLfloat | far |
CC3Vector | farBottomLeft |
CC3Vector | farBottomRight |
CC3Plane | farPlane |
CC3Vector | farTopLeft |
CC3Vector | farTopRight |
CC3Matrix * | infiniteProjectionMatrix |
BOOL | isUsingParallelProjection: 1 |
GLfloat | left |
CC3Plane | leftPlane |
CC3Matrix * | modelviewMatrix |
CC3Matrix * | modelviewProjectionMatrix |
GLfloat | near |
CC3Vector | nearBottomLeft |
CC3Vector | nearBottomRight |
CC3Plane | nearPlane |
CC3Vector | nearTopLeft |
CC3Vector | nearTopRight |
CC3Matrix * | projectionMatrix |
GLfloat | right |
CC3Plane | rightPlane |
GLfloat | top |
CC3Plane | topPlane |
Represents a camera's frustum.
Each CC3Camera instance contains an instance of this class.
Each frustum has four sides: top, bottom, left and right, and has two caps: near and far. These sides and caps are represented as six planes.
The frustum is a truncated pyramid that has the location of the camera as the pyrimid apex. This frustum manages and populates the projection matrix used by the camera, and builds its planes from a combination of that projection matrix and the camera's modelview matrix.
The frustum is a type of bounding volume and therefore supports methods for testing whether locations, rays, shapes, and other bounding volumes intersect the volume of the frustum.
- (void) DEPRECATED_ATTRIBUTE |
- (BOOL) doesIntersectPointAt: | (CC3Vector) | DEPRECATED_ATTRIBUTE |
- (BOOL) doesIntersectSphereAt: | (CC3Vector) | aLocation | |
withRadius: | (GLfloat) | DEPRECATED_ATTRIBUTE | |
+ (id) frustumOnModelviewMatrix: | (CC3Matrix *) | aMtx |
Allocates and initializes an autoreleased instance on the specified modelview matrix.
- (id) initOnModelviewMatrix: | (CC3Matrix *) | aMtx |
Initializes this instance on the specified modelview matrix.
- (void) populateFrom: | (GLfloat) | fieldOfView | |
andAspect: | (GLfloat) | aspect | |
andNearClip: | (GLfloat) | nearClip | |
andFarClip: | (GLfloat) | farClip | |
andZoom: | (GLfloat) | zoomFactor | |
Sets the six frustum clipping planes and the projectionMatrix from the specified projection parameters.
The zoomFactor is applied to the field of view to create an effective field of view. A zoomFactor of greater than one will decrease the effective field of view (zooming-in), and a zoomFactor of less than one will increase the effective field of view (zooming-out). For smaller zoomFactor values, the effective field of view is clamped at slightly less than 180 degrees, to avoid an extreme fish-eye effect that makes the scene completely disappear into the distance.
The aspect parameter indicates the width:height ratio of the viewport. The field of view angle is applied to the narrower dimension, to ensure that overall perspective are consistent across a simple transposition of the viewport dimensions (ie- a rotation of the viewport by 90 degrees).
For bounding volumes that are described in terms of a hull of vertices and planes, this property returns the array of planes that define the boundary surface of this bounding volume.
The planes are defined in the global coordinate system. The number of planes in the array is specified by the planeCount property.
Not all bounding volumes are based on vertices and planes, and this abstract implementation returns the NULL pointer. Subclasses that make use of vertices and planes will allocate the underlying array and override this implementation.
Implements CC3BoundingVolume.
For bounding volumes that are described in terms of a hull of vertices and planes, this property returns the array of vertices at the points where the planes intersect.
The vertices are defined in the global coordinate system. The number of vertices in the array is defined by the vertexCount property.
The returned vertices are not in any defined order.
Not all bounding volumes are based on vertices and planes, and this abstract implementation returns the NULL pointer. Subclasses that make use of vertices and planes will allocate the underlying array and override this implementation.
Implements CC3BoundingVolume.
- (GLfloat) bottom [read, assign] |
The distance from view center to the bottom of this frustum at the near clipping plane.
- (CC3Plane) bottomPlane [read, assign] |
The clip plane at the bottom of this frustum, in global coordinates.
- (GLfloat) far [read, assign] |
The distance to the far end of this frustum.
- (CC3Vector) farBottomLeft [read, assign] |
Returns the location of the far bottom left corner of this frustum, in the global coordinate system.
- (CC3Vector) farBottomRight [read, assign] |
Returns the location of the far bottom right corner of this frustum, in the global coordinate system.
- (CC3Plane) farPlane [read, assign] |
The clip plane at the far end of this frustum, in global coordinates.
- (CC3Vector) farTopLeft [read, assign] |
Returns the location of the far top left corner of this frustum, in the global coordinate system.
- (CC3Vector) farTopRight [read, assign] |
Returns the location of the far top right corner of this frustum, in the global coordinate system.
- (CC3Matrix *) infiniteProjectionMatrix [read, assign] |
The projection matrix modified to have an infinite depth of view, by assuming a farClippingDistance set at infinity.
- (BOOL) isUsingParallelProjection [read, write, assign] |
Indicates whether this frustum uses parallel projection.
If this value is set to NO, the projection matrix will be configured for perspective projection, which is typical for 3D scenes. If this value is set to YES, the projection matrix will be configured for orthographic projection.
The initial value of this property is NO, indicating that perspective projection will be used.
- (GLfloat) left [read, assign] |
The distance from view center to the left edge of this frustum at the near clipping plane.
- (CC3Plane) leftPlane [read, assign] |
The clip plane at the left side of this frustum, in global coordinates.
- (CC3Matrix *) modelviewMatrix [read, write, retain] |
The modelview matrix of the camera.
Setting this property will automatically mark the planes as dirty. However, if the contents of the matrix change, this instance will be unaware, and the application is responsible for invoking the markPlanesDirty method to let this instance know.
- (CC3Matrix *) modelviewProjectionMatrix [read, assign] |
The combined modelview-projection matrix that projects the scene to the viewport.
This is simply a multiplicative product of the camera's modelview and projection matrices. It is calculated as part of the recalculation of the frustum planes.
- (GLfloat) near [read, assign] |
The distance to the near end of this frustum.
- (CC3Vector) nearBottomLeft [read, assign] |
Returns the location of the near bottom left corner of this frustum, in the global coordinate system.
- (CC3Vector) nearBottomRight [read, assign] |
Returns the location of the near bottom right corner of this frustum, in the global coordinate system.
- (CC3Plane) nearPlane [read, assign] |
The clip plane at the near end of this frustum, in global coordinates.
- (CC3Vector) nearTopLeft [read, assign] |
Returns the location of the near top left corner of this frustum, in the global coordinate system.
- (CC3Vector) nearTopRight [read, assign] |
Returns the location of the near top right corner of this frustum, in the global coordinate system.
- (CC3Matrix *) projectionMatrix [read, assign] |
The projection matrix that takes the camera's modelview and projects it to the viewport.
- (GLfloat) right [read, assign] |
The distance from view center to the right edge of this frustum at the near clipping plane.
- (CC3Plane) rightPlane [read, assign] |
The clip plane at the right side of this frustum, in global coordinates.
- (GLfloat) top [read, assign] |
The distance from view center to the top of this frustum at the near clipping plane.
- (CC3Plane) topPlane [read, assign] |
The clip plane at the top of this frustum, in global coordinates.