<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import sys <EOL> import socket <EOL> import time <EOL> import pickle <EOL> from threading import Thread <EOL> from panda3d . core import load_prc_file_data , Filename , Mat4 <EOL> from panda3d . core import CS_zup_right , CS_yup_right , BamCache <EOL> from direct . showbase . ShowBase import ShowBase <EOL> sys . path . insert ( <NUM_LIT:0> , "<STR_LIT>" ) <EOL> from rpcore import RenderPipeline , PointLight <EOL> class Application ( ShowBase ) : <EOL> ICOMING_PORT = <NUM_LIT> <EOL> def __init__ ( self ) : <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> load_prc_file_data ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . render_pipeline = RenderPipeline ( ) <EOL> self . render_pipeline . mount_mgr . config_dir = "<STR_LIT>" <EOL> self . render_pipeline . set_empty_loading_screen ( ) <EOL> self . render_pipeline . create ( self ) <EOL> self . setup_scene ( ) <EOL> BamCache . get_global_ptr ( ) . cache_models = False <EOL> self . update_queue = [ ] <EOL> self . start_listen ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> self . taskMgr . step ( ) <EOL> last_update = <NUM_LIT:0.0> <EOL> self . scene_node = None <EOL> while True : <EOL> curr_time = time . time ( ) <EOL> if curr_time > last_update + <NUM_LIT:1.0> : <EOL> last_update = curr_time <EOL> self . taskMgr . step ( ) <EOL> if self . update_queue : <EOL> if self . scene_node : <EOL> self . scene_node . remove_node ( ) <EOL> payload = self . update_queue . pop ( <NUM_LIT:0> ) <EOL> print ( "<STR_LIT>" , payload ) <EOL> scene = self . loader . loadModel ( Filename . from_os_specific ( payload [ "<STR_LIT>" ] ) ) <EOL> for light in scene . find_all_matches ( "<STR_LIT>" ) : <EOL> light . remove_node ( ) <EOL> for light in scene . find_all_matches ( "<STR_LIT>" ) : <EOL> light . remove_node ( ) <EOL> main_cam = scene . find ( "<STR_LIT>" ) <EOL> if main_cam : <EOL> transform_mat = main_cam . get_transform ( self . render ) . get_mat ( ) <EOL> transform_mat = Mat4 . convert_mat ( CS_zup_right , CS_yup_right ) * transform_mat <EOL> self . camera . set_mat ( transform_mat ) <EOL> else : <EOL> print ( "<STR_LIT>" ) <EOL> self . camera . set_pos ( <NUM_LIT:0> , - <NUM_LIT> , <NUM_LIT:0> ) <EOL> self . camera . look_at ( <NUM_LIT:0> , - <NUM_LIT> , <NUM_LIT:0> ) <EOL> self . camLens . set_fov ( <NUM_LIT> ) <EOL> self . scene_node = scene <EOL> scene . reparent_to ( self . render ) <EOL> for i in range ( <NUM_LIT:8> ) : <EOL> self . taskMgr . step ( ) <EOL> dest_path = Filename . from_os_specific ( payload [ "<STR_LIT>" ] ) <EOL> print ( "<STR_LIT>" , dest_path ) <EOL> self . win . save_screenshot ( dest_path ) <EOL> self . notify_about_finish ( int ( payload [ "<STR_LIT>" ] ) ) <EOL> def start_listen ( self ) : <EOL> """<STR_LIT>""" <EOL> thread = Thread ( target = self . listener_thread , args = ( ) , name = "<STR_LIT>" ) <EOL> thread . setDaemon ( True ) <EOL> thread . start ( ) <EOL> return thread <EOL> def listener_thread ( self ) : <EOL> """<STR_LIT>""" <EOL> sock = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM ) <EOL> sock . setsockopt ( socket . SOL_SOCKET , socket . SO_REUSEADDR , <NUM_LIT:1> ) <EOL> print ( "<STR_LIT>" + str ( self . ICOMING_PORT ) ) <EOL> try : <EOL> sock . bind ( ( "<STR_LIT:127.0.0.1>" , self . ICOMING_PORT ) ) <EOL> while True : <EOL> data , addr = sock . recvfrom ( <NUM_LIT> ) <EOL> self . handle_data ( data ) <EOL> except Exception as msg : <EOL> print ( "<STR_LIT>" , msg ) <EOL> finally : <EOL> sock . close ( ) <EOL> def handle_data ( self , data ) : <EOL> """<STR_LIT>""" <EOL> unpacked_data = pickle . loads ( data ) <EOL> self . update_queue . append ( unpacked_data ) <EOL> def notify_about_finish ( self , port ) : <EOL> """<STR_LIT>""" <EOL> print ( "<STR_LIT>" + str ( port ) ) <EOL> sock = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) <EOL> sock . setsockopt ( socket . IPPROTO_TCP , socket . TCP_NODELAY , <NUM_LIT:1> ) <EOL> try : <EOL> sock . connect ( ( "<STR_LIT:localhost>" , port ) ) <EOL> except Exception as msg : <EOL> print ( "<STR_LIT>" , msg ) <EOL> return <EOL> sock . sendall ( b"<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> sock . close ( ) <EOL> def setup_scene ( self ) : <EOL> """<STR_LIT>""" <EOL> self . disableMouse ( ) <EOL> self . render2d . hide ( ) <EOL> self . aspect2d . hide ( ) <EOL> light = PointLight ( ) <EOL> light . pos = <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> <EOL> light . radius = <NUM_LIT> <EOL> light . energy = <NUM_LIT> <EOL> light . set_color_from_temperature ( <NUM_LIT> ) <EOL> light = PointLight ( ) <EOL> light . pos = - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> <EOL> light . radius = <NUM_LIT> <EOL> light . set_color_from_temperature ( <NUM_LIT> ) <EOL> light . energy = <NUM_LIT> <EOL> Application ( ) </s>
