本文整理汇总了Python中collada.E类的典型用法代码示例。如果您正苦于以下问题:Python E类的具体用法?Python E怎么用?Python E使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了E类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, id, name, effect, xmlnode=None):
"""Creates a material.
:param str id:
A unique string identifier for the material
:param str name:
A name for the material
:param collada.material.Effect effect:
The effect instantiated in this material
:param xmlnode:
If loaded from xml, the xml node
"""
self.id = id
"""The unique string identifier for the material"""
self.name = name
"""The name for the material"""
self.effect = effect
"""The :class:`collada.material.Effect` instantiated in this material"""
if xmlnode != None:
self.xmlnode = xmlnode
"""ElementTree representation of the surface."""
else:
self.xmlnode = E.material(
E.instance_effect(url="#%s" % self.effect.id)
, id=str(self.id), name=str(self.name))
示例2: __init__
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()))))
示例3: __init__
def __init__(self, id, color, xmlnode = None):
"""Create a new ambient light.
:param str id:
A unique string identifier for the light
:param tuple color:
Either a tuple of size 3 containing the RGB color value
of the light or a tuple of size 4 containing the RGBA
color value of the light
:param xmlnode:
If loaded from xml, the xml node
"""
self.id = id
"""The unique string identifier for the light"""
self.color = color
"""Either a tuple of size 3 containing the RGB color value
of the light or a tuple of size 4 containing the RGBA
color value of the light"""
if xmlnode != None:
self.xmlnode = xmlnode
"""ElementTree representation of the light."""
else:
self.xmlnode = E.light(
E.technique_common(
E.ambient(
E.color(' '.join(map(str, self.color ) ))
)
)
, id=self.id, name=self.id)
示例4: __init__
def __init__(self, symbol, target, inputs, xmlnode = None):
"""Creates a material node
:param str symbol:
The symbol within a geometry this material should be bound to
:param collada.material.Material target:
The material object being bound to
:param list inputs:
A list of tuples of the form ``(semantic, input_semantic, set)`` mapping
texcoords or other inputs to material input channels, e.g.
``('TEX0', 'TEXCOORD', '0')`` would map the effect parameter ``'TEX0'``
to the ``'TEXCOORD'`` semantic of the geometry, using texture coordinate
set ``0``.
:param xmlnode:
When loaded, the xmlnode it comes from
"""
self.symbol = symbol
"""The symbol within a geometry this material should be bound to"""
self.target = target
"""An object of type :class:`collada.material.Material` representing the material object being bound to"""
self.inputs = inputs
"""A list of tuples of the form ``(semantic, input_semantic, set)`` mapping
texcoords or other inputs to material input channels, e.g.
``('TEX0', 'TEXCOORD', '0')`` would map the effect parameter ``'TEX0'``
to the ``'TEXCOORD'`` semantic of the geometry, using texture coordinate
set ``0``."""
if xmlnode is not None:
self.xmlnode = xmlnode
"""ElementTree representation of the material node."""
else:
self.xmlnode = E.instance_material(
*[E.bind_vertex_input(semantic=sem, input_semantic=input_sem, input_set=set)
for sem, input_sem, set in self.inputs]
, **{'symbol': self.symbol, 'target':"#%s"%self.target.id} )
示例5: __init__
def __init__(self, id, color, xmlnode=None):
"""Create a new sun light.
:Parameters:
id
Id for the object
color
Light color
xmlnode
If load form xml, the xml node
"""
self.id = id
"""Id in the light library."""
# TODO: check if this is actually the initial direction
self.direction = numpy.array([0, 0, 1], dtype=numpy.float32)
"""Incoming direction of the light."""
self.color = color
"""Light color."""
if xmlnode != None:
self.xmlnode = xmlnode
else:
self.xmlnode = E.light(
E.technique_common(E.directional(E.color(" ".join([str(v) for v in self.color])))),
id=self.id,
name=self.id,
)
示例6: save
def save(self):
"""Saves the geometry node back to :attr:`xmlnode`"""
self.xmlnode.set('url', "#%s" % self.geometry.id)
for m in self.materials:
m.save()
matparent = self.xmlnode.find('%s/%s'%( tag('bind_material'), tag('technique_common') ) )
if matparent is None and len(self.materials)==0:
return
elif matparent is None:
matparent = E.technique_common()
self.xmlnode.append(E.bind_material(matparent))
elif len(self.materials) == 0 and matparent is not None:
bindnode = self.xmlnode.find('%s' % tag('bind_material'))
self.xmlnode.remove(bindnode)
return
for m in self.materials:
if m.xmlnode not in matparent:
matparent.append(m.xmlnode)
xmlnodes = [m.xmlnode for m in self.materials]
for n in matparent:
if n not in xmlnodes:
matparent.remove(n)
示例7: getPropNode
def getPropNode(prop, value):
propnode = E(prop)
if type(value) is Map:
propnode.append(copy.deepcopy(value.xmlnode))
elif type(value) is float:
propnode.append(E.float(str(value)))
else:
propnode.append(E.color(' '.join(map(str, value) )))
return propnode
示例8: _recreateXmlNode
def _recreateXmlNode(self):
perspective_node = E.perspective()
if self.xfov is not None:
perspective_node.append(E.xfov(str(self.xfov)))
if self.yfov is not None:
perspective_node.append(E.yfov(str(self.yfov)))
if self.aspect_ratio is not None:
perspective_node.append(E.aspect_ratio(str(self.aspect_ratio)))
perspective_node.append(E.znear(str(self.znear)))
perspective_node.append(E.zfar(str(self.zfar)))
self.xmlnode = E.camera(
E.optics(
E.technique_common(perspective_node)
)
, id=self.id, name=self.id)
示例9: __init__
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 )
示例10: _recreateXmlNode
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))
示例11: _recreateXmlNode
def _recreateXmlNode(self):
self.xmlnode = E.asset()
for contributor in self.contributors:
self.xmlnode.append(contributor.xmlnode)
self.xmlnode.append(E.created(self.created.isoformat()))
if self.keywords is not None:
self.xmlnode.append(E.keywords(self.keywords))
self.xmlnode.append(E.modified(self.modified.isoformat()))
if self.revision is not None:
self.xmlnode.append(E.revision(self.revision))
if self.subject is not None:
self.xmlnode.append(E.subject(self.subject))
if self.title is not None:
self.xmlnode.append(E.title(self.title))
if self.unitmeter is not None and self.unitname is not None:
self.xmlnode.append(E.unit(name=self.unitname, meter=str(self.unitmeter)))
self.xmlnode.append(E.up_axis(self.upaxis))
示例12: save
def save(self):
"""Saves the surface data back to :attr:`xmlnode`"""
surfacenode = self.xmlnode.find( tag('surface') )
initnode = surfacenode.find( tag('init_from') )
if self.format:
formatnode = surfacenode.find( tag('format') )
if formatnode is None:
surfacenode.append(E.format(self.format))
else:
formatnode.text = self.format
initnode.text = self.image.id
self.xmlnode.set('sid', self.id)