def createBuffer(self, name, xsize, ysize, texgroup, depthbits=1): """ Low-level buffer creation. Not intended for public use. """ winprops = WindowProperties() winprops.setSize(xsize, ysize) props = FrameBufferProperties() props.setRgbColor(1) props.setDepthBits(depthbits) depthtex, colortex, auxtex0, auxtex1 = texgroup if (auxtex0 != None): props.setAuxRgba(1) if (auxtex1 != None): props.setAuxRgba(2) buffer=base.graphicsEngine.makeOutput( self.win.getPipe(), name, -1, props, winprops, GraphicsPipe.BFRefuseWindow | GraphicsPipe.BFResizeable, self.win.getGsg(), self.win) if (buffer == None): return buffer if (depthtex): buffer.addRenderTexture(depthtex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepthStencil) if (colortex): buffer.addRenderTexture(colortex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) if (auxtex0): buffer.addRenderTexture(auxtex0, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0) if (auxtex1): buffer.addRenderTexture(auxtex1, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1) buffer.setSort(self.nextsort) buffer.disableClears() buffer.getDisplayRegion(0).disableClears() self.nextsort += 1 return buffer
def createBuffer(self, name, xsize, ysize, texgroup, depthbits=1): """ Low-level buffer creation. Not intended for public use. """ winprops = WindowProperties() winprops.setSize(xsize, ysize) props = FrameBufferProperties() props.setRgbColor(1) props.setDepthBits(depthbits) depthtex, colortex, auxtex0, auxtex1 = texgroup if (auxtex0 != None): props.setAuxRgba(1) if (auxtex1 != None): props.setAuxRgba(2) buffer=base.graphicsEngine.makeOutput( self.win.getPipe(), name, -1, props, winprops, GraphicsPipe.BFRefuseWindow | GraphicsPipe.BFResizeable, self.win.getGsg(), self.win) if (buffer == None): return buffer if (depthtex): buffer.addRenderTexture(depthtex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) if (colortex): buffer.addRenderTexture(colortex, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) if (auxtex0): buffer.addRenderTexture(auxtex0, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0) if (auxtex1): buffer.addRenderTexture(auxtex1, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1) buffer.setSort(self.nextsort) buffer.disableClears() buffer.getDisplayRegion(0).disableClears() self.nextsort += 1 return buffer
def init_fbp(): """ Initial / default FrameBufferProperties """ fbp = FrameBufferProperties() fbp.setRgbColor(1) fbp.setColorBits(1) fbp.setAlphaBits(1) fbp.setDepthBits(1) return fbp
def createOffscreenBuffer(sort): winprops = WindowProperties.size(SIZE, SIZE) props = FrameBufferProperties() props.setRgbColor(1) props.setAlphaBits(1) props.setDepthBits(1) return base.graphicsEngine.makeOutput(base.pipe, "offscreenBuffer", sort, props, winprops, GraphicsPipe.BFRefuseWindow, base.win.getGsg(), base.win)
def createOffscreenBuffer(sort): winprops = WindowProperties.size(SIZE, SIZE) props = FrameBufferProperties() props.setRgbColor(1) props.setAlphaBits(1) props.setDepthBits(1) return base.graphicsEngine.makeOutput( base.pipe, "offscreenBuffer", sort, props, winprops, GraphicsPipe.BFRefuseWindow, base.win.getGsg(), base.win )
def makeTextureBuffer(name, xSize, ySize, tex = None, toRam = False, fbp = None): """Copied from graphicsOutput.cxx and pythonified.""" if fbp == None: fbp = FrameBufferProperties() fbp.setRgbColor(1) fbp.setDepthBits(1) flags = GraphicsPipe.BFRefuseWindow; if hasattr(GraphicsPipe, "BFSizePower2") and Texture.getTexturesPower2() != ATSNone: flags |= GraphicsPipe.BFSizePower2 if tex != None and tex.getTextureType() == Texture.TTCubeMap: flags |= GraphicsPipe.BFSizeSquare buffer = WindowManager.gsg.getEngine().makeOutput(base.pipe, name, 0, fbp, WindowProperties.size(xSize, ySize), flags, WindowManager.gsg) if WindowManager.gsg == None: WindowManager.gsg = buffer.getGsg() if buffer != None: if toRam: buffer.addRenderTexture(tex, RTMCopyRam); else: buffer.addRenderTexture(tex, RTMBindOrCopy); return buffer return None
def __init__(self, scene_file, pedestrian_file, dir, mode): ShowBase.__init__(self) self.globalClock = ClockObject.getGlobalClock() self.globalClock.setMode(ClockObject.MSlave) self.directory = dir self.model = Model(dir) self.loadScene(scene_file) self.loadPedestrians(pedestrian_file) #self.cam_label = OST("Top Down", pos=(0, 0.95), fg=(1,1,1,1), # scale=0.05, mayChange=True) #self.time_label = OST("Time: 0.0", pos=(-1.3, 0.95), fg=(1,1,1,1), # scale=0.06, mayChange=True, align=TextNode.ALeft) #self.accept("arrow_right", self.changeCamera, [1]) #self.accept("arrow_left", self.changeCamera, [-1]) self.accept("escape", self.exit) self.accept("aspectRatioChanged", self.setAspectRatio) self.accept("window-event", self.windowChanged) new_window_fbp = FrameBufferProperties.getDefault() new_window_properties = WindowProperties.getDefault() self.new_window = base.graphicsEngine.makeOutput(base.pipe, 'Top Down View Window', 0, new_window_fbp, new_window_properties, GraphicsPipe.BFRequireWindow) self.new_window_display_region = self.new_window.makeDisplayRegion() #base.disableMouse() lens = OrthographicLens() lens.setFilmSize(1500, 1500) lens.setNearFar(-5000, 5000) self.default_camera = render.attachNewNode(Camera("top down")) self.default_camera.node().setLens(lens) #self.default_camera.setPosHpr(Vec3( -75, 0, 2200), Vec3(0, -90, 0)) self.default_camera.setPosHpr(Vec3(-75, 0, 0), Vec3(0, -90, 0)) #self.new_window = base.openWindow() self.display_regions = [] self.display_regions.append(self.new_window_display_region) self.display_regions.append(base.win.makeDisplayRegion(0, 0.32, 0.52, 1)) self.display_regions.append(base.win.makeDisplayRegion(0.34, 0.66, 0.52, 1)) self.display_regions.append(base.win.makeDisplayRegion(0.68, 1, 0.52, 1)) self.display_regions.append(base.win.makeDisplayRegion(0, 0.32, 0, 0.48)) self.display_regions.append(base.win.makeDisplayRegion(0.34, 0.66, 0, 0.48)) self.display_regions.append(base.win.makeDisplayRegion(0.68, 1, 0, 0.48)) self.display_regions[0].setCamera(self.default_camera) self.border_regions = [] self.border_regions.append(base.win.makeDisplayRegion(0.32, 0.34, 0.52, 1)) self.border_regions.append(base.win.makeDisplayRegion(0.66, 0.68, 0.52, 1)) self.border_regions.append(base.win.makeDisplayRegion(0, 1, 0.48, 0.52)) self.border_regions.append(base.win.makeDisplayRegion(0.32, 0.34, 0, 0.48)) self.border_regions.append(base.win.makeDisplayRegion(0.66, 0.68, 0, 0.48)) for i in range(0, len(self.border_regions)): border_region = self.border_regions[i] border_region.setClearColor(VBase4(0, 0, 0, 1)) border_region.setClearColorActive(True) border_region.setClearDepthActive(True) #self.setCamera(0) self.controller = Controller(self, mode) self.taskMgr.add(self.updateCameraModules, "Update Camera Modules", 80) self.globalClock.setFrameTime(0.0) self.width = WIDTH self.height = HEIGHT props = WindowProperties( ) props.setTitle( 'Virtual Vision Simulator' ) base.win.requestProperties( props ) """new_window_2d_display_region = self.new_window.makeDisplayRegion() new_window_2d_display_region.setSort(20) new_window_camera_2d = NodePath(Camera('2d camera of new window')) lens_2d = OrthographicLens() lens_2d.setFilmSize(2, 2) lens_2d.setNearFar(-1000, 1000) new_window_camera_2d.node().setLens(lens_2d) new_window_render_2d = NodePath('render2d of new window') new_window_render_2d.setDepthTest(False) new_window_render_2d.setDepthWrite(False) new_window_camera_2d.reparentTo(new_window_render_2d) new_window_2d_display_region.setCamera(new_window_camera_2d)""" """aspectRatio = base.getAspectRatio() self.new_window_aspect2d = new_window_render_2d.attachNewNode(PGTop('Aspect2d of new window')) self.new_window_aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0)""" render.analyze()
def __init__(self, _base): self._base = _base self._base.cam.node().setActive(0) # window properties self.winprops = WindowProperties.size(base.win.getXSize(),base.win.getYSize()) self.props = FrameBufferProperties() self.props.setDepthBits(1) self.props.setColorBits(1) self.props.setAlphaBits(1) # buffers creation self.geom_buffer = self.make_FBO("geom buffer",3) self.light_buffer = self.make_FBO("light buffer",0) self.transparency_buffer = self.make_FBO("transparency buffer",0) # cameras creation self.geom_cam = self._base.makeCamera(self.geom_buffer) self.light_cam = self._base.makeCamera(self.light_buffer) self.transparency_cam = self._base.makeCamera(self.transparency_buffer) # cameras setup self.geom_cam.node().getDisplayRegion(0).setClearColorActive(1) self.geom_cam.node().getDisplayRegion(0).setClearColor(Vec4(1,0,0,1)) self.geom_cam.node().getDisplayRegion(0).setClearDepthActive(1) self.light_cam.node().getDisplayRegion(0).setClearColorActive(1) self.geom_cam.node().getDisplayRegion(0).setClearColor(Vec4(0,1,0,1)) self.light_cam.node().getDisplayRegion(0).setClearDepthActive(1) self.transparency_cam.node().getDisplayRegion(0).setClearColorActive(1) self.transparency_cam.node().getDisplayRegion(0).setClearDepthActive(1) self.geom_cam.node().getLens().setNear(0.1) self.light_cam.node().getLens().setNear(0.1) self.transparency_cam.node().getLens().setNear(0.1) self.geom_cam.node().getLens().setFov(90) self.light_cam.node().getLens().setFov(90) self._base.cam.node().getLens().setFov(90) self.transparency_cam.node().getLens().setFov(90) # cameras masks self.geom_mask = BitMask32(1) self.light_mask = BitMask32(2) self.transparency_mask = BitMask32(4) self.light_cam.node().setCameraMask(self.light_mask) self.geom_cam.node().setCameraMask(self.geom_mask) self.transparency_cam.node().setCameraMask(self.transparency_mask) RENDER_NODES['LIGHTS'].hide(self.geom_mask) RENDER_NODES['GEOMS'].hide(self.light_mask) RENDER_NODES['TRANSPS'].hide(self.geom_mask) # link cameras self.geom_cam.node().setScene(RENDER_NODES['GEOMS']) self.light_cam.node().setScene(RENDER_NODES['LIGHTS']) self.transparency_cam.node().setScene(RENDER_NODES['TRANSPS']) # buffers rendering order self.light_buffer.setSort(0) self.geom_buffer.setSort(-50) self.transparency_buffer.setSort(50) self._base.win.setSort(-100) # shadows cube creation self.shadow_cube = RENDER_NODES['GEOMS'].attachNewNode("cubemap") self.shadow_cube.setPos(0, 0, 0) buffer_cube_shadow = self._base.win.makeCubeMap("cube 1", 512, self.shadow_cube, camera_mask = self.geom_mask, to_ram = False, fbp = self.props) self.shadow_cube_texture = buffer_cube_shadow.getTexture() cameras = [] for camera in self.shadow_cube.getChildren(): cameras.append(camera) camera.node().getLens().setFov(90) camera.node().getLens().setNearFar(0.1 ,10.0) camera.node().setCameraMask(self.geom_mask) cameraInit = NodePath(PandaNode("cube camera initiator")) cameraInit.setShader(Shader.load('shaders/point_lights_cube.sha')) cameraInit.setShaderInput("light2", self.shadow_cube) cameraInit.setShaderInput("lightCamera", camera) cameraInit.setShaderInput("lensFar", Vec4(camera.node().getLens().getFar())) cameraInit.setShaderInput("transparency", Vec4(1)) camera.node().setInitialState(cameraInit.getState()) # reflections cube creation self.reflection_cube = RENDER_NODES['GEOMS'].attachNewNode("cubemap pivot") self.buffer_reflection_cube = self._base.win.makeCubeMap("cube 2", 512, self.reflection_cube, camera_mask = self.geom_mask, to_ram = False, fbp = self.props) self.reflection_cube_texture = self.buffer_reflection_cube.getTexture() for camera in self.reflection_cube.getChildren(): camera.node().getLens().setNearFar(0.1 ,500.0) # shader rendering normal maps normal_shader = ShaderAttrib.make() normal_shader = normal_shader.setShader(Shader.load(CG_NORMALMAP)) # shader rendering light light_shader = ShaderAttrib.make() light_shader = light_shader.setShader(Shader.load(CG_LIGHT)) # link states with cameras self.geom_cam.node().setTagStateKey(SHADER_TAGS['g-buffer']) self.geom_cam.node().setTagState("True", RenderState.make(normal_shader)) self.light_cam.node().setTagStateKey(SHADER_TAGS['compute light']) self.light_cam.node().setTagState("True", RenderState.make(light_shader)) # render textures creation self.albedo_map = Texture() self.normal_map = Texture() self.depth_map = Texture() self.specular_map = Texture() self.misc_map = Texture() self.light_map = Texture() self.transparency_map = Texture() self.transparency_depth_map = Texture() # render textures self.transparency_buffer.addRenderTexture(self.transparency_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) self.transparency_buffer.addRenderTexture(self.transparency_depth_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) self.geom_buffer.addRenderTexture(self.normal_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) self.geom_buffer.addRenderTexture(self.depth_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) self.geom_buffer.addRenderTexture(self.albedo_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0) self.geom_buffer.addRenderTexture(self.specular_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1) self.geom_buffer.addRenderTexture(self.misc_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba2) self.light_buffer.addRenderTexture(self.light_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) taskMgr.add(self.update,'update reflections cubemap')
class BufferSystem(): def __init__(self, _base): self._base = _base self._base.cam.node().setActive(0) # window properties self.winprops = WindowProperties.size(base.win.getXSize(),base.win.getYSize()) self.props = FrameBufferProperties() self.props.setDepthBits(1) self.props.setColorBits(1) self.props.setAlphaBits(1) # buffers creation self.geom_buffer = self.make_FBO("geom buffer",3) self.light_buffer = self.make_FBO("light buffer",0) self.transparency_buffer = self.make_FBO("transparency buffer",0) # cameras creation self.geom_cam = self._base.makeCamera(self.geom_buffer) self.light_cam = self._base.makeCamera(self.light_buffer) self.transparency_cam = self._base.makeCamera(self.transparency_buffer) # cameras setup self.geom_cam.node().getDisplayRegion(0).setClearColorActive(1) self.geom_cam.node().getDisplayRegion(0).setClearColor(Vec4(1,0,0,1)) self.geom_cam.node().getDisplayRegion(0).setClearDepthActive(1) self.light_cam.node().getDisplayRegion(0).setClearColorActive(1) self.geom_cam.node().getDisplayRegion(0).setClearColor(Vec4(0,1,0,1)) self.light_cam.node().getDisplayRegion(0).setClearDepthActive(1) self.transparency_cam.node().getDisplayRegion(0).setClearColorActive(1) self.transparency_cam.node().getDisplayRegion(0).setClearDepthActive(1) self.geom_cam.node().getLens().setNear(0.1) self.light_cam.node().getLens().setNear(0.1) self.transparency_cam.node().getLens().setNear(0.1) self.geom_cam.node().getLens().setFov(90) self.light_cam.node().getLens().setFov(90) self._base.cam.node().getLens().setFov(90) self.transparency_cam.node().getLens().setFov(90) # cameras masks self.geom_mask = BitMask32(1) self.light_mask = BitMask32(2) self.transparency_mask = BitMask32(4) self.light_cam.node().setCameraMask(self.light_mask) self.geom_cam.node().setCameraMask(self.geom_mask) self.transparency_cam.node().setCameraMask(self.transparency_mask) RENDER_NODES['LIGHTS'].hide(self.geom_mask) RENDER_NODES['GEOMS'].hide(self.light_mask) RENDER_NODES['TRANSPS'].hide(self.geom_mask) # link cameras self.geom_cam.node().setScene(RENDER_NODES['GEOMS']) self.light_cam.node().setScene(RENDER_NODES['LIGHTS']) self.transparency_cam.node().setScene(RENDER_NODES['TRANSPS']) # buffers rendering order self.light_buffer.setSort(0) self.geom_buffer.setSort(-50) self.transparency_buffer.setSort(50) self._base.win.setSort(-100) # shadows cube creation self.shadow_cube = RENDER_NODES['GEOMS'].attachNewNode("cubemap") self.shadow_cube.setPos(0, 0, 0) buffer_cube_shadow = self._base.win.makeCubeMap("cube 1", 512, self.shadow_cube, camera_mask = self.geom_mask, to_ram = False, fbp = self.props) self.shadow_cube_texture = buffer_cube_shadow.getTexture() cameras = [] for camera in self.shadow_cube.getChildren(): cameras.append(camera) camera.node().getLens().setFov(90) camera.node().getLens().setNearFar(0.1 ,10.0) camera.node().setCameraMask(self.geom_mask) cameraInit = NodePath(PandaNode("cube camera initiator")) cameraInit.setShader(Shader.load('shaders/point_lights_cube.sha')) cameraInit.setShaderInput("light2", self.shadow_cube) cameraInit.setShaderInput("lightCamera", camera) cameraInit.setShaderInput("lensFar", Vec4(camera.node().getLens().getFar())) cameraInit.setShaderInput("transparency", Vec4(1)) camera.node().setInitialState(cameraInit.getState()) # reflections cube creation self.reflection_cube = RENDER_NODES['GEOMS'].attachNewNode("cubemap pivot") self.buffer_reflection_cube = self._base.win.makeCubeMap("cube 2", 512, self.reflection_cube, camera_mask = self.geom_mask, to_ram = False, fbp = self.props) self.reflection_cube_texture = self.buffer_reflection_cube.getTexture() for camera in self.reflection_cube.getChildren(): camera.node().getLens().setNearFar(0.1 ,500.0) # shader rendering normal maps normal_shader = ShaderAttrib.make() normal_shader = normal_shader.setShader(Shader.load(CG_NORMALMAP)) # shader rendering light light_shader = ShaderAttrib.make() light_shader = light_shader.setShader(Shader.load(CG_LIGHT)) # link states with cameras self.geom_cam.node().setTagStateKey(SHADER_TAGS['g-buffer']) self.geom_cam.node().setTagState("True", RenderState.make(normal_shader)) self.light_cam.node().setTagStateKey(SHADER_TAGS['compute light']) self.light_cam.node().setTagState("True", RenderState.make(light_shader)) # render textures creation self.albedo_map = Texture() self.normal_map = Texture() self.depth_map = Texture() self.specular_map = Texture() self.misc_map = Texture() self.light_map = Texture() self.transparency_map = Texture() self.transparency_depth_map = Texture() # render textures self.transparency_buffer.addRenderTexture(self.transparency_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) self.transparency_buffer.addRenderTexture(self.transparency_depth_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) self.geom_buffer.addRenderTexture(self.normal_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) self.geom_buffer.addRenderTexture(self.depth_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepth) self.geom_buffer.addRenderTexture(self.albedo_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba0) self.geom_buffer.addRenderTexture(self.specular_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba1) self.geom_buffer.addRenderTexture(self.misc_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPAuxRgba2) self.light_buffer.addRenderTexture(self.light_map, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPColor) taskMgr.add(self.update,'update reflections cubemap') ## TODO move this to renderer class def render(self): RENDER_NODES['GEOMS'].setTag(SHADER_TAGS['g-buffer'], "True") RENDER_NODES['GEOMS'].setShaderInput("modifier",Vec3(0,0,0)) RENDER_NODES['GEOMS'].setShaderInput('camera', base.camera) RENDER_NODES['GEOMS'].setShaderInput("light", BUFFER_SYSTEM['main'].shadow_cube) RENDER_NODES['GEOMS'].setShaderInput("light2", BUFFER_SYSTEM['main'].shadow_cube) RENDER_NODES['GEOMS'].setShaderInput("projDepthmap", BUFFER_SYSTEM['main'].shadow_cube_texture) RENDER_NODES['GEOMS'].setShaderInput("textureDims", Vec4(32)) RENDER_NODES['GEOMS'].setShaderInput("smoothSamples", Vec4(1)) RENDER_NODES['GEOMS'].setShaderInput("lensFar", Vec4(10)) RENDER_NODES['GEOMS'].setShaderInput("lensNear", Vec4(0.01)) RENDER_NODES['GEOMS'].setShaderInput("penumbra", 0.00003) RENDER_NODES['GEOMS'].setShaderInput("depthOffset", 0.1) RENDER_NODES['GEOMS'].setShaderInput("a", BUFFER_SYSTEM['main'].shadow_cube) def update(self,task): #self.reflection_cube.setPos(self._base.camera.getPos()) #self.reflection_cube.setHpr(self._base.camera.getHpr()) return task.cont def make_FBO(self, name, auxrgba): self.props.setAuxRgba(auxrgba) return base.graphicsEngine.makeOutput( self._base.pipe, name, 0, self.props, self.winprops, GraphicsPipe.BFRefuseWindow, self._base.win.getGsg(), self._base.win)
def __init__(self, scene_file, pedestrian_file, dir, mode): ShowBase.__init__(self) self.globalClock = ClockObject.getGlobalClock() self.globalClock.setMode(ClockObject.MSlave) self.directory = dir self.model = Model(dir) self.loadScene(scene_file) self.loadPedestrians(pedestrian_file) #self.cam_label = OST("Top Down", pos=(0, 0.95), fg=(1,1,1,1), # scale=0.05, mayChange=True) #self.time_label = OST("Time: 0.0", pos=(-1.3, 0.95), fg=(1,1,1,1), # scale=0.06, mayChange=True, align=TextNode.ALeft) #self.accept("arrow_right", self.changeCamera, [1]) #self.accept("arrow_left", self.changeCamera, [-1]) self.accept("escape", self.exit) self.accept("aspectRatioChanged", self.setAspectRatio) self.accept("window-event", self.windowChanged) new_window_fbp = FrameBufferProperties.getDefault() new_window_properties = WindowProperties.getDefault() self.new_window = base.graphicsEngine.makeOutput( base.pipe, 'Top Down View Window', 0, new_window_fbp, new_window_properties, GraphicsPipe.BFRequireWindow) self.new_window_display_region = self.new_window.makeDisplayRegion() #base.disableMouse() lens = OrthographicLens() lens.setFilmSize(1500, 1500) lens.setNearFar(-5000, 5000) self.default_camera = render.attachNewNode(Camera("top down")) self.default_camera.node().setLens(lens) #self.default_camera.setPosHpr(Vec3( -75, 0, 2200), Vec3(0, -90, 0)) self.default_camera.setPosHpr(Vec3(-75, 0, 0), Vec3(0, -90, 0)) #self.new_window = base.openWindow() self.display_regions = [] self.display_regions.append(self.new_window_display_region) self.display_regions.append( base.win.makeDisplayRegion(0, 0.32, 0.52, 1)) self.display_regions.append( base.win.makeDisplayRegion(0.34, 0.66, 0.52, 1)) self.display_regions.append( base.win.makeDisplayRegion(0.68, 1, 0.52, 1)) self.display_regions.append( base.win.makeDisplayRegion(0, 0.32, 0, 0.48)) self.display_regions.append( base.win.makeDisplayRegion(0.34, 0.66, 0, 0.48)) self.display_regions.append( base.win.makeDisplayRegion(0.68, 1, 0, 0.48)) self.display_regions[0].setCamera(self.default_camera) self.border_regions = [] self.border_regions.append( base.win.makeDisplayRegion(0.32, 0.34, 0.52, 1)) self.border_regions.append( base.win.makeDisplayRegion(0.66, 0.68, 0.52, 1)) self.border_regions.append(base.win.makeDisplayRegion( 0, 1, 0.48, 0.52)) self.border_regions.append( base.win.makeDisplayRegion(0.32, 0.34, 0, 0.48)) self.border_regions.append( base.win.makeDisplayRegion(0.66, 0.68, 0, 0.48)) for i in range(0, len(self.border_regions)): border_region = self.border_regions[i] border_region.setClearColor(VBase4(0, 0, 0, 1)) border_region.setClearColorActive(True) border_region.setClearDepthActive(True) #self.setCamera(0) self.controller = Controller(self, mode) self.taskMgr.add(self.updateCameraModules, "Update Camera Modules", 80) self.globalClock.setFrameTime(0.0) self.width = WIDTH self.height = HEIGHT props = WindowProperties() props.setTitle('Virtual Vision Simulator') base.win.requestProperties(props) """new_window_2d_display_region = self.new_window.makeDisplayRegion() new_window_2d_display_region.setSort(20) new_window_camera_2d = NodePath(Camera('2d camera of new window')) lens_2d = OrthographicLens() lens_2d.setFilmSize(2, 2) lens_2d.setNearFar(-1000, 1000) new_window_camera_2d.node().setLens(lens_2d) new_window_render_2d = NodePath('render2d of new window') new_window_render_2d.setDepthTest(False) new_window_render_2d.setDepthWrite(False) new_window_camera_2d.reparentTo(new_window_render_2d) new_window_2d_display_region.setCamera(new_window_camera_2d)""" """aspectRatio = base.getAspectRatio() self.new_window_aspect2d = new_window_render_2d.attachNewNode(PGTop('Aspect2d of new window')) self.new_window_aspect2d.setScale(1.0 / aspectRatio, 1.0, 1.0)""" render.analyze()