#NEWLINE# def __init__( self , sourcebyid , bind_shape_matrix , joint_source , joint_matrix_source , weight_source , weight_joint_source , vcounts , vertex_weight_index , offsets , geometry , controller_node = None , skin_node = None ) : #NEWLINE# #INDENT# "Create a skin.\n\n        :Parameters:\n          sourceById\n            A dict mapping id's to a collada source\n          bind_shape_matrix\n            A numpy array of floats (pre-shape)\n          joint_source\n            The string id for the joint source\n          joint_matrix_source\n            The string id for the joint matrix source\n          weight_source\n            The string id for the weight source\n          weight_joint_source\n            The string id for the joint source of weights\n          vcounts\n            A list with the number of influences on each vertex\n          vertex_weight_index\n            An array with the indexes as they come from <v> array\n          offsets\n            A list with the offsets in the weight index array for each source\n            in (joint, weight)\n          geometry\n            The source geometry this should be applied to (geometry.Geometry)\n          controller_node\n            XML node of the <controller> tag which is the parent of this\n          skin_node\n            XML node of the <skin> tag if this is from there\n\n        " #NEWLINE# self . sourcebyid = sourcebyid #NEWLINE# self . bind_shape_matrix = bind_shape_matrix #NEWLINE# self . joint_source = joint_source #NEWLINE# self . joint_matrix_source = joint_matrix_source #NEWLINE# self . weight_source = weight_source #NEWLINE# self . weight_joint_source = weight_joint_source #NEWLINE# self . vcounts = vcounts #NEWLINE# self . vertex_weight_index = vertex_weight_index #NEWLINE# self . offsets = offsets #NEWLINE# self . geometry = geometry #NEWLINE# self . controller_node = controller_node #NEWLINE# self . skin_node = skin_node #NEWLINE# self . xmlnode = controller_node #NEWLINE# if ( not ( type ( self . geometry ) is Geometry ) ) : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Invalid reference geometry in skin' ) #NEWLINE# #UNINDENT# self . id = controller_node . get ( 'id' ) #NEWLINE# if ( self . id is None ) : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Controller node requires an ID' ) #NEWLINE# #UNINDENT# self . nindices = ( max ( self . offsets ) + 1 ) #NEWLINE# if ( len ( bind_shape_matrix ) != 16 ) : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Corrupted bind shape matrix in skin' ) #NEWLINE# #UNINDENT# self . bind_shape_matrix . shape = ( 4 , 4 ) #NEWLINE# if ( not ( ( joint_source in sourcebyid ) and ( joint_matrix_source in sourcebyid ) ) ) : #NEWLINE# #INDENT# raise DaeBrokenRefError ( 'Input in joints not found' ) #NEWLINE# #UNINDENT# if ( not ( ( type ( sourcebyid [ joint_source ] ) is source . NameSource ) or ( type ( sourcebyid [ joint_source ] ) is source . IDRefSource ) ) ) : #NEWLINE# #INDENT# raise DaeIncompleteError ( 'Could not find joint name input for skin' ) #NEWLINE# #UNINDENT# if ( not ( type ( sourcebyid [ joint_matrix_source ] ) is source . FloatSource ) ) : #NEWLINE# #INDENT# raise DaeIncompleteError ( 'Could not find joint matrix source for skin' ) #NEWLINE# #UNINDENT# joint_names = [ j for j in sourcebyid [ joint_source ] ] #NEWLINE# joint_matrices = sourcebyid [ joint_matrix_source ] . data #NEWLINE# joint_matrices . shape = ( ( - 1 ) , 4 , 4 ) #NEWLINE# if ( len ( joint_names ) != len ( joint_matrices ) ) : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Skin joint and matrix inputs must be same length' ) #NEWLINE# #UNINDENT# self . joint_matrices = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( n , m ) in zip ( joint_names , joint_matrices ) : #NEWLINE# #INDENT# self . joint_matrices [ n ] = m #NEWLINE# #UNINDENT# if ( not ( ( weight_source in sourcebyid ) and ( weight_joint_source in sourcebyid ) ) ) : #NEWLINE# #INDENT# raise DaeBrokenRefError ( 'Weights input in joints not found' ) #NEWLINE# #UNINDENT# if ( not ( type ( sourcebyid [ weight_source ] ) is source . FloatSource ) ) : #NEWLINE# #INDENT# raise DaeIncompleteError ( 'Could not find weight inputs for skin' ) #NEWLINE# #UNINDENT# if ( not ( ( type ( sourcebyid [ weight_joint_source ] ) is source . NameSource ) or ( type ( sourcebyid [ weight_joint_source ] ) is source . IDRefSource ) ) ) : #NEWLINE# #INDENT# raise DaeIncompleteError ( 'Could not find weight joint source input for skin' ) #NEWLINE# #UNINDENT# self . weights = sourcebyid [ weight_source ] #NEWLINE# self . weight_joints = sourcebyid [ weight_joint_source ] #NEWLINE# try : #NEWLINE# #INDENT# newshape = [ ] #NEWLINE# at = 0 #NEWLINE# for ct in self . vcounts : #NEWLINE# #INDENT# this_set = self . vertex_weight_index [ ( self . nindices * at ) : ( self . nindices * ( at + ct ) ) ] #NEWLINE# this_set . shape = ( ct , self . nindices ) #NEWLINE# newshape . append ( numpy . array ( this_set ) ) #NEWLINE# at += ct #NEWLINE# #UNINDENT# self . index = newshape #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Corrupted vcounts or index in skin weights' ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# self . joint_index = [ influence [ : , self . offsets [ 0 ] ] for influence in self . index ] #NEWLINE# self . weight_index = [ influence [ : , self . offsets [ 1 ] ] for influence in self . index ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# raise DaeMalformedError ( 'Corrupted joint or weight index in skin' ) #NEWLINE# #UNINDENT# self . max_joint_index = numpy . max ( [ ( numpy . max ( joint ) if ( len ( joint ) > 0 ) else 0 ) for joint in self . joint_index ] ) #NEWLINE# self . max_weight_index = numpy . max ( [ ( numpy . max ( weight ) if ( len ( weight ) > 0 ) else 0 ) for weight in self . weight_index ] ) #NEWLINE# checkSource ( self . weight_joints , ( 'JOINT' , ) , self . max_joint_index ) #NEWLINE# checkSource ( self . weights , ( 'WEIGHT' , ) , self . max_weight_index )