示例#1
0
文件: splat.py 项目: thuskey/Splat3D
    def loadModel(self,newname):
        
        if self.inkGender == 1:
            gen = 1
        else:
            gen = 0

        if newname == 'StartPos' and gen == 1:
            newname = 'Player01'
        if newname == 'StartPos' and gen == 0:
            newname = 'Player00'

        name = ReplaceModel(newname, gen)
        
        paths = ('/Model/',
               '/Pack/Obj/Model/',
               '/Pack/ObjSmall/Model/',
               '/Pack/Enemy/Model/',
               '/Pack/Player/Model/')
        
        for objpath in paths:
            base = window.gamePath + str(objpath) + str(name)
            if os.path.isfile(str(base) + '.sarc'):
                ext = '.sarc'
            elif os.path.isfile(str(base) + '.szs'):
                ext = '.szs'
            else:
                kind = '(skipped)'
                continue

            if base == window.gamePath + '/Pack/ObjSmall/Model/Obj_DemoPlayer':
                return self.cubeList
            
            if os.path.isfile(str(base) + str(ext)):
                with open(base + ext, 'rb') as f:
                    data = f.read()
                    print('Loading model ' + name + '!')   
                    if data.startswith(b'Yaz0'):
                        print('Decompressing Yaz0...')
                        yaz0archive = yaz0.decompress(data)
                        if b"Output.bfres" in yaz0archive:
                            bfres = sarc.extract(yaz0archive, 'Output.bfres')
                            model = fmdl.parse(bfres)
                            return self.generateList(model)
                        else:
                            return self.cubeList   
                    else:
                        print('Skipping yaz0 decompression')
                        sarchive = data
                        if b"Output.bfres" in sarchive:
                            bfres = sarc.extract(sarchive, 'Output.bfres')
                            model = fmdl.parse(bfres)
                            return self.generateList(model)
                        else:
                            return self.cubeList   
                    break              
        else:
            return self.cubeList         
示例#2
0
    def loadModel(self, newname):

        if self.inkGender == 1:
            gen = 1
        else:
            gen = 0

        if newname == 'StartPos' and gen == 1:
            newname = 'Player01'
        if newname == 'StartPos' and gen == 0:
            newname = 'Player00'

        name = ReplaceModel(newname, gen)

        paths = ('/Model/', '/Pack/Obj/Model/', '/Pack/ObjSmall/Model/',
                 '/Pack/Enemy/Model/', '/Pack/Player/Model/')

        for objpath in paths:
            base = window.gamePath + str(objpath) + str(name)
            if os.path.isfile(str(base) + '.sarc'):
                ext = '.sarc'
            elif os.path.isfile(str(base) + '.szs'):
                ext = '.szs'
            else:
                kind = '(skipped)'
                continue

            if base == window.gamePath + '/Pack/ObjSmall/Model/Obj_DemoPlayer':
                return self.cubeList

            if os.path.isfile(str(base) + str(ext)):
                with open(base + ext, 'rb') as f:
                    data = f.read()
                    print('Loading model ' + name + '!')
                    if data.startswith(b'Yaz0'):
                        print('Decompressing Yaz0...')
                        yaz0archive = yaz0.decompress(data)
                        if b"Output.bfres" in yaz0archive:
                            bfres = sarc.extract(yaz0archive, 'Output.bfres')
                            model = fmdl.parse(bfres)
                            return self.generateList(model)
                        else:
                            return self.cubeList
                    else:
                        print('Skipping yaz0 decompression')
                        sarchive = data
                        if b"Output.bfres" in sarchive:
                            bfres = sarc.extract(sarchive, 'Output.bfres')
                            model = fmdl.parse(bfres)
                            return self.generateList(model)
                        else:
                            return self.cubeList
                    break
        else:
            return self.cubeList
示例#3
0
    def loadModel(self,name):
        if not os.path.isfile(window.gamePath+'/mapobj/{0}/{0}.bfres'.format(name)):
            return self.cubeList
        
        with open(window.gamePath+'/mapobj/{0}/{0}.bfres'.format(name),'rb') as f:
            data = f.read()
        #with open(window.gamePath+'/race_common/{0}/{0}.bfres'.format(name),'rb') as f:
        #    data2 = f.read()            

        model = fmdl.parse(data)
        #model2 = fmdl.parse(data2)
        return self.generateList(model)
示例#4
0
    def loadModel(self,name):
        if not os.path.isfile(window.gamePath+'/ObjectData/'+name+'.szs'):
            return self.cubeList

        with open(window.gamePath+'/ObjectData/'+name+'.szs','rb') as f:
            data = f.read()

        sarchive = yaz0.decompress(data)
        if sarc.contains(sarchive,name+'.bfres'):
            bfres = sarc.extract(sarchive,name+'.bfres')
            model = fmdl.parse(bfres)
            return self.generateList(model)
        return self.cubeList
示例#5
0
    def loadModel(self, name):
        if not os.path.isfile(window.gamePath +
                              '/mapobj/{0}/{0}.bfres'.format(name)):
            return self.cubeList

        with open(window.gamePath + '/mapobj/{0}/{0}.bfres'.format(name),
                  'rb') as f:
            data = f.read()
        #with open(window.gamePath+'/race_common/{0}/{0}.bfres'.format(name),'rb') as f:
        #    data2 = f.read()

        model = fmdl.parse(data)
        #model2 = fmdl.parse(data2)
        return self.generateList(model)