def _create_anim_src_elem(anim_name, src_data, src_suffix, src_type, param_name, param_type): """""" idName = anim_name + "-" + src_suffix src_elem = E.source(id=idName) idName += "-array" count = len(src_data) / 16 if param_type == "float4x4" else len(src_data) if src_type == "float": str_src_data = " ".join([str(round(val, precision)) for val in src_data]) + " " str_src_data = str_src_data.replace(".0 ", " ") else: str_src_data = " ".join(map(str, src_data)) src_elem.append(E(src_type + "_array", str_src_data, id=idName, count=str(count))) src_elem.append( E.technique_common( E.accessor( E.param(name=param_name, type=param_type), # accessor child source="#" + idName, count=str(count), # accessor attribs ) ) ) if param_type == "float4x4": src_elem.find(tag("technique_common")).find(tag("accessor")).set("stride", str(16)) return src_elem
def _create_anim_src_elem(anim_name, src_data, src_suffix, src_type, param_name, param_type): """""" idName = anim_name + "-" + src_suffix src_elem = E.source(id=idName) idName += "-array" count = len(src_data) / 16 if param_type == "float4x4" else len( src_data) if src_type == "float": str_src_data = " ".join( [str(round(val, precision)) for val in src_data]) + " " str_src_data = str_src_data.replace(".0 ", " ") else: str_src_data = " ".join(map(str, src_data)) src_elem.append( E(src_type + "_array", str_src_data, id=idName, count=str(count))) src_elem.append( E.technique_common( E.accessor( E.param(name=param_name, type=param_type), #accessor child source="#" + idName, count=str(count) #accessor attribs ))) if param_type == "float4x4": src_elem.find(tag("technique_common")).find(tag("accessor")).set( "stride", str(16)) return src_elem
def __init__(self, id, data, components, xmlnode=None): """Create a name source instance. :param str id: A unique string identifier for the source :param numpy.array data: Numpy array (unshaped) with the source values :param tuple components: Tuple of strings describing the semantic of the data, e.g. ``('JOINT')`` would cause :attr:`data` to be reshaped as ``(-1, 1)`` :param xmlnode: When loaded, the xmlnode it comes from. """ self.id = id """The unique string identifier for the source""" self.data = data """Numpy array with the source values. This will be shaped as ``(-1,N)`` where ``N = len(self.components)``""" self.data.shape = (-1, len(components)) self.components = components """Tuple of strings describing the semantic of the data, e.g. ``('JOINT')``""" if xmlnode != None: self.xmlnode = xmlnode """ElementTree representation of the source.""" else: self.data.shape = (-1, ) txtdata = ' '.join(map(str, self.data.tolist())) rawlen = len(self.data) self.data.shape = (-1, len(self.components)) acclen = len(self.data) stridelen = len(self.components) sourcename = "%s-array" % self.id self.xmlnode = E.source(E.Name_array(txtdata, count=str(rawlen), id=sourcename), E.technique_common( E.accessor( *[ E.param(type='Name', name=c) for c in self.components ], **{ 'count': str(acclen), 'stride': str(stridelen), 'source': sourcename })), id=self.id)
def __init__(self, id, data, components, xmlnode=None): """Create a name source instance. :param str id: A unique string identifier for the source :param numpy.array data: Numpy array (unshaped) with the source values :param tuple components: Tuple of strings describing the semantic of the data, e.g. ``('JOINT')`` would cause :attr:`data` to be reshaped as ``(-1, 1)`` :param xmlnode: When loaded, the xmlnode it comes from. """ self.id = id """The unique string identifier for the source""" self.data = data """Numpy array with the source values. This will be shaped as ``(-1,N)`` where ``N = len(self.components)``""" self.data.shape = (-1, len(components) ) self.components = components """Tuple of strings describing the semantic of the data, e.g. ``('JOINT')``""" if xmlnode != None: self.xmlnode = xmlnode """ElementTree representation of the source.""" else: self.data.shape = (-1,) txtdata = ' '.join(map(str, self.data.tolist() )) rawlen = len( self.data ) self.data.shape = (-1, len(self.components) ) acclen = len( self.data ) stridelen = len(self.components) sourcename = "%s-array"%self.id self.xmlnode = E.source( E.Name_array(txtdata, count=str(rawlen), id=sourcename), E.technique_common( E.accessor( *[E.param(type='Name', name=c) for c in self.components] , **{'count':str(acclen), 'stride':str(stridelen), 'source':sourcename}) ) , id=self.id )