def __init__(self, path=None, file=None): if path: self.reader = ByteIO(path=path + ".vvd") elif file: self.reader = file self.file_data = SourceVvdFileData() self.file_data.read(self.reader)
def __init__(self, filepath): try: from Source2.Blocks.NTRO import NTRO from Source2.Blocks.REDI import REDI from Source2.Blocks.RERP import RERL from Source2.Blocks.VBIB import VBIB from Source2.Blocks.DATA import DATA except: from .Blocks.NTRO import NTRO from .Blocks.REDI import REDI from .Blocks.RERP import RERL from .Blocks.VBIB import VBIB from .Blocks.DATA import DATA print('Reading {}'.format(filepath)) self.reader = ByteIO( path=filepath, copy_data_from_handle=False, ) self.filepath = Path(filepath) self.filename = self.filepath.stem self.filepath = os.path.abspath(os.path.dirname(filepath)) self.header = CompiledHeader() self.header.read(self.reader) self.blocks_info = [] # type: List[InfoBlock] self.rerl = RERL(self) self.nrto = NTRO(self) self.redi = REDI(self) self.vbib = VBIB(self) self.data = DATA(self) self.available_resources = {}
def __init__(self, filepath): self.reader = ByteIO(path=filepath + '.mdl', copy_data_from_handle=False, ) self.filename = os.path.basename(filepath + '.mdl')[:-4] self.file_data = SourceMdlFileDataV10() self.file_data.read(self.reader) self.read_bones() self.read_bone_controllers() self.read_skin_families()
def __init__(self, path=None, file=None): self.final = False if path: self.reader = ByteIO(path=path + ".dx90.vtx") elif file: self.reader = file # print('Reading VTX file') self.vtx = SourceVtxFileData() self.read_source_vtx_header()
def read(self, reader: ByteIO): self.count = reader.read_uint32() self.size = reader.read_uint32() self.unk1 = reader.read_uint32() self.unk2 = reader.read_uint32() entry = reader.tell() self.offset = reader.read_uint32() self.total_size = reader.read_uint32() with reader.save_current_pos(): reader.seek(entry + self.offset) assert self.total_size == self.size * self.count self.buffer = ByteIO(byte_object=reader.read_bytes(self.count * self.size)) self.read_buffer()
def read(self, reader: ByteIO): self.count = reader.read_uint32() self.size = reader.read_uint32() entry = reader.tell() self.attributes_offset = reader.read_uint32() self.attributes_count = reader.read_uint32() with reader.save_current_pos(): reader.seek(entry + self.attributes_offset) for _ in range(self.attributes_count): v_attrib = VertexAttribute() v_attrib.read(reader) self.attributes.append(v_attrib) entry = reader.tell() self.offset = reader.read_uint32() self.total_size = reader.read_uint32() with reader.save_current_pos(): reader.seek(entry + self.offset) assert self.total_size == self.size * self.count self.buffer = ByteIO(byte_object=reader.read_bytes(self.count * self.size)) self.read_buffer()
self.startBlah = 0 self.endBlah = 0 self.restIndex = 0 self.inputField = 0 self.unused = [] def read(self, reader: ByteIO, mdl: SourceMdlFileDataV10): self.boneIndex = reader.read_uint32() self.type = reader.read_uint32() self.startBlah = reader.read_uint32() self.endBlah = reader.read_uint32() self.restIndex = reader.read_uint32() self.inputField = reader.read_uint32() if mdl.version > 10: self.unused = [reader.read_uint32() for _ in range(8)] mdl.bone_controllers.append(self) return self def __str__(self): return '<BoneController bone index:{}>'.format(self.boneIndex) def __repr__(self): return '<BoneController bone index:{}>'.format(self.boneIndex) if __name__ == '__main__': model = r"E:\PYTHON\io_mesh_SourceMDL\test_data\goldSrc\leet.mdl" reader = ByteIO(path=model) mdl = SourceMdlFileDataV10() mdl.read(reader) mdl.print_info()
def __init__(self, block_info: InfoBlock = None): self.strings = [] self.info_block = block_info self.kv = [] self.flags = 0 self.buffer = ByteIO() # type: ByteIO