SCCamera

Inherits From:
NSObject

Declared In:
Sc21/SCCamera.h

Class Description

An SCCamera encapsulates an SoCamera. The purpose of this abstraction is to provide convenience methods for moving and reorienting the camera and for adjusting the clipping planes to optimize z buffer usage.

In a typical Sc21 application, you will never need to create an SCCamera yourself, since SCSceneGraph automatically initializes one. Use SCSceneGraph's camera: method to access that SCCamera.


Method Types

Positioning the camera
- reorient:
- translate:
- zoom:
- viewAll:
Adjusting the clipping planes
- updateClippingPlanes:
- updatesClippingPlanes
- setUpdatesClippingPlanes:
Accessing the SoCamera
- setSoCamera:
- soCamera
Delegate handling
- setDelegate:
- delegate

Instance Methods

delegate

- (id)delegate

Returns the receiver's delegate.


reorient:

- (void)reorient:(SbRotation)rotation

Reorients the receiver's SoCamera camera by rotation.

Note that this does not replace the previous values but is accumulative: the current orientation will be multiplied with rotation.


setDelegate:

- (void)setDelegate:(id)newdelegate

Makes newdelegate the receiver's delegate.


setSoCamera:

- (void)setSoCamera:(SoCamera *)newcamera

Sets the receiver's SoCamera to newcamera.


setUpdatesClippingPlanes:

- (void)setUpdatesClippingPlanes:(BOOL)yn

Sets whether the receiver should automatically update the clipping planes to optimzie z-buffer usage. The default is YES.


soCamera

- (SoCamera *)soCamera

Returns the receiver's SoCamera.


translate:

- (void)translate:(SbVec3f)vector

Translates the receiver's SoCamera by vector relative to its own coordinate system.(In its own coordinate system, the camera is pointing in negative Z direction with the Y axis being up.)


updateClippingPlanes:

- (void)updateClippingPlanes:(SCSceneGraph *)scenegraph

Positions the near and far clipping planes just in front of and behind the scene's bounding box to optimize depth buffer usage.

If present, the delegate method adjustNearClippingPlane:farClippingPlane: will be called with the internally calculated near and far clipping plane values to allow for final fine-tuning. (See the NSObject(SCCameraDelegate) documentation for more information.)

You can set updatesClippingPlanes to NO to disable automatic clipping plane adjustment. In this case, the delegate method adjustNearClippingPlane:farClippingPlane: (if present) will be called with the current (unmodified) near and far clipping plane values, allowing you to do your own custom modifications.


updatesClippingPlanes

- (BOOL)updatesClippingPlanes

Returns YES if the receiver automatically updates the clipping planes to optimzie z-buffer usage, and NO otherwise. The default is YES


viewAll:

- (void)viewAll:(SCSceneGraph *)scenegraph

Positions the receiver's SoCamera so the whole scene in scenegraph is visible. The SoCamera must be part of the scenegraph.


zoom:

- (void)zoom:(float)delta

Zooms in if delta is > 0, else zoom out.

This method is designed so it can easily be connected to mouse movement, using the difference between normalized mouse coordinates as input. Therefore, typical delta values are expected to be in the area of 0.001 - 0.005; the actual zoom factor is calculated based on delta.


Sc21 version 1.0 © 2003-2004 Systems in Motion AS.