Пример #1
0
 def __init__(self, xmlFiles):
     self.xmlStateGroups = XMLStateGroups()
     self.xmlMaterials = XMLMaterials(self.xmlStateGroups)
     self.xmlSegments = XMLSegments(self.xmlStateGroups)
     self.lights = []
     
     self.xmlModels = XMLModels(self.lights,
                                self.xmlSegments,
                                self.xmlStateGroups,
                                self.xmlMaterials)
     
     # join results from all files
     for f in xmlFiles:
         (stat, mat, seg, mod, lights) = _loadXMLModels(f)
         
         self.lights = unique( self.lights + lights)
         
         self.xmlStateGroups = self.xmlStateGroups.join(stat)
         
         self.xmlMaterials = self.xmlMaterials.join(mat)
         self.xmlMaterials.xmlStateGroups = self.xmlStateGroups
         
         self.xmlSegments = self.xmlSegments.join(seg)
         self.xmlSegments.xmlStateGroups = self.xmlStateGroups
         
         self.xmlModels = self.xmlModels.join(mod)
         self.xmlModels.xmlMaterials = self.xmlMaterials
         self.xmlModels.xmlSegments =self.xmlSegments
         self.xmlModels.xmlStateGroups = self.xmlStateGroups
         self.xmlModels.lights = self.lights
Пример #2
0
class XMLLoader(object):
    """
    interface for loading models from xml.
    """
    
    def __init__(self, xmlFiles):
        self.xmlStateGroups = XMLStateGroups()
        self.xmlMaterials = XMLMaterials(self.xmlStateGroups)
        self.xmlSegments = XMLSegments(self.xmlStateGroups)
        self.lights = []
        
        self.xmlModels = XMLModels(self.lights,
                                   self.xmlSegments,
                                   self.xmlStateGroups,
                                   self.xmlMaterials)
        
        # join results from all files
        for f in xmlFiles:
            (stat, mat, seg, mod, lights) = _loadXMLModels(f)
            
            self.lights = unique( self.lights + lights)
            
            self.xmlStateGroups = self.xmlStateGroups.join(stat)
            
            self.xmlMaterials = self.xmlMaterials.join(mat)
            self.xmlMaterials.xmlStateGroups = self.xmlStateGroups
            
            self.xmlSegments = self.xmlSegments.join(seg)
            self.xmlSegments.xmlStateGroups = self.xmlStateGroups
            
            self.xmlModels = self.xmlModels.join(mod)
            self.xmlModels.xmlMaterials = self.xmlMaterials
            self.xmlModels.xmlSegments =self.xmlSegments
            self.xmlModels.xmlStateGroups = self.xmlStateGroups
            self.xmlModels.lights = self.lights
    
    def __del__(self):
        self.xmlStateGroups.cleanup()
        self.xmlMaterials.cleanup()
        self.xmlSegments.cleanup()
        self.xmlModels.cleanup()
    
    def getModel(self, modelName):
        """
        returns instance for model with given name.
        """
        return loadXMLModel(self.xmlModels, modelName)