Multiple Windows with different Cameras

Hi all,

This is my first post here!

I want to have two windows and two cameras. Each window should be displaying one of the views. I tried creating a window using base.openWindow(). So I guess this should mean base.camList[1] is the camera of the new window. But I am unable to control it like that.

Anyway, I wanted to which is the right method to use two cameras and output them to two windows.

Thanks in advance!
Goutham

I did search the forums before posting but was unable to find a solution. I went through this post:
discourse.panda3d.org/viewtopic.php?t=696

You didn’t specify whether your two cameras should be viewing the same scene or not. Here’s an example of viewing two different scenes:

from direct.directbase.DirectStart import *
from pandac.PandaModules import *

base.disableMouse()

win2 = base.openWindow()
cam2 = base.camList[1]

render2 = NodePath('render2')
cam2.reparentTo(render2)

s = loader.loadModel('smiley.egg')
s.reparentTo(render)
camera.setPos(0, -20, 0)

f = loader.loadModel('frowney.egg')
f.reparentTo(render2)
cam2.setPos(0, -20, 0)

To make them both view the same scene, simply leave cam2 parented somewhere under render. If you leave it under its default parent, camera, then it will be slaved to move along wherever you move camera to (just as the default camera is). You can have it look in a slightly different direction, but it will always have the same point of view of the main camera, kind of like a stereo or circle-vision camera. If you want it to be completely independent of the main camera, attach it to some different node.

If you want to be able to control it with the mouse, similar to the way you control the main camera with the mouse, you have to set up all of the infrastructure that makes that possible. That means repeating the work that is done by base.setupMouse().

David

Thanks for the reply!. Sorry i wasnt being more specific. I needed to have two cameras in the same scene. More like each camera being the eyes of one character. And then see them in two different windows.

Great, well, in that case it’s simpler. As I said above, just leave the new cam2 node where it is, and don’t bother creating a render2d node.

David

Thanks a lot! it works.