blender/doc/python_api/rst
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
..
bge_types BGE: scene.pre_draw_setup[] callback 2015-04-21 17:41:23 -03:00
bge.constraints.rst BGE: Add keyword arguments to createConstraint API 2015-04-11 16:17:07 +02:00
bge.events.rst BGE doc cleanup: Some small cleanups in the BGE docs: 2014-03-31 22:22:04 -07:00
bge.logic.rst BGE: TrackTo actuator: increasing up & track axis options 2014-07-14 18:30:27 -07:00
bge.render.rst BGE: New API method getDisplayDimensions 2015-04-07 18:32:25 +02:00
bge.texture.rst BGE VideoTexture: add depth buffer access to ImageViewport and ImageRender. 2012-10-20 22:28:44 +00:00
bge.types.rst BGE: Splitting up the bge.types docs so they are not all on the same page. This should make them much easier to browse. 2013-02-10 06:13:26 +00:00
bgl.rst Documentation update: references to OpenGL tutorials in the python bgl module 2015-02-21 12:16:19 +00:00
change_log.rst update autogenerated changelog. also correct typos in the generator. 2013-05-09 01:58:49 +00:00
gpu.rst Syntax correction for gpu docs, D124 2013-12-23 17:24:23 +11:00
include__bmesh.rst BMesh Py API: add bmesh.geometry.intersect_face_point() 2013-12-06 21:15:56 +11:00
info_api_reference.rst Add 2 documents to the python api reference. 2012-12-07 05:27:09 +00:00
info_best_practice.rst spelling cleanup: spelling corrections from user zeffii on IRC. 2012-08-19 15:28:24 +00:00
info_gotcha.rst Make python gotchas more clear (regarding handling of stale data) 2015-04-13 11:00:22 +02:00
info_overview.rst Add 2 documents to the python api reference. 2012-12-07 05:27:09 +00:00
info_quickstart.rst PyAPI docs: minor changes to sphinx docs. 2015-01-08 03:55:01 +11:00
info_tips_and_tricks.rst Fix T38032, typo in Python API documentation. 2014-01-03 02:28:21 +01:00
info_tutorial_addon.rst PyAPI docs: minor changes to sphinx docs. 2015-01-08 03:55:01 +11:00