def load(self): self.watcher_pmx = pmxutil.Pmxio() self.watcher_pmx.load(self.watcher_pmx_name) self.watcher_vmd = vmdutil.Vmdio() self.watcher_vmd.load(self.watcher_vmd_name) self.bone_defs[self.WATCHER] = self.watcher_pmx.get_elements('bones') self.watcher_motions = self.watcher_vmd.get_frames('bones') if self.target_vmd_name: self.target_vmd = vmdutil.Vmdio() self.target_vmd.load(self.target_vmd_name) if vmdutil.is_camera_header(self.target_vmd.header): self.target_mode = 'CAMERA' self.target_motions = self.target_vmd.get_frames('cameras') else: if not self.target_pmx_name: raise Exception('pmx not setted') else: self.target_pmx = pmxutil.Pmxio() self.target_pmx.load(self.target_pmx_name) self.target_mode = 'MODEL' self.target_motions = self.target_vmd.get_frames('bones') self.bone_defs[self.TARGET] = self.target_pmx.get_elements( 'bones') if self.watcher_extlink is not None: self.watcher_extlink_pmx = pmxutil.Pmxio() self.watcher_extlink_pmx.load(self.watcher_extlink[1]) self.watcher_extlink_vmd = vmdutil.Vmdio() self.watcher_extlink_vmd.load(self.watcher_extlink[2]) self.bone_defs[self.WATCHER_EX] = ( self.watcher_extlink_pmx.get_elements('bones'))
else: new_items = tuple(additional_items) disp_nodes[1] = disp_nodes[1]._replace(n_disp_node_items=len(new_items), disp_node_items=new_items) pmx.set_elements('disp_nodes', disp_nodes) return pmx def make_argumentparser(): parser = argparse.ArgumentParser() parser.add_argument('infile', nargs='?', type=argparse.FileType('rb'), default=sys.stdin.buffer, help='input pmx') parser.add_argument('outfile', nargs='?', type=argparse.FileType('wb'), default=sys.stdout.buffer, help='output pmx') return parser if __name__ == '__main__': parser = make_argumentparser() args = parser.parse_args() pmx = pmxutil.Pmxio() pmx.load_fd(args.infile) pmx = make_brj_pmx(pmx) pmx.store_fd(args.outfile)
def copy_bullets(): orig = pmxutil.Pmxio() orig.load(ORIG) for i, bone_name in enumerate(EDGE_BONES): orig.model_info = orig.model_info._replace(name_jp=bone_name) orig.store(COPY_TO.format(i))