-
Notifications
You must be signed in to change notification settings - Fork 26
Camera
Last revision: ver. 8.0.2 - 6 August 2015
Controls the applications camera (accessed through getDefaultCamera()
or additional cameras in the application.
These global functions are used to manage cameras.
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.
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.
Deletes a secondary camera. NOTE: The default camera cannot be deleted.
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.
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)