Public Member Functions | Properties

CC3Camera Class Reference

CC3Camera represents the camera viewing the 3D world. More...

#import <CC3Camera.h>

Inheritance diagram for CC3Camera:
CC3TargettingNode CC3Node CC3Identifiable CC3PODCamera

List of all members.

Public Member Functions

(void) - buildPerspective
(void) - close
(void) - markProjectionDirty
(void) - open
(CC3Vector- projectLocation:
(CC3Vector- projectNode:

Properties

GLfloat farClippingPlane
GLfloat fieldOfView
CC3Frustumfrustum
CC3GLMatrixmodelviewMatrix
GLfloat nearClippingPlane
CC3GLMatrixprojectionMatrix
CC3Worldworld

Detailed Description

CC3Camera represents the camera viewing the 3D world.

CC3Camera is a type of CC3Node, and can therefore participate in a structural node assembly. An instance can be the child of another node, and the camera itself can have child nodes. For example, a camera can be mounted on a boom object or truck, and will move along with the parent node. Or the camera node itself might have a light node attached as a child, so that the light will move along with the camera, and point where the camera points.

CC3Camera is also a type of CC3TargettingNode, and can be pointed in a particular direction, or can be made to track a target node as that node moves, or the camera moves.

If you find that objects in the periphery of your view appear elongated, you can adjust the fieldOfView and/or uniformScale properties to reduce this "fish-eye" effect. See the notes of the fieldOfView property for more on this.


Member Function Documentation

- (void) buildPerspective

Updates the transformMatrix and modelviewMatrix if the target has moved, builds the projectionMatrix if needed, and updates the frustum if needed.

This method is invoked automatically from the CC3World after all updates have been made to the models in the 3D world. Usually, the application never needs to invoke this method directly.

- (void) close

Closes the camera for drawing operations.

This method is called automatically by the CC3World at the end of each frame drawing cycle. Usually, the application never needs to invoke this method directly.

- (void) markProjectionDirty

Indicates that the projection matrix is dirty and needs to be recalculated.

This method is invoked automatically as needed. Usually the application never needs to invoke this method directly.

- (void) open

Opens the camera for drawing operations.

This method is called automatically by the CC3World at the beginning of each frame drawing cycle. Usually, the application never needs to invoke this method directly.

- (CC3Vector) projectLocation: (CC3Vector a3DLocation

Projects the specified 3D world location onto a 2D position in the viewport coordinate space, indicating where on the screen this 3D location will be seen.

The 2D position can be read from the X and Y components of the returned 3D location.

The Z-component of the returned location indicates the distance from the camera to the specified location, with a positive value indicating that the specified location is in front of the camera, and a negative value indicating that the specified location is behind the camera.

Any 3D world location can be either in front of or behind the camera, and both cases will be projected onto the 2D space of the viewport plane. If you are only interested in the case when the specified location is in front of the camera (potentially visible to the camera), check that the Z-component of the returned location is positive.

This method takes into account the orientation of the device (portrait, landscape).

- (CC3Vector) projectNode: (CC3Node *)  aNode

Projects the globalLocation of the specified node onto a 2D position in the viewport coordinate space, by invoking the projectLocation: method of this camera, passing the node's globalLocation.

See the notes of the projectLocation: method for more info about the content of the returned vector.

In addition to returning the projected 2D location, this method also sets that value into the projectedLocation property of the node, for future access.


Property Documentation

- (GLfloat) farClippingPlane [read, write, assign]

The distance from the camera to the clipping plane of the camera's frustrum that is farthest from the camera.

Initially set to kCC3DefaultFarClippingPlane.

- (GLfloat) fieldOfView [read, write, assign]

The nominal field of view of this camera, in degrees.

The initial value of this property is set to kCC3DefaultFieldOfView.

The effective field of view is influenced by the value of the uniformScale property, which, for cameras, acts as a zoom factor (as if the camera lens is zoomed in or out).

Once a nominal field of view has been set in this property, changing the scale or uniformScale properties will change the effective field of view accordingly (although the value of the fieldOfView property remains the same). The effective field of view is calculated as (fieldOfView / uniformScale). Scales greater than one zoom in (objects appear larger), and scales between one and zero zoom out (objects appear smaller).

Like real-world cameras, larger values for fieldOfView can sometimes result in a "fish-eye" effect, where objects at the periphery of the view can appear elongated. To reduce this effect, lower the value of fieldOfView property, or increase the value of the uniformScale property. In doing so, you may need to move your camera further away from the scene, so that your view will continue to include the same objects.

- (CC3Frustum *) frustum [read, write, retain]

The frustum of the camera.

- (CC3GLMatrix *) modelviewMatrix [read, write, retain]

The matrix that holds the transform from model space to view space.

This matrix is distinct from the camera's transformMatrix, which, like that of all nodes, reflects the location, rotation and scale of the camera node in the 3D world space.

In contrast, the modelviewMatrix combines the inverse of the camera's transformMatrix (because any movement of the camera in world space has the opposite effect on the view), with the deviceRotationMatrix from the viewportManager of the CC3World, to account for the impact of device orientation on the view.

- (GLfloat) nearClippingPlane [read, write, assign]

The distance from the camera to the clipping plane of the camera's frustrum that is nearest to the camera.

Initially set to kCC3DefaultNearClippingPlane.

- (CC3GLMatrix *) projectionMatrix [read, write, retain]

The projection matrix that takes the camera's modelview and projects it to the viewport.

- (CC3World *) world [read, write, assign]

The CC3World in which the camera exists.

This property is automatically set when this camera is added to the CC3World, even if it is part of a larger assembly of nodes. Usually, the application never needs to set this property.


The documentation for this class was generated from the following file: