blender/doc
Dalai Felinto 9425a8ff38 BGE: scene.pre_draw_setup[] callback
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() )
```
2015-04-21 17:41:23 -03:00
..
blender_file_format update dna exporter for API changes 2014-11-14 00:55:40 +01:00
build_systems Update scons build documentation 2015-01-28 23:40:41 +05:00
doxygen doxygen: updating blender version and link to tracker 2015-02-21 12:16:20 +00:00
guides Code cleanup: removed some unused UI button types 2013-06-09 18:05:50 +00:00
license And here is the first git (testing) commit by me! 2013-11-16 12:00:42 +01:00
manpage cleanup: shebang lines 2015-01-29 15:56:23 +11:00
python_api BGE: scene.pre_draw_setup[] callback 2015-04-21 17:41:23 -03:00