def setup_root(self): """Set up the scene graph.""" self.root = NodePath("root") self.root.setAttrib(RescaleNormalAttrib.makeDefault()) self.root.setTwoSided(False) self.backface_culling_enabled = True self.texture_enabled = True self.wireframe = False
def __init__(self, scene, size=(512, 512), shadowing=False, mode='offscreen', zNear=0.1, zFar=1000.0, fov=40.0, depth=True, modelLightsInfo=None, cameraTransform=None): # Off-screen buffers are not supported in OSX if sys.platform == 'darwin': mode = 'onscreen' super(Panda3dRenderer, self).__init__() self.__dict__.update(scene=scene, size=size, mode=mode, zNear=zNear, zFar=zFar, fov=fov, depth=depth, shadowing=shadowing, modelLightsInfo=modelLightsInfo, cameraTransform=cameraTransform) self.cameraMask = BitMask32.bit(0) self.graphicsEngine = GraphicsEngine.getGlobalPtr() self.loader = Loader.getGlobalPtr() self.graphicsEngine.setDefaultLoader(self.loader) # Change some scene attributes for rendering self.scene.scene.setAttrib(RescaleNormalAttrib.makeDefault()) self.scene.scene.setTwoSided(0) self._initModels() selection = GraphicsPipeSelection.getGlobalPtr() self.pipe = selection.makeDefaultPipe() logger.debug('Using %s' % (self.pipe.getInterfaceName())) # Attach a camera to every agent in the scene self.cameras = [] for agentNp in self.scene.scene.findAllMatches('**/agents/agent*'): camera = agentNp.attachNewNode(ModelNode('camera-rgbd')) if self.cameraTransform is not None: camera.setTransform(cameraTransform) camera.node().setPreserveTransform(ModelNode.PTLocal) self.cameras.append(camera) self.rgbBuffers = dict() self.rgbTextures = dict() self.depthBuffers = dict() self.depthTextures = dict() self._initRgbCapture() if self.depth: self._initDepthCapture() self._addDefaultLighting() self.scene.worlds['render'] = self
def setupRender(self): """ Creates the render scene graph, the primary scene graph for rendering 3-d geometry. """ ## This is the root of the 3-D scene graph. ## Make it a BSPRender node to automatically cull ## nodes against the BSP leafs if there is a loaded ## BSP level. self.render = NodePath(BSPRender('render', BSPLoader.getGlobalPtr())) self.render.setAttrib(RescaleNormalAttrib.makeDefault()) self.render.setTwoSided(0) self.backfaceCullingEnabled = 1 self.textureEnabled = 1 self.wireframeEnabled = 0
def __init__(self, frame_size=None, force_hardware=True, MSAA_samples=0, CSAA_samples=0, sRGB_color=False): """Renderer based on Panda3D Keyword Arguments: frame_size {tuple} -- frame size (default: {256, 256}) force_hardware {bool} -- force hardware rendering (default: {True}) MSAA_samples {int} -- MSAA (Multi-Sampling Anti-Aliasing) level (default: {0}) CSAA_samples {int} -- CSAA (Coverage Sampling Antialiasing) level (default: {0}) sRGB_color {bool} -- apply sRGB colorspace gamma correction (default: {False}) """ BaseRenderer.__init__(self) self.return_to_bullet = True # renderer loadPrcFileData( "", f""" gl-compile-and-execute 1 gl-use-bindless-texture 1 prefer-texture-buffer 1 """) fbp = FrameBufferProperties(FrameBufferProperties.getDefault()) fbp.set_force_hardware(force_hardware) fbp.set_force_software(not force_hardware) fbp.set_multisamples(MSAA_samples) fbp.set_coverage_samples(CSAA_samples) fbp.set_srgb_color(sRGB_color) self._renderer = OffscreenRenderer(frame_size, fbp) self._loader = Loader.Loader(None) # scene self.scene = NodePath('render') self.scene.setAttrib(RescaleNormalAttrib.makeDefault()) self.scene.setTwoSided(False) self.scene.setAntialias(AntialiasAttrib.MAuto) self.scene.setShaderAuto() self._light = PbLightNode(self.scene) self._camera = PbCameraNode(self.scene) self._node_dict = {}
from AIBase import AIBase from direct.directnotify.DirectNotifyGlobal import directNotify from panda3d.core import RescaleNormalAttrib, NodePath, Notify __builtins__['base'] = AIBase() __builtins__['ostream'] = Notify.out() __builtins__['run'] = base.run __builtins__['taskMgr'] = base.taskMgr __builtins__['jobMgr'] = base.jobMgr __builtins__['eventMgr'] = base.eventMgr __builtins__['messenger'] = base.messenger __builtins__['bboard'] = base.bboard __builtins__['config'] = base.config __builtins__['directNotify'] = directNotify render = NodePath('render') render.setAttrib(RescaleNormalAttrib.makeDefault()) render.setTwoSided(0) __builtins__['render'] = render from direct.showbase import Loader base.loader = Loader.Loader(base) __builtins__['loader'] = base.loader directNotify.setDconfigLevels() def inspect(anObject): from direct.tkpanels import Inspector Inspector.inspect(anObject) __builtins__['inspect'] = inspect taskMgr.finalInit()