Beispiel #1
0
 def read(self, reader: ByteIO):
     entry = reader.tell()
     self.content_relative_filename_offset = reader.read_int32()
     self.content_relative_filename = reader.read_from_offset(entry + self.content_relative_filename_offset,
                                                              reader.read_ascii_string)
     entry = reader.tell()
     self.content_search_path_offset = reader.read_int32()
     self.content_search_path = reader.read_from_offset(entry + self.content_search_path_offset,
                                                        reader.read_ascii_string)
Beispiel #2
0
 def read(self, reader: ByteIO):
     entry = reader.tell()
     self.name_offset = reader.read_int32()
     self.name = reader.read_from_offset(entry + self.name_offset,
                                                              reader.read_ascii_string)
     entry = reader.tell()
     self.value_offset = reader.read_int32()
     self.value = reader.read_from_offset(entry + self.value_offset,
                                         reader.read_ascii_string)
Beispiel #3
0
 def read(self, reader: ByteIO):
     entry = reader.tell()
     self.string_offset = reader.read_int32()
     self.string = reader.read_from_offset(entry + self.string_offset, reader.read_ascii_string)
     entry = reader.tell()
     self.compiler_identifier_offset = reader.read_int32()
     self.compiler_identifier = reader.read_from_offset(entry + self.compiler_identifier_offset,
                                                        reader.read_ascii_string)
     self.fingerprint = reader.read_uint32()
     self.user_data = reader.read_uint32()
Beispiel #4
0
 def read(self, reader: ByteIO, mdl: SourceMdlFileDataV10):
     self.boneOffset = reader.tell()
     self.name = reader.read_ascii_string(32)
     self.parentBoneIndex = reader.read_int32()
     self.flags = reader.read_int32()
     self.boneControllerIndex = [reader.read_int32() for _ in range(6)]
     self.position.read(reader)
     self.rotation.read(reader)
     self.scale = [reader.read_float() for _ in range(6)]
     mdl.bones.append(self)
Beispiel #5
0
 def read(self, reader: ByteIO):
     entry = reader.tell()
     self.parameter_name_offset = reader.read_int32()
     self.parameter_name = reader.read_from_offset(entry + self.parameter_name_offset,
                                                   reader.read_ascii_string)
     entry = reader.tell()
     self.parameter_type_offset = reader.read_int32()
     self.parameter_type = reader.read_from_offset(entry + self.parameter_type_offset,
                                                   reader.read_ascii_string)
     self.fingerprint = reader.read_uint32()
     self.fingerprint_default = reader.read_uint32()
Beispiel #6
0
 def read(self, reader: ByteIO, block_info: InfoBlock = None):
     self.info_block = block_info
     self.entry = reader.tell()
     self.resource_entry_offset = reader.read_int32()
     self.resource_count = reader.read_int32()
     with reader.save_current_pos():
         reader.seek(self.entry + self.resource_entry_offset)
         for n in range(self.resource_count):
             resource = RERLResource()
             resource.read(reader)
             self.resources.append(resource)
Beispiel #7
0
 def read(self, reader: ByteIO):
     entry = reader.tell()
     self.material_id = reader.read_int16()
     self.replacement_material_name_offset = reader.read_int32()
     self.replacement_material_name = reader.read_from_offset(self.replacement_material_name_offset,
                                                              reader.read_ascii_string)
     return self
Beispiel #8
0
 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)
Beispiel #9
0
    def read(self, reader: ByteIO, stripgroup: SourceVtxStripGroup):
        entry = reader.tell()
        self.index_count = reader.read_uint32()
        self.index_mesh_index = reader.read_uint32()
        self.vertex_count = reader.read_uint32()
        self.vertex_mesh_index = reader.read_uint32()
        self.bone_count = reader.read_uint16()
        self.flags = StripHeaderFlags(reader.read_uint8())
        self.bone_state_change_count = reader.read_uint32()
        self.bone_state_change_offset = reader.read_uint32()
        global extra_8
        if extra_8:
            self.topology_indices_count = reader.read_int32()
            self.topology_offset = reader.read_int32()
        # print('Strip end',reader.tell())

        stripgroup.vtx_strips.append(self)
Beispiel #10
0
 def read(self, reader: ByteIO):
     self.id = reader.read_uint64()
     entry = reader.tell()
     self.resource_name_offset = reader.read_int32()
     self.resource_name = reader.read_from_offset(entry + self.resource_name_offset,
                                                              reader.read_ascii_string)
     self.unk =reader.read_uint32()
     a = 5
Beispiel #11
0
    def read(self, reader: ByteIO, MDL: SourceMdlFileData):
        entry = reader.tell()
        self.entry = entry
        self.baseHeaderOffset = reader.read_int32()
        self.nameOffset = reader.read_int32()
        self.theName = reader.read_from_offset(entry + self.nameOffset, reader.read_ascii_string)
        self.fps = reader.read_float()
        self.flags = self.STUDIO(reader.read_uint32())
        self.frameCount = reader.read_uint32()
        self.movementCount = reader.read_uint32()
        self.movementOffset = reader.read_uint32()

        self.unused1 = [reader.read_uint32() for _ in range(6)]
        self.animBlock = reader.read_uint32()
        self.animOffset = reader.read_uint32()


        self.ikRuleCount = reader.read_uint32()
        self.ikRuleOffset = reader.read_uint32()
        self.animblockIkRuleOffset = reader.read_uint32()
        self.localHierarchyCount = reader.read_uint32()
        self.localHierarchyOffset = reader.read_uint32()


        self.sectionOffset = reader.read_uint32()
        self.sectionFrameCount = reader.read_uint32()

        self.spanFrameCount = reader.read_uint16()
        self.spanCount = reader.read_uint16()
        self.spanOffset = reader.read_uint32()
        self.spanStallTime = reader.read_float()
        self.fileOffsetStart2 = entry + self.spanOffset
        self.fileOffsetEnd2 = entry + self.spanOffset-1
        if self.spanFrameCount!=0 or self.spanCount!=0 or self.spanOffset!=0 or self.spanStallTime!=0:
            for bone_index in range(len(MDL.bones)):
                bone = MDL.bones[bone_index] #type: SourceMdlBone
                if bone.flags & SourceMdlBone.BONE_HAS_SAVEFRAME_POS:
                    self.fileOffsetEnd2 += self.spanCount * 6
                if bone.flags & SourceMdlBone.BONE_HAS_SAVEFRAME_ROT:
                    self.fileOffsetEnd2 += self.spanCount * 8




        return self
Beispiel #12
0
 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)
Beispiel #13
0
 def read(self, reader: ByteIO):
     entry = reader.tell()
     self.replacements_count = reader.read_int32()
     self.replacement_offset = reader.read_int32()
     with reader.save_current_pos():
         reader.seek(entry + self.replacement_offset)
         for _ in range(self.replacements_count):
             mat = MaterialReplacement()
             mat.read(reader)
             self.replacements.append(mat)
     return self
Beispiel #14
0
 def read(self, reader: ByteIO, block_info: InfoBlock = None):
     self.info_block = block_info
     self.introspection_version = reader.read_int32()
     entry = reader.tell()
     self.struct_offset = reader.read_int32()
     self.struct_count = reader.read_int32()
     with reader.save_current_pos():
         reader.seek(entry + self.struct_offset)
         for n in range(self.struct_count):
             struct = NTROStruct(self)
             struct.read(reader)
             self.structs.append(struct)
     entry = reader.tell()
     self.enum_offset = reader.read_int32()
     self.enum_count = reader.read_int32()
     with reader.save_current_pos():
         reader.seek(entry + self.enum_offset)
         for n in range(self.enum_count):
             enum = NTROEnum(self)
             enum.read(reader)
             self.enums.append(enum)
Beispiel #15
0
    def read_header01(self, reader: ByteIO):
        self.eye_position.read(reader)

        self.hull_min_position.read(reader)

        self.hull_max_position.read(reader)

        self.view_bounding_box_min_position.read(reader)

        self.view_bounding_box_max_position.read(reader)

        self.flags = reader.read_uint32()

        self.bone_count = reader.read_uint32()
        self.bone_offset = reader.read_uint32()

        self.bone_controller_count = reader.read_uint32()
        self.bone_controller_offset = reader.read_uint32()

        self.hitbox_set_count = reader.read_uint32()
        self.hitbox_set_offset = reader.read_uint32()

        self.local_sequence_count = reader.read_uint32()
        self.local_sequence_offset = reader.read_uint32()
        self.sequence_group_count = reader.read_uint32()
        self.sequence_group_offset = reader.read_uint32()

        self.texture_count = reader.read_uint32()
        self.texture_offset = reader.read_uint32()
        self.texture_data_offset = reader.read_int32()

        self.skin_reference_count = reader.read_uint32()
        self.skin_family_count = reader.read_uint32()
        self.skin_family_offset = reader.read_uint32()

        self.body_part_count = reader.read_uint32()
        self.body_part_offset = reader.read_uint32()

        self.local_attachment_count = reader.read_uint32()
        self.local_attachment_offset = reader.read_uint32()

        self.sound_table = reader.read_uint32()
        self.sound_index = reader.read_uint32()
        self.sound_groups = reader.read_uint32()
        self.sound_group_offset = reader.read_uint32()

        self.transitions_count = reader.read_uint32()
        self.transition_offset = reader.read_uint32()

        if self.body_part_count == 0 and self.local_sequence_count > 0:
            self.mdl_file_only_has_animations = True
Beispiel #16
0
    def parse(self, reader: ByteIO, parent=None, in_array=False):
        name = None
        parent = parent

        if not in_array:
            string_id = reader.read_uint32()
            name = "ERROR" if string_id == -1 else self.strings[string_id]
        add = lambda v: parent.update({name: v}
                                      ) if not in_array else parent.append(v)
        data_type = reader.read_int8()
        flag_info = KVFlag.Nothing
        if data_type & 0x80:
            data_type &= 0x7F
            flag_info = KVFlag(reader.read_int8())

        if data_type == KVType.NULL:
            add(None)
            return
        if data_type == KVType.BOOLEAN:
            add(reader.read_int8() > 0)
            return
        if data_type == KVType.INTEGER:
            add(reader.read_int64())
            return
        if data_type == KVType.DOUBLE:
            add(reader.read_double())
            return
        if data_type == KVType.STRING:
            string_id = reader.read_int32()
            if string_id == -1:
                add(None)
                return
            add(self.strings[string_id])
            return
        if data_type == KVType.ARRAY:
            size = reader.read_uint32()
            arr = []
            for _ in range(size):
                self.parse(reader, arr, True)
            add(arr)
            return
        if data_type == KVType.OBJECT:
            size = reader.read_uint32()
            tmp = {}
            for _ in range(size):
                self.parse(reader, tmp, False)
            add(tmp)
            if not parent:
                parent = tmp
        return parent
Beispiel #17
0
 def read(self, reader: ByteIO):
     self.introspection_version = reader.read_int32()
     self.s_id = reader.read_int32()
     entry = reader.tell()
     self.name_offset = reader.read_int32()
     self.name = reader.read_from_offset(entry + self.name_offset,
                                         reader.read_ascii_string)
     self.disc_crc = reader.read_int32()
     self.user_version = reader.read_int32()
     self.disc_size = reader.read_int16()
     self.aligment = reader.read_int16()
     self.base_struct_id = reader.read_int32()
     entry = reader.tell()
     self.field_offset = reader.read_int32()
     self.field_count = reader.read_int32()
     self.struct_flags = reader.read_int32()
     with reader.save_current_pos():
         reader.seek(entry + self.field_offset)
         for n in range(self.field_count):
             field = NTROStructField(self)
             field.read(reader)
             self.fields.append(field)
Beispiel #18
0
 def read_from_buffer(self, reader: ByteIO):
     if self.format == DXGI_FORMAT.R32G32B32_FLOAT:
         return [
             reader.read_float()
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R32G32B32_UINT:
         return [
             reader.read_uint32()
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R32G32B32_SINT:
         return [
             reader.read_int32()
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R32G32B32A32_FLOAT:
         return [
             reader.read_float()
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R32G32B32A32_UINT:
         return [
             reader.read_uint32()
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R32G32B32A32_SINT:
         return [
             reader.read_int32()
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R16G16_FLOAT:
         return [
             short_to_float(reader.read_int16())
             for _ in range(self.format.name.count('16'))
         ]
     elif self.format == DXGI_FORMAT.R32G32_FLOAT:
         return [
             short_to_float(reader.read_float())
             for _ in range(self.format.name.count('32'))
         ]
     elif self.format == DXGI_FORMAT.R16G16_SINT:
         return [
             reader.read_int16()
             for _ in range(self.format.name.count('16'))
         ]
     elif self.format == DXGI_FORMAT.R16G16_UINT:
         return [
             reader.read_uint16()
             for _ in range(self.format.name.count('16'))
         ]
     elif self.format == DXGI_FORMAT.R8G8B8A8_SNORM:
         return [
             reader.read_int8() for _ in range(self.format.name.count('8'))
         ]
     elif self.format == DXGI_FORMAT.R8G8B8A8_UNORM:
         return [
             reader.read_uint8() for _ in range(self.format.name.count('8'))
         ]
     elif self.format == DXGI_FORMAT.R8G8B8A8_UINT:
         return [
             reader.read_uint8() for _ in range(self.format.name.count('8'))
         ]
     else:
         raise NotImplementedError('Unknown buffer format {}'.format(
             self.format.name))
Beispiel #19
0
    def read(self,reader:ByteIO,mdl:SourceMdlFileData):
        entry = reader.tell()
        self.baseHeaderOffset = reader.read_int32()
        self.nameOffset = reader.read_uint32()
        self.theName = reader.read_from_offset(entry+self.nameOffset,reader.read_ascii_string)
        self.activityNameOffset = reader.read_uint32()
        self.theActivityName = reader.read_from_offset(entry+self.activityNameOffset,reader.read_ascii_string)
        self.flags = reader.read_uint32()
        self.activity = reader.read_int32()
        self.activityWeight = reader.read_uint32()
        self.eventCount = reader.read_uint32()
        self.eventOffset = reader.read_uint32()
        self.bbMin.read(reader)
        self.bbMax.read(reader)
        self.blendCount = reader.read_uint32()
        self.animIndexOffset = reader.read_uint32()
        self.movementIndex = reader.read_uint32()
        self.groupSize = [reader.read_uint32() for _ in range(2)]
        self.paramIndex = [reader.read_int32() for _ in range(2)]
        self.paramStart = [reader.read_uint32() for _ in range(2)]
        self.paramEnd = [reader.read_uint32() for _ in range(2)]
        self.paramParent = reader.read_uint32()
        self.fadeInTime = reader.read_float()
        self.fadeOutTime = reader.read_float()
        self.localEntryNodeIndex = reader.read_uint32()
        self.localExitNodeIndex = reader.read_uint32()
        self.nodeFlags = reader.read_uint32()
        self.entryPhase = reader.read_float()
        self.exitPhase = reader.read_float()
        self.lastFrame = reader.read_float()
        self.nextSeq = reader.read_uint32()
        self.pose = reader.read_uint32()

        self.ikRuleCount = reader.read_uint32()
        self.autoLayerCount = reader.read_uint32()
        self.autoLayerOffset = reader.read_uint32()
        self.weightOffset = reader.read_uint32()
        self.poseKeyOffset = reader.read_uint32()

        self.ikLockCount = reader.read_uint32()
        self.ikLockOffset = reader.read_uint32()
        self.keyValueOffset = reader.read_uint32()
        self.keyValueSize = reader.read_uint32()
        self.cyclePoseIndex = reader.read_uint32()
        if mdl.version == 49:
            self.activityModifierOffset = reader.read_int32()
            self.activityModifierCount = reader.read_uint32()
            self.unused = [reader.read_uint32() for _ in range(5)]
        else:
            self.unused = [reader.read_uint32() for _ in range(7)]

        if self.groupSize[0] > 1 and self.groupSize[1] > 1 and self.poseKeyOffset !=0:
            with reader.save_current_pos():
                reader.seek(entry+self.poseKeyOffset)
                for _ in range(self.groupSize[0]+self.groupSize[1]):
                    self.thePoseKeys.append(reader.read_float())
        if self.eventCount > 0 and self.eventOffset!=0:
            with reader.save_current_pos():
                reader.seek(entry+self.eventOffset)
                for _ in range(self.eventCount):
                    self.theEvents.append(SourceMdlEvent().read(reader))


        return self