本文整理汇总了Python中collada.E.input方法的典型用法代码示例。如果您正苦于以下问题:Python E.input方法的具体用法?Python E.input怎么用?Python E.input使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类collada.E
的用法示例。
在下文中一共展示了E.input方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from collada import E [as 别名]
# 或者: from collada.E import input [as 别名]
def __init__(self, sources, material, polygons, xmlnode=None):
"""A Polygons should not be created manually. Instead, call the
:meth:`collada.geometry.Geometry.createPolygons` method after
creating a geometry instance.
"""
max_offset = max([ max([input[0] for input in input_type_array])
for input_type_array in sources.itervalues() if len(input_type_array) > 0])
vcounts = numpy.zeros(len(polygons), dtype=numpy.int32)
for i, poly in enumerate(polygons):
vcounts[i] = len(poly) / (max_offset + 1)
indices = numpy.concatenate(polygons)
super(Polygons, self).__init__(sources, material, indices, vcounts, xmlnode)
if xmlnode is not None: self.xmlnode = xmlnode
else:
acclen = len(polygons)
self.xmlnode = E.polygons(count=str(acclen), material=self.material)
all_inputs = []
for semantic_list in self.sources.itervalues():
all_inputs.extend(semantic_list)
for offset, semantic, sourceid, set, src in all_inputs:
inpnode = E.input(offset=str(offset), semantic=semantic, source=sourceid)
if set is not None:
inpnode.set('set', str(set))
self.xmlnode.append(inpnode)
for poly in polygons:
self.xmlnode.append(E.p(' '.join(map(str, poly.flatten().tolist()))))
示例2: _recreateXmlNode
# 需要导入模块: from collada import E [as 别名]
# 或者: from collada.E import input [as 别名]
def _recreateXmlNode(self):
self.index.shape = (-1)
acclen = len(self.index)
txtindices = ' '.join(map(str, self.index.tolist()))
self.index.shape = (-1, 3, self.nindices)
self.xmlnode = E.triangles(count=str(self.ntriangles))
if self.material is not None:
self.xmlnode.set('material', self.material)
all_inputs = []
for semantic_list in self.sources.itervalues():
all_inputs.extend(semantic_list)
for offset, semantic, sourceid, set, src in all_inputs:
inpnode = E.input(offset=str(offset), semantic=semantic, source=sourceid)
if set is not None:
inpnode.set('set', str(set))
self.xmlnode.append(inpnode)
self.xmlnode.append(E.p(txtindices))
示例3: __init__
# 需要导入模块: from collada import E [as 别名]
# 或者: from collada.E import input [as 别名]
def __init__(self, sources, material, index, xmlnode=None):
"""A LineSet should not be created manually. Instead, call the
:meth:`collada.geometry.Geometry.createLineSet` method after
creating a geometry instance.
"""
if len(sources) == 0: raise DaeIncompleteError('A line set needs at least one input for vertex positions')
if not 'VERTEX' in sources: raise DaeIncompleteError('Line set requires vertex input')
#find max offset
max_offset = max([ max([input[0] for input in input_type_array])
for input_type_array in sources.itervalues() if len(input_type_array) > 0])
self.sources = sources
self.material = material
self.index = index
self.indices = self.index
self.nindices = max_offset + 1
self.index.shape = (-1, 2, self.nindices)
self.nlines = len(self.index)
if len(self.index) > 0:
self._vertex = sources['VERTEX'][0][4].data
self._vertex_index = self.index[:,:, sources['VERTEX'][0][0]]
self.maxvertexindex = numpy.max( self._vertex_index )
checkSource(sources['VERTEX'][0][4], ('X', 'Y', 'Z'), self.maxvertexindex)
else:
self._vertex = None
self._vertex_index = None
self.maxvertexindex = -1
if 'NORMAL' in sources and len(sources['NORMAL']) > 0 and len(self.index) > 0:
self._normal = sources['NORMAL'][0][4].data
self._normal_index = self.index[:,:, sources['NORMAL'][0][0]]
self.maxnormalindex = numpy.max( self._normal_index )
checkSource(sources['NORMAL'][0][4], ('X', 'Y', 'Z'), self.maxnormalindex)
else:
self._normal = None
self._normal_index = None
self.maxnormalindex = -1
if 'TEXCOORD' in sources and len(sources['TEXCOORD']) > 0 and len(self.index) > 0:
self._texcoordset = tuple([texinput[4].data for texinput in sources['TEXCOORD']])
self._texcoord_indexset = tuple([ self.index[:,:, sources['TEXCOORD'][i][0]]
for i in xrange(len(sources['TEXCOORD'])) ])
self.maxtexcoordsetindex = [ numpy.max( tex_index ) for tex_index in self._texcoord_indexset ]
for i, texinput in enumerate(sources['TEXCOORD']):
checkSource(texinput[4], ('S', 'T'), self.maxtexcoordsetindex[i])
else:
self._texcoordset = tuple()
self._texcoord_indexset = tuple()
self.maxtexcoordsetindex = -1
if xmlnode is not None:
self.xmlnode = xmlnode
"""ElementTree representation of the line set."""
else:
self.index.shape = (-1)
acclen = len(self.index)
txtindices = ' '.join(map(str, self.index.tolist()))
self.index.shape = (-1, 2, self.nindices)
self.xmlnode = E.lines(count=str(self.nlines), material=self.material)
all_inputs = []
for semantic_list in self.sources.itervalues():
all_inputs.extend(semantic_list)
for offset, semantic, sourceid, set, src in all_inputs:
inpnode = E.input(offset=str(offset), semantic=semantic, source=sourceid)
if set is not None:
inpnode.set('set', str(set))
self.xmlnode.append(inpnode)
self.xmlnode.append(E.p(txtindices))
示例4: __init__
# 需要导入模块: from collada import E [as 别名]
# 或者: from collada.E import input [as 别名]
def __init__(self, collada, id, name, sourcebyid, primitives=None, xmlnode=None, double_sided=False):
"""Create a geometry instance
:param collada.Collada collada:
The collada object this geometry belongs to
:param str id:
A unique string identifier for the geometry
:param str name:
A text string naming the geometry
:param sourcebyid:
A list of :class:`collada.source.Source` objects or
a dictionary mapping source ids to the actual objects
:param list primitives:
List of primitive objects contained within the geometry.
Do not set this argument manually. Instead, create a
:class:`collada.geometry.Geometry` first and then append
to :attr:`primitives` with the `create*` functions.
:param xmlnode:
When loaded, the xmlnode it comes from.
:param bool double_sided:
Whether or not the geometry should be rendered double sided
"""
self.collada = collada
"""The :class:`collada.Collada` object this geometry belongs to"""
self.id = id
"""The unique string identifier for the geometry"""
self.name = name
"""The text string naming the geometry"""
self.double_sided = double_sided
"""A boolean indicating whether or not the geometry should be rendered double sided"""
self.sourceById = sourcebyid
"""A dictionary containing :class:`collada.source.Source` objects indexed by their id."""
if type(sourcebyid) is types.ListType:
self.sourceById = {}
for src in sourcebyid:
self.sourceById[src.id] = src
self.primitives = []
"""List of primitives (base type :class:`collada.primitive.Primitive`) inside this geometry."""
if primitives is not None:
self.primitives = primitives
if xmlnode != None:
self.xmlnode = xmlnode
"""ElementTree representation of the geometry."""
else:
sourcenodes = []
verticesnode = None
for srcid, src in self.sourceById.iteritems():
sourcenodes.append(src.xmlnode)
if verticesnode is None:
# pick first source to be in the useless <vertices> tag
verticesnode = E.vertices(
E.input(semantic="POSITION", source="#%s" % srcid), id=srcid + "-vertices"
)
meshnode = E.mesh(*sourcenodes)
meshnode.append(verticesnode)
self.xmlnode = E.geometry(meshnode)
if len(self.id) > 0:
self.xmlnode.set("id", self.id)
if len(self.name) > 0:
self.xmlnode.set("name", self.name)