two windows, slightly different scenes

Hi there,

I would like to have two windows, where most of the scene is exactly the same, but one window has one additional element. I know I can open a new window with base.openWindow() and get the camera for that window, but I can’t have objects with two parents, correct? This is an extremely simple scene, with basically just one object in the original scene. So, is the best way to do this to load the model for the object in the original scene twice, each with its own camera parents, and then I can have my second object that is a child of just one of the cameras? If I do it this way, I have to duplicate my code manipulating the duplicated object. Or have I misunderstood something fundamental?

thanks,
Maria

Maybe you need two cameras with different Masks?

For the record, you can have objects with two parents: it’s called instancing.

You don’t need to load your models twice. You can either use instancing to instance one node to two scene graph parents (though instanceTo offers little benefit over copyTo in many cases), or you could do what ninth suggested: add a second camera that renders the same scene, except has a camera mask. You can use hide() and show() on a particular node passing a particular mask to hide or show a node for that camera only.

Thanks for the answers! I knew about objects and instancing, but I thought I read in the manual that the nodes couldn’t have more than one parent. I can’t find that in the manual now, so not sure where I got that idea.

thanks,
Maria

I used a second camera, and set the camera mask for the second camera, and it works like a charm. I can’t seem to access the second window, however. Whether I am trying to set the background color or attach a keypress, it only works for the first window. I tried using the same trick as the getting the second camera, window.winList[1], but this gives me, AttributeError: ‘libpanda.GraphicsWindow’ object has no attribute ‘setBackgroundColor’. What am I missing?

thanks,
Maria

You’ll need to store the GraphicsWindow object somewhere - base.win only stores a reference to the main window. The function setBackgroundColor is just a shortcut for setClearColorActive(True) setClearColor((r, g, b, a)) on the GraphicsWindow object itself.

Thanks so much for your patience. I am having a hard time understanding the manual on this point. It seems this is not as simple as saying gw = GraphicsWindow(). It appears I need to use base.graphicsEngine.makeOutput(pipe, name, sort, fbProps, winProps, flags, gsg, host) But, this sounds like just a more complicated way of creating a second window, and it sounds like you are talking about an object that refers to both the new window and the main window. Or are you saying that if I have this new GraphicsWindow object, than I can attach a keypress or set the color to both windows? I was able to set the background color finally to the second window by doing this:
window2 = win.openWindow()
window2.setClearColor((115 / 255, 115 / 255, 115 / 255, 1))
But, I’m not sure what to do about keypresses, since they are attached to self, which is a DirectObject, and not really either window.
thanks,
Maria