#NEWLINE# @ staticmethod #NEWLINE# def load( collada , localscope , morphnode , controllernode ) : #NEWLINE# #INDENT# baseid = morphnode . get ( 'source' ) #NEWLINE# if ( ( len ( baseid ) < 2 ) or ( baseid [ 0 ] != '#' ) or ( not ( baseid [ 1 : ] in collada . geometries ) ) ) : #NEWLINE# #INDENT# raise DaeBrokenRefError ( ( 'Base source of morph %s not found' % baseid ) ) #NEWLINE# #UNINDENT# basegeom = collada . geometries [ baseid [ 1 : ] ] #NEWLINE# method = morphnode . get ( 'method' ) #NEWLINE# if ( method is None ) : #NEWLINE# #INDENT# method = 'NORMALIZED' #NEWLINE# #UNINDENT# if ( not ( ( method == 'NORMALIZED' ) or ( method == 'RELATIVE' ) ) ) : #NEWLINE# #INDENT# raise DaeMalformedError ( ( "Morph method must be either NORMALIZED or RELATIVE. Found '%s'" % method ) ) #NEWLINE# #UNINDENT# inputnodes = morphnode . findall ( ( '%s/%s' % ( tag ( 'targets' ) , tag ( 'input' ) ) ) ) #NEWLINE# if ( ( inputnodes is None ) or ( len ( inputnodes ) < 2 ) ) : #NEWLINE# #INDENT# raise DaeIncompleteError ( 'Not enough inputs in a morph' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# inputs = [ ( i . get ( 'semantic' ) , i . get ( 'source' ) ) for i in inputnodes ] #NEWLINE# #UNINDENT# except ValueError as ex : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Corrupted inputs in morph' ) #NEWLINE# #UNINDENT# target_source = None #NEWLINE# weight_source = None #NEWLINE# for i in inputs : #NEWLINE# #INDENT# if ( ( len ( i [ 1 ] ) < 2 ) or ( i [ 1 ] [ 0 ] != '#' ) or ( not ( i [ 1 ] [ 1 : ] in localscope ) ) ) : #NEWLINE# #INDENT# raise DaeBrokenRefError ( ( 'Input in morph node %s not found' % i [ 1 ] ) ) #NEWLINE# #UNINDENT# if ( i [ 0 ] == 'MORPH_TARGET' ) : #NEWLINE# #INDENT# target_source = localscope [ i [ 1 ] [ 1 : ] ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( i [ 0 ] == 'MORPH_WEIGHT' ) : #NEWLINE# #INDENT# weight_source = localscope [ i [ 1 ] [ 1 : ] ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( not ( type ( target_source ) is source . IDRefSource ) ) or ( not ( type ( weight_source ) is source . FloatSource ) ) ) : #NEWLINE# #INDENT# raise DaeIncompleteError ( 'Not enough inputs in targets of morph' ) #NEWLINE# #UNINDENT# if ( len ( target_source ) != len ( basegeom ) ) : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Morph inputs must be of same length' ) #NEWLINE# #UNINDENT# target_list = [ ] #NEWLINE# for ( target , weight ) in zip ( target_source , weight_source ) : #NEWLINE# #INDENT# if ( ( len ( target ) < 1 ) or ( not ( target in collada . geometries ) ) ) : #NEWLINE# #INDENT# raise DaeBrokenRefError ( ( 'Targeted geometry %s in morph not found' % target ) ) #NEWLINE# #UNINDENT# target_list . append ( ( collada . geometries [ target ] , weight [ 0 ] ) ) #NEWLINE# #UNINDENT# return Morph ( basegeom , target_list , controllernode )