Get the depth buffer

Hi all,

I’m currently trying to obtain the depth buffer without the use of shaders, I try to force the texture to the RAM, but without success.
here’s my (unworking) code:

class ImageManager:
    def __init__(self):
        self.manager = FilterManager(base.win, base.cam)
        self.screenTexture = Texture()
        self.screenTexture.setFormat(Texture.FRgba32)
        self.quad = self.manager.renderSceneInto(depthtex=self.screenTexture)
        self.screenTexture.setKeepRamImage(True)
        #base.win.addRenderTexture(self.screenTexture,GraphicsOutput.RTMCopyRam)
        print "Image Manager running"
    def getImage(self):
        idata=None
        sx=sy=0
        self.screenTexture.makeRamImage()
        if self.screenTexture.hasRamImage():         
            idata=self.screenTexture.getRamImage().getData()
            sx=self.screenTexture.getXSize()
            sy=self.screenTexture.getYSize()
        return (idata,sx,sy)

class World(DirectObject.DirectObject):

    def __init__(self):
        self.accept("q",sys.exit)
        self.IM=ImageManager()
        taskMgr.add(self.t,"adasdasd")
        self.box=loader.loadModel("models/box")
        self.box.reparentTo(render)
        self.screen=pygame.display.set_mode((800,600))

    def t(self,task):
        try:
            a=self.IM.getImage()
            print len(a[0])#a is NoneType!!!! (has no length)
            b=pygame.image.fromstring(a[0],(a[1],a[2]),"RGBA")
            self.screen.blit(b,(0,0))
            pygame.display.flip()
        except TypeError:
            print "Unable to get depth buffer..."
        return Task.cont
import math

#Task to move the camera
def SpinCameraTask(task):
  angledegrees = task.time * 6.0
  angleradians = angledegrees * (math.pi / 180.0)
  base.camera.setPos(20*math.sin(angleradians),-20.0*math.cos(angleradians),3)
  base.camera.setHpr(angledegrees, 0, 0)
  return Task.cont

taskMgr.add(SpinCameraTask, "SpinCameraTask")

w=World()
run()

Can this method actually be used? If not, what should I do?

So, can this actually be done in Panda?

I’m not sure. It’s supposed to work, but I think there were some issues in the buffer-management code that crept in recently, making it difficult to create a texture of the appropriate format. (And note that the format should be FDepthComponent, and not FRgba32.)

I haven’t had a chance to investigate lately. If anyone else is willing to look into it, I’d be happy to accept your help.

David