I’m trying to make a minimap for my game, so I created a DisplayRegion in the corner of my screen and a new camera above my terrain. However, when I get too close to 3d meshes they cover up the DisplayRegion and hide my minimap. Is this supposed to happen, and if so, how do I fix it?
Sounds like you didn’t enable clearing of your new DisplayRegion. Try:
If you don’t clear the DisplayRegion, it will draw on top of what was already drawn before it (which might actually mean below whatever was drawn before it, depending on the depth buffer).
I had the same problem, which I solved with the suggestions made. I use a display region which overlaps the normal rendering surface as a mirror. On that mirror I project an image with a camera that records what is behind me. And then I mirror that image over the X-axis to get a correct mirror image, see code.
centralMirror = base.win.makeDisplayRegion(left, right, bottom, top) centralMirror.setClearColorActive(True) centralMirror.setClearDepthActive(True) self.centralMirrorCamera = Camera('centralmirrorcam') self.cMCameraNP = render.attachNewNode(self.centralMirrorCamera) self.cMCameraNP.setScale(-1,1,1) centralMirror.setCamera(self.cMCameraNP) self.parentnode1 = render.attachNewNode('camparent1') self.parentnode1.reparentTo(render) self.cMCameraNP.reparentTo(self.parentnode1) lens = self.centralMirrorCamera.getLens() lens.setFar(1500.0)
If I do this, the image in the mirror is okay, except that the sky is not rendered: the sky is black and you can’t see the skydome. If I leave out the self.cMCameraNP.setScale(-1,1,1) statement, the sky is generated correctly in the mirror, but the image is not mirrored over the x-axis.
Must be something simple that I overlooked. Any help is welcommed.
When you mirror a scene by giving it a -1 scale, you reverse the vertex winding order, so that clockwise polygons become counter-clockwise, and vice-versa. Since your graphics card uses vertex winding order to determine which side of the polygon is the front, you have just reversed all of your polygons and basically turned the world inside-out. That’s my guess as to why you’re not seeing the sky, and probably other weird artifacts as well.
The easy way to compensate for this is to tell the camera to use the opposite convention for vertex winding order, for instance:
dummy = NodePath('dummy') dummy.setAttrib(CullFaceAttrib.makeReverse()) camera.setInitialState(dummy.getState())
Brilliant!. Thank you, that worked.