def read(self, reader: ByteIO): entry = reader.tell() self.name = reader.read_ascii_string() reader.seek(entry + 36) self.format = DXGI_FORMAT(reader.read_int32()) self.offset = reader.read_uint32() reader.skip(12)
def read(self, reader: ByteIO, block_info: InfoBlock = None): self.info_block = block_info entry = reader.tell() self.name_offset = reader.read_int32() self.name = reader.read_from_offset(entry + self.name_offset, reader.read_ascii_string) self.count = reader.read_int16() self.on_disc_size = reader.read_int16() entry = reader.tell() self.indirection_bytes_offset = reader.read_int32() self.indirection_level = reader.read_int32() with reader.save_current_pos(): reader.seek(entry + self.indirection_bytes_offset) indir_level = self.indirection_level if self.indirection_level < 10 else 10 for _ in range(indir_level): self.indirection_bytes.append(reader.read_int8()) self.data_type = reader.read_int32() self.type = KeyValueDataType(reader.read_int16()) reader.skip(2)
def read(self, frame_count, anim_section, mdl: SourceMdlFileData, reader: ByteIO): anim_entry = reader.tell() self.boneIndex = reader.read_uint8() print('BoneIndex:',self.boneIndex) try: self.bone_name = mdl.bones[self.boneIndex].name except: self.bone_name = "ERROR" print('BoneName:',self.bone_name) if self.boneIndex == 255: reader.skip(3) return self, 0 if self.boneIndex >= mdl.bone_count: print('Bone index out of range {} - {}'.format(self.boneIndex, mdl.bone_count)) return self, 0 self.flags = reader.read_uint8() self.sflags = self.STUDIO_ANIM.get_flags(self.flags) self.nextSourceMdlAnimationOffset = reader.read_int16() pdata = reader.tell() print('Seq flag',self.flags,self.sflags) if (self.flags & self.STUDIO_ANIM.RAWROT2) > 0: with reader.save_current_pos(): reader.seek(pdata) self.theRot64bits.read(reader) print('Rot 64',self.theRot64bits) if (self.flags & self.STUDIO_ANIM.RAWROT) > 0: with reader.save_current_pos(): reader.seek(pdata) self.theRot48bits.read(reader) print('Rot 48', self.theRot48bits) if (self.flags & self.STUDIO_ANIM.RAWPOS) > 0: with reader.save_current_pos(): reader.seek(pdata+(((self.flags & self.STUDIO_ANIM.RAWROT) != 0)*6) + ((self.flags & self.STUDIO_ANIM.RAWROT2) != 0)*8) self.thePos.read(reader) print('Pos', self.thePos) if (self.flags & self.STUDIO_ANIM.ANIMROT) > 0: with reader.save_current_pos(): rotV_entry = reader.tell() reader.seek(pdata) self.theRotV.read(reader) self.theRotV.read_values(rotV_entry, frame_count, reader) print('Rot V', self.theRotV) if (self.flags & self.STUDIO_ANIM.ANIMPOS) > 0: with reader.save_current_pos(): reader.seek(((self.flags & self.STUDIO_ANIM.ANIMPOS)!=0) + pdata) posV_entry = reader.tell() self.thePosV.read(reader) self.thePosV.read_values(posV_entry, frame_count, reader) print('Pos V', self.thePosV) print('\n') pprint(self.__dict__) print('\n') if self.nextSourceMdlAnimationOffset == 0: print('DONE WITH ANIMATIONS') reader.seek(pdata) return self, -1 else: nextAnimationInputFileStreamPosition = anim_entry + self.nextSourceMdlAnimationOffset if nextAnimationInputFileStreamPosition < reader.tell(): print('PROBLEM! Should not be going backwards in file.') # raise BufferError('PROBLEM! Should not be going backwards in file.') reader.seek(nextAnimationInputFileStreamPosition) anim_section.append(self) return self, 1