Skip to content
Alessandro Febretti edited this page Sep 23, 2015 · 15 revisions

extends SceneNode wraps Camera

Last revision: ver. 8.0.2 - 6 August 2015

Controls the applications camera (accessed through getDefaultCamera() or additional cameras in the application.

Methods

Method(s)

Description

setEnabled(bool enabled) bool isEnabled()

When set to disabled, the camera will not draw new frames.

setPitchYawRoll(Vector3 value)

Sets the camera orientation as yaw, pitch roll in radians. value is a 3. For example, to rotate 45 degrees around the global Y axis: camera.setPitchYawRoll(Vector3(0, radians(45), 0))

Vector3 getHeadOffset(), setHeadOffset(Vector3 value)

Gets or sets the relative offset of the observer head, relative to the camera position. The head offset in conjunction with the head orientation and eye separation to compute the camera projection frustum. The head offset is a 3.

setEyeSeparation(float value), float getEyeSeparation()

Gets or sets the eye separation for stereo rendering.

setHeadOrientation(Quaternion value), Quaternion getHeadOrientation()

Gets or sets the head orientation relative to the camera orientation. The orientation value is a .

focusOn(SceneNode node)

Moves and orients the camera to center the specified in the field of view.

int getCameraId()

Gets the unique id of this camera.

float getNearZ() float getFarZ() setNearFarZ(float near, float far)

Gets or sets the near and far Z clipping planes for this camera.

Tracking and Navigation

bool isTrackingEnabled(), setTrackingEnabled(bool value)

int getTrackerSourceId(), setTrackerSourceId(int value)

setControllerEnabled(bool value), bool isControllerEnabled()

CameraController getController()

Gets the used to handle this camera navigation.

View Management

DisplayTileConfig getCustomTileConfig()

Gets the custom rendering configuration for this camera (see ). Cameras usually render using the tile configuration of the physical tile they are rendering to. Setting this display tile configuration to enabled will cause the camera to render using these custom settings instead.

Vector2 getViewPosition() setViewPosition(float x, float y)

experimental

Vector2 getViewSize() setViewSize(float x, float y)

experimental

bool isSceneEnabled() setSceneEnabled(bool enabled)

When set to true, will draw all 3D scene render passes for this camera. Set to true by default.

bool isOverlayEnabled() setOverlayEnabled(bool enabled)

When set to true, will draw all 2D overlay render passes for this camera. Set to true by default.

(v8.0.2) bool isCullingEnabled(), setCullingEnabled(bool enabled)

When set to false, disables all culling for this camera. All drawables will attempt drawing, even the ones that are outside of this camera frustum. This is useful to force drawing of all objects when we want to use vertex shaders with custom projections. By default, culling is enabled.

(5.2) CameraOutput getOutput([int contextId])

Returns the camera output (see ), optionally specifying the output context when rendering on multiple contexts.

Clear Color / Depth (6.0)

setBackgroundColor(Color c), Color getBackgroundColor()

Gets or sets the background color used to clear the frame buffer (see )

clearColor(bool enabled), bool isClearColorEnabled()

Enables or checks the state of color buffer clearing (using the color specified in setBackgroundColor)

clearDepth(bool enabled), bool isClearDepthEnabled()

Enables or checks the state of depth buffer clearing

On-demand drawing (v8.0.3)

queueFrameDraw()

Queues one frame for drawing. Use this to force a frame draw when MaxFps is set to 0.

setMaxFps(float fps), float getMaxFps()

Set the maximum fps that this camera will render at. Use 0 to stop camera drawing and use queueFrameDraw to draw frames on-demand. Use -1 to disable the fps cap and let this camera draw at the maximum renderer speed (typically 60fps).

Global functions

These global functions are used to manage cameras.

Camera getDefaultCamera()

Returns the main omegalib camera instance

Camera getCamera(string name)

Finds a camera by name

Camera getCameraById(int id)

Finds a camera by id. Each camera created by an application has a unique id. When a camera gets destroyed its id will not get recycled.

Camera getOrCreateCamera(string name)

Finds a camera by name, or creates it if no camera with the specified name exists. NOTE: For new cameras, overlay rendering will be disabled by default, since this is typically the desired behavior. To control scene and/or overlay rendering for the camera, use the camera setOverlayEnabled and setSceneEnabled methods.

(v6.0) deleteCamera(Camera c)

Deletes a secondary camera. NOTE: The default camera cannot be deleted.

setTileCamera(string tileName, string cameraName)

Sets the camera attached to the specified tile (by name). The tile names can be obtained using the getTiles() function. If a camera with the specified name does not exist, it will be created.

setNearFarZ(near, far)

Sets the near and far clip planes for the default camera

getNearZ()

Gets the near clip plane for the default camera

getFarZ()

Gets the far clip plane for the default camera

Examples

Secondary Cameras

NOTE: This example makes use of the cyclops module. Make sure you have it installed to use this.

box = BoxShape.create(0.8, 0.8, 0.8)
box.setPosition(Vector3(0, 2, -3))

# Apply an emissive textured effect (no lighting)
box.setEffect("textured -v emissive -d cyclops/test/omega-transparent.png")

# Spin the box!
def onUpdate(frame, t, dt):
	box.pitch(dt)
	box.yaw(dt / 3)
setUpdateFunction(onUpdate)

def createSecondaryCameraWindow(id, windowName, width, height, x, y):
    # create second camera
    cam = getOrCreateCamera(id)
    cam.setHeadOffset(Vector3(0, 2, 0))

    coutput = PixelData.create(width,height,PixelFormat.FormatRgba)
    cam.getOutput(0).setReadbackTarget(coutput)
    cam.getOutput(0).setEnabled(True)

    # create a movable window displaying the output of the second camera.
    uim = UiModule.createAndInitialize()
    container = Container.create(ContainerLayout.LayoutVertical, uim.getUi())
    container.setStyleValue('fill', 'black')
    container.setPosition(Vector2(x, y))
    container.setAlpha(1)
    titleBar = Label.create(container)
    titleBar.setText(windowName)
    titleBar.setPinned(True)
    titleBar.setDraggable(True)
    titleBar.setVisible(True)
    titleBar.setAutosize(False)
    titleBar.setStyleValue('fill', '#000000ff')
    titleBar.setHeight(24)

    img = Image.create(container)
    img.setData(coutput)
    
    return cam
    
# create two secondary camera windows
createSecondaryCameraWindow('c1', 'Camera 1', 250, 250, 5, 25)
createSecondaryCameraWindow('c2', 'Camera 2 (custom render)', 250, 250, 270, 25)
Clone this wiki locally