forked from bartvdbraak/blender
9425a8ff38
This callback allows the user to change the camera data right before the rendering calculations. scene.pre_draw[] is not enough here, because if you want to change the camera matrices (projection/modelview) the culling test is done before that (after pre_draw_setup[] though). Reviewers: moguri, campbellbarton Differential Revision: https://developer.blender.org/D1251 Python sample code using this. The sample scene would need a default camera (not used for rendering), a dummy camera ('Camera.VR'), and two cameras ('Camera.Left', 'Camera.Right') that will be used for the actual rendering. ``` import bge def callback(): scene = bge.logic.getCurrentScene() objects = scene.objects vr_camera = objects.get('Camera.VR') if bge.render.getStereoEye() == bge.render.LEFT_EYE: camera = objects.get('Camera.Left') else: camera = objects.get('Camera.Right') vr_camera.worldOrientation = camera.worldOrientation vr_camera.worldPosition = camera.worldPosition def init(): scene = bge.logic.getCurrentScene() main_camera = scene.active_camera main_camera.useViewport = True scene.pre_draw_setup.append(callback) objects = scene.objects vr_camera = objects.get('Camera.VR') vr_camera.useViewport = True vr_camera.setViewport( 0, 0, bge.render.getWindowWidth(), bge.render.getWindowHeight() ) ``` |
||
---|---|---|
.. | ||
bge_types | ||
bge.constraints.rst | ||
bge.events.rst | ||
bge.logic.rst | ||
bge.render.rst | ||
bge.texture.rst | ||
bge.types.rst | ||
bgl.rst | ||
change_log.rst | ||
gpu.rst | ||
include__bmesh.rst | ||
info_api_reference.rst | ||
info_best_practice.rst | ||
info_gotcha.rst | ||
info_overview.rst | ||
info_quickstart.rst | ||
info_tips_and_tricks.rst | ||
info_tutorial_addon.rst |