<s> """<STR_LIT>""" <EOL> from panda3d . core import Mat4 , PerspectiveLens , LVector3 , LVecBase2i , LVecBase2f <EOL> from panda3d . core import BoundingSphere <EOL> class ShadowSource ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . _slot = - <NUM_LIT:1> <EOL> self . _needs_update = True <EOL> self . _resolution = <NUM_LIT> <EOL> self . _mvp = <NUM_LIT:0.0> <EOL> self . _region = LVecBase2i ( - <NUM_LIT:1> ) <EOL> self . _region_uv = LVecBase2f ( <NUM_LIT:0.0> ) <EOL> self . _bounds = BoundingSphere ( ) <EOL> def set_resolution ( self , resolution ) : <EOL> self . _resolution = resolution <EOL> def set_needs_update ( self , flag ) : <EOL> self . _needs_update = flag <EOL> def set_slot ( self , slot ) : <EOL> self . _slot = slot <EOL> def set_region ( self , region , region_uv ) : <EOL> self . _region = region <EOL> self . _region_uv = region_uv <EOL> def clear_region ( self ) : <EOL> self . _region = LVecBase2i ( - <NUM_LIT:1> ) <EOL> self . _region_uv = LVecBase2f ( <NUM_LIT:0.0> ) <EOL> def get_bounds ( self ) : <EOL> return self . _bounds <EOL> def set_perspective_lens ( self , fov , near_plane , far_plane , pos , direction ) : <EOL> transform_mat = Mat4 . translate_mat ( - pos ) <EOL> temp_lens = PerspectiveLens ( fov , fov ) <EOL> temp_lens . set_film_offset ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> temp_lens . set_near_far ( near_plane , far_plane ) <EOL> temp_lens . set_view_vector ( direction , LVector3 . up ( ) ) <EOL> self . set_matrix_lens ( transform_mat * temp_lens . get_projection_mat ( ) ) <EOL> hexahedron = temp_lens . make_bounds ( ) <EOL> center = ( hexahedron . get_min ( ) + hexahedron . get_max ( ) ) * <NUM_LIT:0.5> <EOL> self . _bounds = BoundingSphere ( pos + center , ( hexahedron . get_max ( ) - center ) . length ( ) ) <EOL> def set_matrix_lens ( self , mvp ) : <EOL> self . _mvp = mvp <EOL> self . set_needs_update ( True ) <EOL> def has_region ( self ) : <EOL> return ( self . _region . x >= <NUM_LIT:0> and self . _region . y >= <NUM_LIT:0> and <EOL> self . _region . z >= <NUM_LIT:0> and self . _region . w >= <NUM_LIT:0> ) <EOL> def has_slot ( self ) : <EOL> return self . _slot >= <NUM_LIT:0> <EOL> def get_slot ( self ) : <EOL> return self . _slot <EOL> def get_needs_update ( self ) : <EOL> return not self . has_region or self . _needs_update <EOL> def get_resolution ( self ) : <EOL> return self . _resolution <EOL> def get_mvp ( self ) : <EOL> return self . _mvp <EOL> def get_region ( self ) : <EOL> return self . _region <EOL> def get_uv_region ( self ) : <EOL> return self . _region_uv <EOL> def write_to_command ( self , cmd ) : <EOL> cmd . push_mat4 ( self . _mvp ) <EOL> cmd . push_vec4 ( self . _region_uv ) </s>
