I have the impression that it will be relatively straightforward, but I seek some confirmation before proceeding to familiarize myself with Panda3D (Java3D was used previously). Is it simply a matter of defining two cameras? Perhaps, as explained here?: panda3d.org/manual/index.php/Multi-Pass_Rendering
i once wrote a small 3d-panoramic-viewer.
the cameras are not positioned as you would like them to be but the rest is pretty much what you’r looking for.
class PanoramaDemo(DirectObject):
def __init__(self):
# Camera 1
self.my_cam1 = Camera("cam1")
## my_cam1.setScene(land)
self.my_camera1 = render.attachNewNode(self.my_cam1)
self.my_camera1.setName("camera1")
self.my_camera1.setPos(0,20,0)
# Camera 2
self.my_cam2 = Camera("cam2")
self.my_camera2 = render.attachNewNode(self.my_cam2)
self.my_camera2.setName("camera2")
self.my_camera2.setPos(0,-20,0)
dr = base.camNode.getDisplayRegion(0)
dr.setActive(0) # Or leave it (dr.setActive(1))
# Now, make a new pair of side-by-side DisplayRegions.
window = dr.getWindow()
dr1 = window.makeDisplayRegion(0, 0.5, 0, .75)
dr1.setSort(dr.getSort())
dr2 = window.makeDisplayRegion(0.5, 1, 0, .75)
dr2.setSort(dr.getSort())
# A smaller window
# Setup each camera.
dr1.setCamera(self.my_camera1)
dr2.setCamera(self.my_camera2)
Thomas’ solution is perfectly correct. But note also that Panda has built-in support for stereo, and with it you can define your two views as the left and right eyes of a stereo camera. This makes it a little more automatic to set up the convergence distance and so forth; it is also a slight optimization because Panda knows it needs to perform the cull operation only once for both left and right views.
from direct.directbase.DirectStart import *
from pandac.PandaModules import *
def splitScreen():
""" This function splits the main display region into two separate
left-and-right regions, which represent the left and right eye of
the camera. """
# First, disable the default DisplayRegion, which covers the whole
# screen.
dr = base.camNode.getDisplayRegion(0)
dr.setActive(0)
# Now, make a new pair of side-by-side DisplayRegions.
window = dr.getWindow()
dr1 = window.makeDisplayRegion(0, 0.5, 0, 1)
dr1.setSort(dr.getSort())
dr2 = window.makeDisplayRegion(0.5, 1, 0, 1)
dr2.setSort(dr.getSort())
# Set these both up to use the same camera.
dr1.setCamera(base.cam)
dr2.setCamera(base.cam)
# And make them into left and right stereo pairs.
dr1.setStereoChannel(Lens.SCLeft)
dr2.setStereoChannel(Lens.SCRight)