def onCreateInstance(self, parent): # create instance of this class '''if filepath is not None: name = filepath.split('/')[-1] else: name = 'EggTexture' ''' print dir(parent), type(parent) modelWrapper = parent.modelWrapper # the default texture relativePath = posixpath.dirname(parent.getParentFilepath()) defaultTexturePath = relpath(relativePath, 'data/grid.png') eggTexture = EggTexture('texture', defaultTexturePath) eggTexture.setName('texture-%i' % hash(eggTexture)) #print "I: ObjectEggTexture.onCreateInstance:" #print " - parent:", parent #print " - name:", eggTexture.getName() # we need to insert the texture at the beginning... origChildrens = parent.eggData.getChildren() parent.eggData.addChild(eggTexture) for c in origChildrens: parent.eggData.removeChild(c) parent.eggData.addChild(c) #for parent.eggData #print " - parent.eggData:" print parent.eggData objectInstance = ObjectEggTexture(parent, modelWrapper, eggTexture) objectInstance.setPolygonGroup(parent.defaultPolygonGroup) return objectInstance
def setImageBasename(self, basename): self.stop() if basename: if basename[0] == '/': relativePath = posixpath.dirname(self.getParentFilepath()) basename = relpath(relativePath, posixpath.abspath(basename)) self.imageBasename = basename self.start()
def setTexture(self, filename): assert(type(filename) == Filename) filename = filename.getFullpath() print "I: ObjectEggTexture.setTexture:" print " - filename: ", filename print " - parentpath: ", self.getParentFilepath() if filename: if filename[0] == '/': relativePath = posixpath.dirname(self.getParentFilepath()) print " -", relativePath filename = posixpath.abspath(filename) print " -", filename filename = relpath(relativePath, filename) print "I: ObjectEggTexture.setTexture:", filename self.eggTexture.setFilename(Filename(filename)) # update the visual model self.stopEdit() self.modelWrapper.updateModelFromEggData() self.startEdit()
def setTex5(self, texPath): if texPath: if texPath[0] == "/": relativePath = posixpath.dirname(self.getParentFilepath()) texPath = relpath(relativePath, posixpath.abspath(texPath)) self.tex5Path = Filepath(texPath)
def setExternalReference(self, filepath, relativeTo, objectInstance): # convert to a relative path extRefPath = relpath(relativeTo, posixpath.abspath(filepath)) # add the reference to the egg-file extRef = EggExternalReference("ExtRef", extRefPath) objectInstance.addChild(extRef)
def setTex2(self, texPath): if texPath: if texPath[0] == '/': relativePath = posixpath.dirname(self.getParentFilepath()) texPath = relpath(relativePath, posixpath.abspath(texPath)) self.tex2Path = Filepath(texPath)