def __init__(self, lane, position, heading, random_seed): super(TollGateBuilding, self).__init__(lane, position, heading, random_seed) air_wall = generate_invisible_static_wall( self.BUILDING_LENGTH, lane.width, self.BUILDING_HEIGHT / 2, object_id=self.id ) self.add_body(air_wall) self.origin.setPos(panda_position(position)) self.origin.setH(panda_heading(heading)) if self.render: building_model = self.loader.loadModel(AssetLoader.file_path("models", "tollgate", "booth.gltf")) gate_model = self.loader.loadModel(AssetLoader.file_path("models", "tollgate", "gate.gltf")) building_model.setH(90) building_model.reparentTo(self.origin) gate_model.reparentTo(self.origin)
def _add_visualization(self): if self.render: [path, scale, x_y_z_offset, H] = self.path[self.np_random.randint(0, len(self.path))] if path not in BaseVehicle.model_collection: car_model = self.loader.loadModel( AssetLoader.file_path("models", path)) BaseVehicle.model_collection[path] = car_model else: car_model = BaseVehicle.model_collection[path] car_model.setScale(scale) car_model.setH(H) car_model.setPos(x_y_z_offset) car_model.setZ(-self.TIRE_RADIUS - self.CHASSIS_TO_WHEEL_AXIS + x_y_z_offset[-1]) car_model.instanceTo(self.origin) if self.config["random_color"]: material = Material() material.setBaseColor( (self.panda_color[0] * self.MATERIAL_COLOR_COEFF, self.panda_color[1] * self.MATERIAL_COLOR_COEFF, self.panda_color[2] * self.MATERIAL_COLOR_COEFF, 0.2)) material.setMetallic(self.MATERIAL_METAL_COEFF) material.setSpecular(self.MATERIAL_SPECULAR_COLOR) material.setRefractiveIndex(1.5) material.setRoughness(self.MATERIAL_ROUGHNESS) material.setShininess(self.MATERIAL_SHININESS) material.setTwoside(False) self.origin.setMaterial(material, True)
def __init__(self, name=None, random_seed=None, config=None, escape_random_seed_assertion=False): """ Config is a static conception, which specified the parameters of one element. There parameters doesn't change, such as length of straight road, max speed of one vehicle, etc. """ super(BaseObject, self).__init__(name, random_seed, config) if not escape_random_seed_assertion: assert random_seed is not None, "Please assign a random seed for {} class.".format( self.class_name) # Following properties are available when this object needs visualization and physics property self._body = None # each element has its node_path to render, physics node are child nodes of it self.origin = NodePath(self.name) # Temporally store bullet nodes that have to place in bullet world (not NodePath) self.dynamic_nodes = PhysicsNodeList() # Nodes in this tuple didn't interact with other nodes! they only used to do rayTest or sweepTest self.static_nodes = PhysicsNodeList() # render or not self.render = False if AssetLoader.loader is None else True if self.render: self.loader = AssetLoader.get_loader() if not hasattr(self.loader, "loader"): # It is closed before! self.loader.__init__()
def __init__(self, block_index: int, global_network: RoadNetwork, random_seed, ignore_intersection_checking=False): super(BaseBlock, self).__init__(str(block_index) + self.ID, random_seed, escape_random_seed_assertion=True) # block information assert self.ID is not None, "Each Block must has its unique ID When define Block" assert len(self.ID) == 1, "Block ID must be a character " self.block_index = block_index self.ignore_intersection_checking = ignore_intersection_checking # each block contains its own road network and a global network self._global_network = global_network self.block_network = RoadNetwork() # a bounding box used to improve efficiency x_min, x_max, y_min, y_max self.bounding_box = None # used to spawn npc self._respawn_roads = [] self._block_objects = None if self.render: # render pre-load self.road_texture = self.loader.loadTexture( AssetLoader.file_path("textures", "sci", "color.jpg")) self.road_texture.setMinfilter( SamplerState.FT_linear_mipmap_linear) self.road_texture.setAnisotropicDegree(8) self.road_normal = self.loader.loadTexture( AssetLoader.file_path("textures", "sci", "normal.jpg")) self.ts_color = TextureStage("color") self.ts_normal = TextureStage("normal") self.side_texture = self.loader.loadTexture( AssetLoader.file_path("textures", "sidewalk", "color.png")) self.side_texture.setMinfilter( SamplerState.FT_linear_mipmap_linear) self.side_texture.setAnisotropicDegree(8) self.side_normal = self.loader.loadTexture( AssetLoader.file_path("textures", "sidewalk", "normal.png")) self.sidewalk = self.loader.loadModel( AssetLoader.file_path("models", "box.bam"))
def _load_shader_str(shaderpath, defines=None): shader_dir = AssetLoader.file_path("shaders", "pbr_shaders", shaderpath) with open(shader_dir) as shaderfile: shaderstr = shaderfile.read() if defines is not None: shaderstr = _add_shader_defines(shaderstr, defines) return shaderstr
def __init__(self): assert engine_initialized( ), "You should initialize engine before adding camera to vehicle" config = get_global_config()["vehicle_config"]["depth_camera"] self.BUFFER_W, self.BUFFER_H = config[0], config[1] self.VIEW_GROUND = config[2] super(DepthCamera, self).__init__() cam = self.get_cam() lens = self.get_lens() cam.lookAt(0, 2.4, 1.3) lens.setFov(60) lens.setAspectRatio(2.0) if get_engine( ).mode == RENDER_MODE_NONE or not AssetLoader.initialized(): return # add shader for it if get_global_config()["headless_machine_render"]: vert_path = AssetLoader.file_path("shaders", "depth_cam_gles.vert.glsl") frag_path = AssetLoader.file_path("shaders", "depth_cam_gles.frag.glsl") else: from pgdrive.utils import is_mac if is_mac(): vert_path = AssetLoader.file_path("shaders", "depth_cam_mac.vert.glsl") frag_path = AssetLoader.file_path("shaders", "depth_cam_mac.frag.glsl") else: vert_path = AssetLoader.file_path("shaders", "depth_cam.vert.glsl") frag_path = AssetLoader.file_path("shaders", "depth_cam.frag.glsl") custom_shader = Shader.load(Shader.SL_GLSL, vertex=vert_path, fragment=frag_path) cam.node().setInitialState( RenderState.make(ShaderAttrib.make(custom_shader, 1))) if self.VIEW_GROUND: self.GROUND = GeoMipTerrain("mySimpleTerrain") self.GROUND.setHeightfield( AssetLoader.file_path("textures", "height_map.png")) # terrain.setBruteforce(True) # # Since the terrain is a texture, shader will not calculate the depth information, we add a moving terrain # # model to enable the depth information of terrain self.GROUND_MODEL = self.GROUND.getRoot() self.GROUND_MODEL.setPos(-128, 0, self.GROUND_HEIGHT) self.GROUND_MODEL.hide(CamMask.AllOn) self.GROUND_MODEL.show(CamMask.DepthCam) self.GROUND.generate()
def _add_lane_line2bullet(self, lane_start, lane_end, middle, parent_np: NodePath, color: Vec4, line_type: LineType, straight_stripe=False): length = norm(lane_end[0] - lane_start[0], lane_end[1] - lane_start[1]) if length <= 0: return if LineType.prohibit(line_type): node_name = BodyName.White_continuous_line if color == LineColor.GREY else BodyName.Yellow_continuous_line else: node_name = BodyName.Broken_line # add bullet body for it if straight_stripe: body_np = parent_np.attachNewNode(node_name) else: body_node = BulletGhostNode(node_name) body_node.set_active(False) body_node.setKinematic(False) body_node.setStatic(True) body_np = parent_np.attachNewNode(body_node) # its scale will change by setScale body_height = DrivableAreaProperty.LANE_LINE_GHOST_HEIGHT shape = BulletBoxShape( Vec3(length / 2 if line_type != LineType.BROKEN else length, DrivableAreaProperty.LANE_LINE_WIDTH / 2, body_height)) body_np.node().addShape(shape) mask = DrivableAreaProperty.CONTINUOUS_COLLISION_MASK if line_type != LineType.BROKEN else DrivableAreaProperty.BROKEN_COLLISION_MASK body_np.node().setIntoCollideMask(mask) self.static_nodes.append(body_np.node()) # position and heading body_np.setPos( panda_position(middle, DrivableAreaProperty.LANE_LINE_GHOST_HEIGHT / 2)) direction_v = lane_end - lane_start # theta = -numpy.arctan2(direction_v[1], direction_v[0]) theta = -math.atan2(direction_v[1], direction_v[0]) body_np.setQuat( LQuaternionf(math.cos(theta / 2), 0, 0, math.sin(theta / 2))) if self.render: # For visualization lane_line = self.loader.loadModel( AssetLoader.file_path("models", "box.bam")) lane_line.setScale(length, DrivableAreaProperty.LANE_LINE_WIDTH, DrivableAreaProperty.LANE_LINE_THICKNESS) lane_line.setPos( Vec3(0, 0 - DrivableAreaProperty.LANE_LINE_GHOST_HEIGHT / 2)) lane_line.reparentTo(body_np) body_np.set_color(color)
def test_asset_loader(): default_config = PGDriveEnv.default_config() world = EngineCore(global_config=default_config) try: world.clear_world() initialize_asset_loader(world) print(AssetLoader.asset_path) print(AssetLoader.file_path("aaa")) # print(AssetLoader.get_loader()) finally: world.close_world()
def __init__(self, lane, longitude: float, lateral: float, static: bool = False, random_seed=None): super(TrafficCone, self).__init__(lane, longitude, lateral, random_seed) self.add_body(BaseRigidBodyNode(self.name, self.NAME)) self.body.addShape(BulletCylinderShape(self.RADIUS, self.HEIGHT)) self.body.setIntoCollideMask(self.COLLISION_GROUP) self.origin.setPos(panda_position(self.position, self.HEIGHT / 2)) self.origin.setH(panda_heading(self.heading)) if self.render: model = self.loader.loadModel( AssetLoader.file_path("models", "traffic_cone", "scene.gltf")) model.setScale(0.02) model.setPos(0, 0, -self.HEIGHT / 2) model.reparentTo(self.origin) self.set_static(static)
def __init__(self, lane, longitude: float, lateral: float, static: bool = False, random_seed=None): super(TrafficBarrier, self).__init__(lane, longitude, lateral, random_seed) self.add_body(BaseRigidBodyNode(self.name, self.NAME)) self.body.addShape( BulletBoxShape((self.WIDTH / 2, self.LENGTH / 2, self.HEIGHT / 2))) self.body.setIntoCollideMask(self.COLLISION_GROUP) self.origin.setPos(panda_position(self.position, self.HEIGHT / 2)) self.origin.setH(panda_heading(self.heading)) if self.render: model = self.loader.loadModel( AssetLoader.file_path("models", "barrier", "scene.gltf")) model.setH(-90) model.reparentTo(self.origin) self.set_static(static)
def __init__(self): super(Terrain, self).__init__(random_seed=0) shape = BulletPlaneShape(Vec3(0, 0, 1), 0) node = BulletRigidBodyNode(BodyName.Ground) node.setFriction(.9) node.addShape(shape) node.setIntoCollideMask(self.COLLISION_MASK) self.dynamic_nodes.append(node) self.origin.attachNewNode(node) if self.render: self.origin.hide(CamMask.MiniMap | CamMask.Shadow | CamMask.DepthCam | CamMask.ScreenshotCam) # self.terrain_normal = self.loader.loadTexture( # AssetLoader.file_path( "textures", "grass2", "normal.jpg") # ) self.terrain_texture = self.loader.loadTexture( AssetLoader.file_path("textures", "ground.png")) self.terrain_texture.setWrapU(Texture.WM_repeat) self.terrain_texture.setWrapV(Texture.WM_repeat) self.ts_color = TextureStage("color") self.ts_normal = TextureStage("normal") self.ts_normal.set_mode(TextureStage.M_normal) self.origin.setPos(0, 0, self.HEIGHT) cm = CardMaker('card') scale = 20000 cm.setUvRange((0, 0), (scale / 10, scale / 10)) card = self.origin.attachNewNode(cm.generate()) # scale = 1 if self.use_hollow else 20000 card.set_scale(scale) card.setPos(-scale / 2, -scale / 2, -0.1) card.setZ(-.05) card.setTexture(self.ts_color, self.terrain_texture) # card.setTexture(self.ts_normal, self.terrain_normal) self.terrain_texture.setMinfilter( SamplerState.FT_linear_mipmap_linear) self.terrain_texture.setAnisotropicDegree(8) card.setQuat( LQuaternionf(math.cos(-math.pi / 4), math.sin(-math.pi / 4), 0, 0))
def __init__(self, num_lasers: int = 16, distance: float = 50, enable_show=True): # properties self.available = True if num_lasers > 0 and distance > 0 else False parent_node_np: NodePath = get_engine().render self.origin = parent_node_np.attachNewNode("Could_points") show = enable_show and (AssetLoader.loader is not None) self.dim = num_lasers self.num_lasers = num_lasers self.perceive_distance = distance self.height = self.DEFAULT_HEIGHT self.radian_unit = 2 * np.pi / num_lasers if self.num_lasers > 0 else None self.start_phase_offset = 0 self._lidar_range = np.arange( 0, self.num_lasers) * self.radian_unit + self.start_phase_offset # override these properties to decide which elements to detect and show self.origin.hide(CamMask.RgbCam | CamMask.Shadow | CamMask.Shadow | CamMask.DepthCam) self.mask = CollisionGroup.BrokenLaneLine self.cloud_points_vis = [] if show else None logging.debug("Load Vehicle Module: {}".format( self.__class__.__name__)) if show: for laser_debug in range(self.num_lasers): ball = AssetLoader.loader.loadModel( AssetLoader.file_path("models", "box.bam")) ball.setScale(0.001) ball.setColor(0., 0.5, 0.5, 1) shape = BulletSphereShape(0.1) ghost = BulletGhostNode('Lidar Point') ghost.setIntoCollideMask(CollisionGroup.AllOff) ghost.addShape(shape) laser_np = self.origin.attachNewNode(ghost) self.cloud_points_vis.append(laser_np) ball.getChildren().reparentTo(laser_np)
def _add_wheel(self, pos: Vec3, radius: float, front: bool, left): wheel_np = self.origin.attachNewNode("wheel") if self.render: # TODO something wrong with the wheel render model_path = 'models/yugo/yugotireR.egg' if left else 'models/yugo/yugotireL.egg' wheel_model = self.loader.loadModel( AssetLoader.file_path(model_path)) wheel_model.reparentTo(wheel_np) wheel_model.set_scale(1.4, radius / 0.25, radius / 0.25) wheel = self.system.create_wheel() wheel.setNode(wheel_np.node()) wheel.setChassisConnectionPointCs(pos) wheel.setFrontWheel(front) wheel.setWheelDirectionCs(Vec3(0, 0, -1)) wheel.setWheelAxleCs(Vec3(1, 0, 0)) wheel.setWheelRadius(radius) wheel.setMaxSuspensionTravelCm(self.SUSPENSION_LENGTH) wheel.setSuspensionStiffness(self.SUSPENSION_STIFFNESS) wheel.setWheelsDampingRelaxation(4.8) wheel.setWheelsDampingCompression(1.2) wheel.setFrictionSlip(self.config["wheel_friction"]) wheel.setRollInfluence(0.5) return wheel
def __init__(self, pure_background: bool = False): super(SkyBox, self).__init__(random_seed=0) self._accumulate = 0 self.f = 1 if not self.render or pure_background: return skybox = self.loader.loadModel(AssetLoader.file_path("models", "skybox.bam")) skybox.hide(CamMask.MiniMap | CamMask.RgbCam | CamMask.Shadow | CamMask.ScreenshotCam) skybox.set_scale(20000) skybox_texture = self.loader.loadTexture(AssetLoader.file_path("textures", "skybox.jpg")) skybox_texture.set_minfilter(SamplerState.FT_linear) skybox_texture.set_magfilter(SamplerState.FT_linear) skybox_texture.set_wrap_u(SamplerState.WM_repeat) skybox_texture.set_wrap_v(SamplerState.WM_mirror) skybox_texture.set_anisotropic_degree(16) skybox.set_texture(skybox_texture) gles = ConfigVariableString("load-display").getValue() if gles == "pandagles2": skybox_shader = Shader.load( Shader.SL_GLSL, AssetLoader.file_path("shaders", "skybox_gles.vert.glsl"), AssetLoader.file_path("shaders", "skybox_gles.frag.glsl") ) else: if is_mac(): vert_file = "skybox_mac.vert.glsl" frag_file = "skybox_mac.frag.glsl" else: vert_file = "skybox.vert.glsl" frag_file = "skybox.frag.glsl" skybox_shader = Shader.load( Shader.SL_GLSL, AssetLoader.file_path("shaders", vert_file), AssetLoader.file_path("shaders", frag_file) ) skybox.set_shader(skybox_shader) skybox.reparentTo(self.origin) skybox.setZ(-4400) skybox.setH(30)
def __init__(self, engine, show_navi_mark: bool = False, random_navi_mark_color=False, show_dest_mark=False, show_line_to_dest=False): """ This class define a helper for localizing vehicles and retrieving navigation information. It now only support from first block start to the end node, but can be extended easily. """ self.map = None self.final_road = None self.final_lane = None self.checkpoints = None self.current_ref_lanes = None self.next_ref_lanes = None self.current_road = None self.next_road = None self._target_checkpoints_index = None self._navi_info = np.zeros( (self.navigation_info_dim, )) # navi information res # Vis self._show_navi_info = ( engine.mode == RENDER_MODE_ONSCREEN and not engine.global_config["debug_physics_world"]) self.origin = engine.render.attachNewNode( "navigation_sign") if self._show_navi_info else None self.navi_mark_color = ( 0.6, 0.8, 0.5) if not random_navi_mark_color else get_np_random().rand(3) self.navi_arrow_dir = None self._dest_node_path = None self._goal_node_path = None self._line_to_dest = None self._show_line_to_dest = show_line_to_dest if self._show_navi_info: # nodepath self._line_to_dest = self.origin.attachNewNode("line") self._goal_node_path = self.origin.attachNewNode("target") self._dest_node_path = self.origin.attachNewNode("dest") if show_navi_mark: navi_point_model = AssetLoader.loader.loadModel( AssetLoader.file_path("models", "box.bam")) navi_point_model.reparentTo(self._goal_node_path) if show_dest_mark: dest_point_model = AssetLoader.loader.loadModel( AssetLoader.file_path("models", "box.bam")) dest_point_model.reparentTo(self._dest_node_path) if show_line_to_dest: line_seg = LineSegs("line_to_dest") line_seg.setColor(self.navi_mark_color[0], self.navi_mark_color[1], self.navi_mark_color[2], 0.7) line_seg.setThickness(2) self._dynamic_line_np = NodePath(line_seg.create(True)) self._dynamic_line_np.reparentTo(self.origin) self._line_to_dest = line_seg self._goal_node_path.setTransparency(TransparencyAttrib.M_alpha) self._dest_node_path.setTransparency(TransparencyAttrib.M_alpha) self._goal_node_path.setColor(self.navi_mark_color[0], self.navi_mark_color[1], self.navi_mark_color[2], 0.7) self._dest_node_path.setColor(self.navi_mark_color[0], self.navi_mark_color[1], self.navi_mark_color[2], 0.7) self._goal_node_path.hide(CamMask.AllOn) self._dest_node_path.hide(CamMask.AllOn) self._goal_node_path.show(CamMask.MainCam) self._dest_node_path.show(CamMask.MainCam) logging.debug("Load Vehicle Module: {}".format( self.__class__.__name__))
def __init__(self, global_config): self.global_config = global_config if self.global_config["pstats"]: # pstats debug provided by panda3d loadPrcFileData("", "want-pstats 1") loadPrcFileData( "", "win-size {} {}".format(*self.global_config["window_size"])) # Setup onscreen render if self.global_config["use_render"]: self.mode = RENDER_MODE_ONSCREEN # Warning it may cause memory leak, Pand3d Official has fixed this in their master branch. # You can enable it if your panda version is latest. loadPrcFileData( "", "threading-model Cull/Draw" ) # multi-thread render, accelerate simulation when evaluate else: if self.global_config["offscreen_render"]: self.mode = RENDER_MODE_OFFSCREEN loadPrcFileData("", "threading-model Cull/Draw") else: self.mode = RENDER_MODE_NONE if is_mac() and (self.mode == RENDER_MODE_OFFSCREEN ): # Mac don't support offscreen rendering self.mode = RENDER_MODE_ONSCREEN # Setup some debug options if self.global_config["headless_machine_render"]: # headless machine support loadPrcFileData("", "load-display pandagles2") if self.global_config["debug"]: # debug setting EngineCore.DEBUG = True _free_warning() setup_logger(debug=True) self.accept('1', self.toggleDebug) self.accept('2', self.toggleWireframe) self.accept('3', self.toggleTexture) self.accept('4', self.toggleAnalyze) else: # only report fatal error when debug is False _suppress_warning() # a special debug mode if self.global_config["debug_physics_world"]: self.accept('1', self.toggleDebug) self.accept('4', self.toggleAnalyze) super(EngineCore, self).__init__(windowType=self.mode) # Change window size at runtime if screen too small # assert int(self.global_config["use_topdown"]) + int(self.global_config["offscreen_render"]) <= 1, ( # "Only one of use_topdown and offscreen_render options can be selected." # ) # main_window_position = (0, 0) if self.mode == RENDER_MODE_ONSCREEN: if self.global_config["fast"]: pass else: loadPrcFileData("", "compressed-textures 1") # Default to compress h = self.pipe.getDisplayHeight() w = self.pipe.getDisplayWidth() if self.global_config["window_size"][ 0] > 0.9 * w or self.global_config["window_size"][ 1] > 0.9 * h: old_scale = self.global_config["window_size"][ 0] / self.global_config["window_size"][1] new_w = int(min(0.9 * w, 0.9 * h * old_scale)) new_h = int(min(0.9 * h, 0.9 * w / old_scale)) self.global_config["window_size"] = tuple([new_w, new_h]) from panda3d.core import WindowProperties props = WindowProperties() props.setSize(self.global_config["window_size"][0], self.global_config["window_size"][1]) self.win.requestProperties(props) logging.warning( "Since your screen is too small ({}, {}), we resize the window to {}." .format(w, h, self.global_config["window_size"])) # main_window_position = ( # (w - self.global_config["window_size"][0]) / 2, (h - self.global_config["window_size"][1]) / 2 # ) # self.highway_render = None # if self.global_config["use_topdown"]: # self.highway_render = HighwayRender(self.global_config["use_render"], main_window_position) # screen scale factor self.w_scale = max( self.global_config["window_size"][0] / self.global_config["window_size"][1], 1) self.h_scale = max( self.global_config["window_size"][1] / self.global_config["window_size"][0], 1) if self.mode == RENDER_MODE_ONSCREEN: self.disableMouse() if not self.global_config["debug_physics_world"] and (self.mode in [ RENDER_MODE_ONSCREEN, RENDER_MODE_OFFSCREEN ]): initialize_asset_loader(self) gltf.patch_loader(self.loader) # Display logo if self.mode == RENDER_MODE_ONSCREEN and (not self.global_config["debug"]) \ and (not self.global_config["fast"]): self._loading_logo = OnscreenImage( image=AssetLoader.file_path("PGDrive-large.png"), pos=(0, 0, 0), scale=(self.w_scale, 1, self.h_scale)) self._loading_logo.setTransparency(True) for i in range(20): self.graphicsEngine.renderFrame() self.taskMgr.add(self.remove_logo, "remove _loading_logo in first frame") self.closed = False # add element to render and pbr render, if is exists all the time. # these element will not be removed when clear_world() is called self.pbr_render = self.render.attachNewNode("pbrNP") # attach node to this root root whose children nodes will be clear after calling clear_world() self.worldNP = self.render.attachNewNode("world_np") # same as worldNP, but this node is only used for render gltf model with pbr material self.pbr_worldNP = self.pbr_render.attachNewNode("pbrNP") self.debug_node = None # some render attribute self.pbrpipe = None self.world_light = None # physics world self.physics_world = PhysicsWorld( self.global_config["debug_static_world"]) # collision callback self.physics_world.dynamic_world.setContactAddedCallback( PythonCallbackObject(collision_callback)) # for real time simulation self.force_fps = ForceFPS(self, start=True) # init terrain self.terrain = Terrain() self.terrain.attach_to_world(self.render, self.physics_world) # init other world elements if self.mode != RENDER_MODE_NONE: from pgdrive.engine.core.our_pbr import OurPipeline self.pbrpipe = OurPipeline(render_node=None, window=None, camera_node=None, msaa_samples=4, max_lights=8, use_normal_maps=False, use_emission_maps=True, exposure=1.0, enable_shadows=False, enable_fog=False, use_occlusion_maps=False) self.pbrpipe.render_node = self.pbr_render self.pbrpipe.render_node.set_antialias(AntialiasAttrib.M_auto) self.pbrpipe._recompile_pbr() self.pbrpipe.manager.cleanup() # set main cam self.cam.node().setCameraMask(CamMask.MainCam) self.cam.node().getDisplayRegion(0).setClearColorActive(True) self.cam.node().getDisplayRegion(0).setClearColor(BKG_COLOR) lens = self.cam.node().getLens() lens.setFov(70) lens.setAspectRatio(1.2) self.sky_box = SkyBox() self.sky_box.attach_to_world(self.render, self.physics_world) self.world_light = Light(self.global_config) self.world_light.attach_to_world(self.render, self.physics_world) self.render.setLight(self.world_light.direction_np) self.render.setLight(self.world_light.ambient_np) self.render.setShaderAuto() self.render.setAntialias(AntialiasAttrib.MAuto) # ui and render property if self.global_config["show_fps"]: self.setFrameRateMeter(True) # onscreen message self.on_screen_message = ScreenMessage( debug=self.DEBUG ) if self.mode == RENDER_MODE_ONSCREEN and self.global_config[ "onscreen_message"] else None self._show_help_message = False self._episode_start_time = time.time() self.accept("h", self.toggle_help_message) self.accept("f", self.force_fps.toggle) else: self.on_screen_message = None # task manager self.taskMgr.remove('audioLoop')