<s> from visual import * <EOL> show_sphere = True <EOL> scene . width = scene . height = <NUM_LIT> <EOL> names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> lookup = { "<STR_LIT>" : materials . wood , "<STR_LIT>" : materials . rough , <EOL> "<STR_LIT>" : materials . marble , "<STR_LIT>" : materials . plastic , <EOL> "<STR_LIT>" : materials . earth , "<STR_LIT>" : materials . diffuse , <EOL> "<STR_LIT>" : materials . emissive , "<STR_LIT>" : materials . unshaded , <EOL> "<STR_LIT>" : materials . shiny , "<STR_LIT>" : materials . chrome , <EOL> "<STR_LIT>" : materials . blazed , "<STR_LIT>" : materials . silver , <EOL> "<STR_LIT>" : materials . bricks , "<STR_LIT>" : materials . BlueMarble , <EOL> "<STR_LIT>" : materials . ice , "<STR_LIT>" : materials . glass } <EOL> def destroy ( ) : <EOL> for obj in scene . objects : <EOL> obj . visible = False <EOL> del obj <EOL> def show_object ( index , x , y , show_sphere ) : <EOL> sphere ( pos = ( x , y , <NUM_LIT:0> ) , radius = R / <NUM_LIT:5> , color = color . red ) <EOL> mat = lookup [ names [ index ] ] <EOL> if show_sphere : <EOL> s = sphere ( pos = ( x , y , <NUM_LIT:0> ) , radius = R , material = mat , index = index ) <EOL> if names [ index ] == "<STR_LIT>" : <EOL> s . rotate ( angle = pi / <NUM_LIT:2> , axis = ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> else : <EOL> box ( pos = ( x , y , <NUM_LIT:0> ) , size = ( D , D , D ) , material = mat , index = index ) <EOL> label ( pos = ( x , y - <NUM_LIT> ) , box = <NUM_LIT:0> , text = names [ index ] ) <EOL> D = <NUM_LIT> <EOL> R = <NUM_LIT> <EOL> first = True <EOL> show = - <NUM_LIT:1> <EOL> while True : <EOL> destroy ( ) <EOL> scene . range = <NUM_LIT> <EOL> scene . fov = <NUM_LIT:0.5> <EOL> scene . center = ( <NUM_LIT> , <NUM_LIT> ) <EOL> scene . forward = ( <NUM_LIT:0> , <NUM_LIT:0> , - <NUM_LIT:1> ) <EOL> index = <NUM_LIT:0> <EOL> for y in range ( <NUM_LIT:4> ) : <EOL> for x in range ( <NUM_LIT:4> ) : <EOL> if index >= <NUM_LIT:16> : break <EOL> show_object ( index , x , <NUM_LIT:3> - y , show_sphere ) <EOL> index += <NUM_LIT:1> <EOL> label ( pos = ( <NUM_LIT> , <NUM_LIT> ) , box = <NUM_LIT:0> , <EOL> text = "<STR_LIT>" ) <EOL> first = False <EOL> picked = None <EOL> while True : <EOL> rate ( <NUM_LIT:30> ) <EOL> if scene . mouse . events : <EOL> m = scene . mouse . getevent ( ) <EOL> if m . click and picked : <EOL> picked = None <EOL> break <EOL> elif m . click and m . pick : <EOL> mouseloc = scene . mouse . project ( normal = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:1> ) ) <EOL> xp , yp = ( mouseloc . x , mouseloc . y ) <EOL> x , y = ( m . pick . x , m . pick . y ) <EOL> if ( x - xp ) ** <NUM_LIT:2> + ( y - yp ) ** <NUM_LIT:2> < R ** <NUM_LIT:2> : <EOL> picked = m . pick <EOL> destroy ( ) <EOL> scene . center = ( <NUM_LIT:0> , - <NUM_LIT> * R , <NUM_LIT:0> ) <EOL> scene . range = <NUM_LIT> * R <EOL> show_object ( m . pick . index , <NUM_LIT:0> , <NUM_LIT:0> , show_sphere ) <EOL> label ( pos = ( <NUM_LIT:0> , <NUM_LIT> * R ) , box = <NUM_LIT:0> , text = "<STR_LIT>" ) <EOL> elif scene . kb . keys : <EOL> scene . kb . getkey ( ) <EOL> show_sphere = ( not show_sphere ) <EOL> if not picked : break <EOL> destroy ( ) <EOL> scene . forward = ( <NUM_LIT:0> , <NUM_LIT:0> , - <NUM_LIT:1> ) <EOL> show_object ( m . pick . index , <NUM_LIT:0> , <NUM_LIT:0> , show_sphere ) <EOL> label ( pos = ( <NUM_LIT:0> , <NUM_LIT> * R ) , box = <NUM_LIT:0> , text = "<STR_LIT>" ) </s>
