<s> from __future__ import absolute_import , division , print_function , unicode_literals <EOL> """<STR_LIT>""" <EOL> print ( """<STR_LIT>""" ) <EOL> import demo <EOL> import pi3d <EOL> import numpy as np <EOL> import time <EOL> import threading <EOL> DISPLAY = pi3d . Display . create ( x = <NUM_LIT:50> , y = <NUM_LIT:50> , near = <NUM_LIT> , far = <NUM_LIT> , frames_per_second = <NUM_LIT:20> , samples = <NUM_LIT:4> ) <EOL> DISPLAY . set_background ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> CAM = pi3d . Camera ( ) <EOL> CAM2D = pi3d . Camera ( is_3d = False ) <EOL> flatsh = pi3d . Shader ( "<STR_LIT>" ) <EOL> matsh = pi3d . Shader ( "<STR_LIT>" ) <EOL> target = pi3d . Sprite ( camera = CAM2D , z = <NUM_LIT> , w = <NUM_LIT:50> , h = <NUM_LIT:50> ) <EOL> target . set_draw_details ( flatsh , [ pi3d . Texture ( "<STR_LIT>" ) ] ) <EOL> import stars <EOL> s = stars . Stars ( ) <EOL> font = pi3d . Font ( '<STR_LIT>' ) <EOL> name_loc = s . v [ list ( s . names ) ] <EOL> label = pi3d . String ( font = font , string = '<STR_LIT>' , y = - <NUM_LIT> , is_3d = False , camera = CAM2D ) <EOL> label . set_shader ( flatsh ) <EOL> t = threading . Thread ( target = s . select_visible ) <EOL> t . daemon = True <EOL> t . start ( ) <EOL> while not s . ready : <EOL> time . sleep ( <NUM_LIT:0.1> ) <EOL> '''<STR_LIT>''' <EOL> orion = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <EOL> <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> orion_line = pi3d . Lines ( vertices = s . v [ orion , : <NUM_LIT:3> ] ) <EOL> orion_line . set_shader ( matsh ) <EOL> ursamajor = [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> ursamajor_line = pi3d . Lines ( vertices = s . v [ ursamajor , : <NUM_LIT:3> ] , material = ( <NUM_LIT:0.0> , <NUM_LIT> , <NUM_LIT> ) ) <EOL> ursamajor_line . set_shader ( matsh ) <EOL> pi = [ <NUM_LIT:0> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> pi_line = pi3d . Lines ( vertices = s . v [ pi , : <NUM_LIT:3> ] , material = ( <NUM_LIT> , <NUM_LIT:0.0> , <NUM_LIT> ) ) <EOL> pi_line . set_shader ( matsh ) <EOL> import starsystem as sm <EOL> near_system = sm . StarSystem ( sm . systems [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , sm . systems [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , sm . systems [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , s . v ) <EOL> mymouse = pi3d . Mouse ( restrict = False ) <EOL> mymouse . start ( ) <EOL> rot = <NUM_LIT:0.0> <EOL> tilt = <NUM_LIT:0.0> <EOL> step = [ <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] <EOL> mykeys = pi3d . Keyboard ( ) <EOL> fr = <NUM_LIT:1> <EOL> rec = False <EOL> while DISPLAY . loop_running ( ) : <EOL> mx , my = mymouse . position ( ) <EOL> rot = - mx * <NUM_LIT> <EOL> tilt = my * <NUM_LIT> <EOL> s . xm , s . ym , s . zm = CAM . relocate ( rot , tilt , point = [ s . xm , s . ym , s . zm ] , distance = step ) <EOL> s . draw ( ) <EOL> lbla = label . alpha ( ) <EOL> if lbla > <NUM_LIT> : <EOL> label . draw ( ) <EOL> orion_line . draw ( ) <EOL> ursamajor_line . draw ( ) <EOL> pi_line . draw ( ) <EOL> label . set_alpha ( lbla * <NUM_LIT> ) <EOL> orion_line . set_alpha ( lbla * <NUM_LIT:0.5> ) <EOL> ursamajor_line . set_alpha ( lbla * <NUM_LIT:0.5> ) <EOL> pi_line . set_alpha ( lbla * <NUM_LIT:0.5> ) <EOL> sublight = abs ( step [ <NUM_LIT:0> ] ) < <NUM_LIT> <EOL> if sublight : <EOL> near_system . draw ( ) <EOL> target . draw ( ) <EOL> if s . ready : <EOL> s . re_init ( ) <EOL> k = mykeys . read ( ) <EOL> if k > - <NUM_LIT:1> : <EOL> if k == ord ( '<STR_LIT:p>' ) : <EOL> rec = not rec <EOL> elif k == ord ( '<STR_LIT:w>' ) : <EOL> step = [ i + i * <NUM_LIT> for i in step ] if step [ <NUM_LIT:0> ] >= <NUM_LIT> else [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] <EOL> elif k == ord ( '<STR_LIT:s>' ) : <EOL> step = [ i - abs ( i ) * <NUM_LIT> for i in step ] if abs ( step [ <NUM_LIT:0> ] ) >= <NUM_LIT> else [ - <NUM_LIT> , - <NUM_LIT> , - <NUM_LIT> ] <EOL> elif k == <NUM_LIT> : <EOL> mykeys . close ( ) <EOL> DISPLAY . stop ( ) <EOL> break <EOL> else : <EOL> if k == ord ( '<STR_LIT:U+0020>' ) : <EOL> r_loc = s . v [ [ systm [ <NUM_LIT:0> ] for systm in sm . systems ] , <NUM_LIT:0> : <NUM_LIT:3> ] - [ s . xm , s . ym , s . zm ] <EOL> r_dist = ( r_loc [ : , <NUM_LIT:0> ] ** <NUM_LIT:2> + r_loc [ : , <NUM_LIT:1> ] ** <NUM_LIT:2> + r_loc [ : , <NUM_LIT:2> ] ** <NUM_LIT:2> ) . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> n = np . argmin ( r_dist ) <EOL> if r_dist [ n ] < <NUM_LIT> : <EOL> near_system . visible = True <EOL> if near_system . star_ref != n : <EOL> near_system . change_details ( sm . systems [ n ] [ <NUM_LIT:0> ] , sm . systems [ n ] [ <NUM_LIT:1> ] , sm . systems [ n ] [ <NUM_LIT:2> ] , s . v ) <EOL> if not sublight : <EOL> s . xm , s . ym , s . zm = s . v [ sm . systems [ n ] [ <NUM_LIT:0> ] , <NUM_LIT:0> : <NUM_LIT:3> ] + [ <NUM_LIT> , <NUM_LIT:0.0> , - <NUM_LIT> ] <EOL> else : <EOL> near_system . visible = False <EOL> step = [ <NUM_LIT:0.0> , <NUM_LIT:0.0> , <NUM_LIT:0.0> ] <EOL> r_loc = name_loc [ : , <NUM_LIT:0> : <NUM_LIT:3> ] - [ s . xm , s . ym , s . zm ] <EOL> r_dist = ( ( r_loc [ : , <NUM_LIT:0> ] ** <NUM_LIT:2> + r_loc [ : , <NUM_LIT:1> ] ** <NUM_LIT:2> + r_loc [ : , <NUM_LIT:2> ] ** <NUM_LIT:2> ) ** <NUM_LIT:0.5> ) . reshape ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> n = np . argmax ( np . dot ( r_loc / r_dist , CAM . mtrx [ <NUM_LIT:0> : <NUM_LIT:3> , <NUM_LIT:3> ] ) ) <EOL> label = pi3d . String ( font = font , string = '<STR_LIT>' . format ( <EOL> s . names [ int ( name_loc [ n , <NUM_LIT:7> ] ) ] , r_dist [ n , <NUM_LIT:0> ] * <NUM_LIT> , step [ <NUM_LIT:0> ] * <NUM_LIT> ) , <EOL> y = - <NUM_LIT> , is_3d = False , camera = CAM2D ) <EOL> label . set_shader ( flatsh ) <EOL> label . set_alpha ( <NUM_LIT> ) <EOL> orion_line . set_alpha ( <NUM_LIT:0.5> ) <EOL> ursamajor_line . set_alpha ( <NUM_LIT:0.5> ) </s>
