SCController

Inherits From:
NSObject

Conforms To:
NSCoding

Declared In:
Sc21/SCController.h

Class Description

An SCController is the main component for rendering Coin scene graphs. It handles all actual scene management and rendering, and passes events on to the eventhandler chain.

The most basic setup of using an SCController is to have an SCSceneGraph, an SCView, and an SCController instance, connecting the SCView's controller outlet to the SCController and the SCController's sceneGraph outlet to the SCSceneGraph.

Since Coin is a data driven API, redraws are usually requested by the scene graph itself. To handle these redraws, the controller must be given a "drawable" (an object conforming to the SCDrawable protocol) that should called upon such a redraw request. See the SCDrawable and SCView documentation for more information.


Global Variables

Synopsis:

NSString * SCSceneGraphChangedNotification;

Description:

Posted when the scenegraph is changed through setSceneGraph:


Method Types

Static initialization
+ initCoin
Initializing an SCController
- init
Coin rendering and related functionality
- render
Accessing the drawable
- setDrawable:
- drawable
Accessing the scenegraph and scenemanager
- setSceneGraph:
- sceneGraph
- setSceneManager:
- sceneManager
Render settings
- setBackgroundColor:
- backgroundColor
- setClearsColorBuffer:
- clearsColorBuffer
- setClearsDepthBuffer:
- clearsDepthBuffer
Event handling
- handleEvent:
- setEventHandler:
- eventHandler


Class Methods

initCoin

+ (void)initCoin

Initializes Coin.

SCController automatically calls this method if needed.

You need to call this method explicitly only if you want to use Coin functionality before actually instantiating an SCController in your application (e.g. if you want to read a 3D model from disk and load the nib file containing your SCView and SCController only if the file was read successfully).

This method calls SoDB::init(), SoInteraction::init() and SoNodeKit::init().


Instance Methods

backgroundColor

- (NSColor *)backgroundColor

Returns the scene's background color.


clearsColorBuffer

- (BOOL)clearsColorBuffer

Returns YES if the receiver clears the color buffer before rendering. The default value is YES.


clearsDepthBuffer

- (BOOL)clearsDepthBuffer

Returns YES if the receiver clears the depth buffer before rendering. The default value is YES.


drawable

- (id<SCDrawable>)drawable

Returns the receiver's drawable.


eventHandler

- (SCEventHandler *)eventHandler

Returns the first eventhandler in the receiver's eventhandler chain.


handleEvent:

- (BOOL)handleEvent:(NSEvent *)event

Handle event by sending it down the eventhandler chain, starting at the receiver's eventHandler. If eventHandler returns NO, event is sent to the eventHandler's nextEventHandler, and so on.

Note that the Sc21 way of handling events is different from the one taken in Cocoa (where events are normally handled by NSView subclasses) - SCView just passes on all events to this method. (See the SCEventHandler documentation for more information on eventhandling in Sc21.)

For overriding the default behavior of ctrl-clicks (context menu), see the documentation for SCView's -mouseDown: method.

Returns YES if the event has been handled, NO otherwise.


init

- (id)init

Designated initializer.

Initializes a newly allocated SCController and calls initCoin.


render

- (void)render

Renders the scene by calling the receiver's SoSceneManager's render() funtion. After rendering, an update: message is sent to each eventhandler in the event handler chain, starting at the receiver's eventHandler.


sceneGraph

- (SCSceneGraph *)sceneGraph

Returns the receiver's scenegraph


sceneManager

- (SoSceneManager *)sceneManager

Returns the receiver's Coin scene manager instance.


setBackgroundColor:

- (void)setBackgroundColor:(NSColor *)color

Sets the background color of the scene to color. Raises an exception if color cannot be converted to an RGB color.


setClearsColorBuffer:

- (void)setClearsColorBuffer:(BOOL)yesno

Controls whether the receiver should clear the color buffer before rendering. The default value is YES.


setClearsDepthBuffer:

- (void)setClearsDepthBuffer:(BOOL)yesno

Controls whether the receiver should clear the depth buffer before rendering. The default value is YES.


setDrawable:

- (void)setDrawable:(id<SCDrawable>)newdrawable

Set the receiver's drawable. Note that you do not have to call this method if you are using an SCView.


setEventHandler:

- (void)setEventHandler:(SCEventHandler *)handler

Set the receiver's eventhandler, which will be the start of the eventhandler chain.(See handleEvent: for more information.)


setSceneGraph:

- (void)setSceneGraph:(SCSceneGraph *)scenegraph

Sets the scene graph that shall be rendered.


setSceneManager:

- (void)setSceneManager:(SoSceneManager *)scenemanager

Sets the receiver's scene manager to scenemanager. The scene manager's render callback will be set to SCController's internal redraw callback implementation; and scenemanager will be activated. Also, if a scenegraph has been set earlier, scenemanager's scenegraph will be set to it.

Note that you should not normally need to call that method, since a scene manager is created for you while initializing.


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