예제 #1
0
    def __init__(self, id, img, format=None, xmlnode=None):
        """Creates a surface.
        
        :param str id:
          A string identifier for the surface within the local scope of the material
        :param collada.material.CImage img:
          The image object
        :param str format:
          The format of the image
        :param xmlnode:
          If loaded from xml, the xml node
        
        """

        self.id = id
        """The string identifier for the surface within the local scope of the material"""
        self.image = img
        """:class:`collada.material.CImage` object from the image library."""
        self.format = format if format is not None else "A8R8G8B8"
        """Format string."""
        if xmlnode != None:
            self.xmlnode = xmlnode
            """ElementTree representation of the surface."""
        else:
            self.xmlnode = E.newparam(
                E.surface(
                    E.init_from(self.image.id),
                    E.format(self.format)
                , type="2D")
            , sid=self.id)
예제 #2
0
 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)