Exemple #1
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.index = s.i32()
     self.slot_target_namespace = s.zs()
     stream.seek(511 - len(self.slot_target_namespace), SEEK_CUR)
     self.slot_target_bone = s.zs()
     stream.seek(511 - len(self.slot_target_bone), SEEK_CUR)
Exemple #2
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     self.on_complete = [
         resources.get_block(s.u32(), DecisionGraphNode.get_node_types())
         for i in range(s.i32())
     ]
     DecisionGraphNode.read(self, stream, resources)
Exemple #3
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     flags = s.u8()
     self.type = (flags & 0x07) >> 0
     self.static = ((flags & 0x08) >> 3) == 1
     self.unknown = (flags & 0xF0) >> 4
     return self
Exemple #4
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     flags = s.u8()
     self.type = (flags & 0x07) >> 0
     self.static = ((flags & 0x08) >> 3) == 1
     self.unknown = (flags & 0xF0) >> 4
     return self
Exemple #5
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.index = s.i32()
     self.slot_target_namespace = s.zs()
     stream.seek(511 - len(self.slot_target_namespace), SEEK_CUR)
     self.slot_target_bone = s.zs()
     stream.seek(511 - len(self.slot_target_bone), SEEK_CUR)
Exemple #6
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     self.weight = s.f32()
     self.decision_graph_nodes = [
         resources.get_block(s.u32(),
                             DecisionGraphNode.get_node_types())
     ]
Exemple #7
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.next_state = rcol.get_block(s.u32(),
                                      DecisionGraphNode.get_node_types())
     DecisionGraphNode.read(self, stream, rcol)
Exemple #8
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.name = s.u32()
     self.start_index = s.i32()
     self.start_vertex = s.i32()
     self.vertex_count = s.i32()
     self.index_count = s.i32()
Exemple #9
0
 def read_rcol(self, stream, rcol):
     self.read_tag(stream)
     s = StreamReader(stream)
     self.version = s.u32()
     cBones = s.i32()
     names = [s.u32() for i in range(cBones)]
     poses = [s.m43() for pose_index in range(cBones)]
     self.bones = [self.Bone(names[i], poses[i]) for i in range(cBones)]
Exemple #10
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.version = s.u32()
     cNames = s.u32()
     for i in range(cNames):
         iid = s.u64()
         name = s.p32()
         self.names[iid] = name
Exemple #11
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.type = s.u32()
     self.origin = [s.f32() for i in range(3)]
     self.normal = [s.f32() for i in range(3)]
     self.x_axis = [s.f32() for i in range(3)]
     self.y_axis = [s.f32() for i in range(3)]
     self.pair_offset = s.f32()
Exemple #12
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.outcomes = [self.Outcome(stream, rcol) for i in range(s.i32())]
     assert s.u32() == DEADBEEF
     self.flags = s.u32()
     DecisionGraphNode.read(self, stream, rcol)
Exemple #13
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.version = s.u32()
     self.deltas = {}
     c = s.i32()
     for i in range(c):
         hsh = s.hash()
         self.deltas[hsh] = self.Delta(stream)
     pass
Exemple #14
0
    def read_rcol(self, stream, rcol):
        s = StreamReader(stream)
        self.read_tag(stream)
        self.version = s.u32()

        self.routing_slots = [RoutingSlot() for i in range(s.i32())]
        self.container_slots = [ContainerSlot() for i in range(s.i32())]
        self.effect_slots = [EffectSlot() for i in range(s.i32())]
        self.target_slots = [TargetSlot() for i in range(s.i32())]
        self.cone_slots = [ConeSlot() for i in range(s.i32())]

        def read_names(slots):
            for slot in slots: slot.name = s.hash(Slot.NAMES)

        def read_bones(slots):
            for slot in slots: slot.bone_name = s.u32()

        def read_transforms(slots):
            for slot in slots: slot.transform = s.m43()

        def read_offsets(slots):
            if any(slots):
                for i in range(s.i32()):
                    slots[i].offset = SlotOffset([s.f32(), s.f32(), s.f32()], [s.f32(), s.f32(), s.f32()])
                    pass
                pass

        read_names(self.routing_slots)
        read_bones(self.routing_slots)
        read_transforms(self.routing_slots)
        read_offsets(self.routing_slots)

        read_names(self.container_slots)
        read_bones(self.container_slots)
        for slot in self.container_slots:
            slot.flags = s.u32()
        read_transforms(self.container_slots)
        read_offsets(self.container_slots)

        read_names(self.effect_slots)
        read_bones(self.effect_slots)
        read_transforms(self.effect_slots)
        read_offsets(self.effect_slots)

        read_names(self.target_slots)
        read_bones(self.target_slots)
        read_transforms(self.target_slots)
        read_offsets(self.target_slots)

        read_names(self.cone_slots)
        read_bones(self.cone_slots)
        read_transforms(self.cone_slots)
        for cone_slot in self.cone_slots:
            cone_slot.radius = s.f32()
            cone_slot.angle = s.f32()
        read_offsets(self.cone_slots)
        pass
Exemple #15
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.version = s.u32()
     self.deltas = {}
     c = s.i32()
     for i in range(c):
         hsh = s.hash()
         self.deltas[hsh] = self.Delta(stream)
     pass
Exemple #16
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.bones = [self.parent.get_bone(s.i32()) for i in range(s.i32())]
     self.info_nodes = [self.parent.get_bone(s.i32()) for i in range(11)]
     self.pole = self.parent.get_bone(s.i32())
     self.slot_info = self.parent.get_bone(s.i32())
     self.slot_offset = self.parent.get_bone(s.i32())
     self.root = self.parent.get_bone(s.i32())
Exemple #17
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     assert s.u16() == self.TAG
     self.id = s.u32()
     self.time_code = s.f32()
     self.unknown1 = s.f32()
     self.unknown2 = s.f32()
     self.unknown3 = s.u32()
     length = s.u32()
     self.name = s.zs()
     assert len(self.name) == length
     s.align()
Exemple #18
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     self.version = s.u32()
     tgi = TGIList(package=resources)
     tgi.begin_read(stream)
     self.locale_key = s.u64()
     self.indexers = [tgi.get_resource(s.i32()) for i in range(s.i32())]
     self.is_bi_directional = bool(s.u32())
     self.cas_panel_group = s.u32()
     self.sort_index = s.i32()
     assert s.u32() == 0
     tgi.end_read(stream)
Exemple #19
0
    def read_rcol(self, stream, rcol):
        s = StreamReader(stream)
        self.read_tag(stream)
        self.version = s.u32()

        self.routing_slots = [RoutingSlot() for i in range(s.i32())]
        self.container_slots = [ContainerSlot() for i in range(s.i32())]
        self.effect_slots = [EffectSlot() for i in range(s.i32())]
        self.target_slots = [TargetSlot() for i in range(s.i32())]
        self.cone_slots = [ConeSlot() for i in range(s.i32())]

        def read_names(slots):
            for slot in slots: slot.name = s.hash(Slot.NAMES)

        def read_bones(slots):
            for slot in slots: slot.bone_name = s.u32()

        def read_transforms(slots):
            for slot in slots: slot.transform = s.m43()

        def read_offsets(slots):
            if any(slots):
                for i in range(s.i32()):
                    slots[i].offset = SlotOffset([s.f32(), s.f32(), s.f32()], [s.f32(), s.f32(), s.f32()])
                    pass
                pass

        read_names(self.routing_slots)
        read_bones(self.routing_slots)
        read_transforms(self.routing_slots)
        read_offsets(self.routing_slots)

        read_names(self.container_slots)
        read_bones(self.container_slots)
        for slot in self.container_slots:
            slot.flags = s.u32()
        read_transforms(self.container_slots)
        read_offsets(self.container_slots)

        read_names(self.effect_slots)
        read_bones(self.effect_slots)
        read_transforms(self.effect_slots)
        read_offsets(self.effect_slots)

        read_names(self.target_slots)
        read_bones(self.target_slots)
        read_transforms(self.target_slots)
        read_offsets(self.target_slots)

        read_names(self.cone_slots)
        read_bones(self.cone_slots)
        read_transforms(self.cone_slots)
        for cone_slot in self.cone_slots:
            cone_slot.radius = s.f32()
            cone_slot.angle = s.f32()
        read_offsets(self.cone_slots)
        pass
Exemple #20
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     self.version = s.u32()
     tgi = TGIList(package=resources)
     tgi.begin_read(stream)
     if self.version >= 0x00000003:
         self.presets = ProductBase.read_presets(stream,tgi)
     self.product_info = ProductInfo()
     self.product_info.read(stream,tgi)
     self.railing_4x_model = tgi.get_resource(s.i32())
     self.railing_1x_model = tgi.get_resource(s.i32())
     self.post_model = tgi.get_resource(s.i32())
     tgi.end_read(stream)
Exemple #21
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.framerate = s.f32()
     cFrames = s.i32()
     offsets = [s.u32() for i in range(cFrames)]
     offsets.append(-1)
     for frame_index in range(cFrames):
         offset = offsets[frame_index]
         next = offsets[frame_index + 1]
         cBytes = next - offset if next > 0 else -1
         data = stream.read(cBytes)
         self.frames.append(data)
Exemple #22
0
 def fix_read_offset(self, stream):
     s = StreamReader(stream)
     pos = stream.tell()
     fix_bytes = 0
     if pos % 2 == 0:
         fix_bytes = pos % 4
     else:
         fix_bytes = pos % 2
         if (pos + fix_bytes) % 2 == 0:
             fix_bytes += 2
     assert fix_bytes <= 3
     for i in range(fix_bytes):
         b = s.i8()
         assert b == i
Exemple #23
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.name = s.u32()
     self.properties = s.u32()
     self.decision_graph = rcol.get_block(s.u32(), DecisionGraph)
     self.transitions = [
         rcol.get_block(s.u32(), State) for i in range(s.i32())
     ]
     self.awareness_overlay_level = s.u32()
Exemple #24
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     assert s.u32() == 0
     self.swizzle_info = rcol.get_block(s.u32(), SwizzleInfo)
     start = stream.tell()
     stream.seek(0, SEEK_END)
     end = stream.tell()
     stream.seek(start, SEEK_SET)
     length = end - start
     self.buffer.stream.seek(0, SEEK_SET)
     self.buffer.stream.truncate()
     self.buffer.stream.write(stream.read(length))
     self.buffer.stream.seek(0, SEEK_SET)
Exemple #25
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     assert s.u32() == 0
     self.swizzle_info = rcol.get_block(s.u32(), SwizzleInfo)
     start = stream.tell()
     stream.seek(0, SEEK_END)
     end = stream.tell()
     stream.seek(start, SEEK_SET)
     length = end - start
     self.buffer.stream.seek(0, SEEK_SET)
     self.buffer.stream.truncate()
     self.buffer.stream.write(stream.read(length))
     self.buffer.stream.seek(0, SEEK_SET)
Exemple #26
0
 def read_presets(cls,stream,resources=None):
     s = StreamReader(stream)
     c = s.i32()
     ce = ComplateEncoder()
     presets = []
     for i in range(c):
         preset = cls.BuildBuyPreset()
         preset.unk1 = s.i8()
         if preset.unk1 != 1:
             preset.unk2 = s.i32()
         preset_ptr = StreamPtr.begin_read(s,relative=True,offset_start=True)
         preset.complate = ce.deserialize(stream,resources)
         preset_ptr.end()
         preset.id = s.u32()
         presets.append(preset)
     return presets
Exemple #27
0
 def read(self, stream, resources):
     s = StreamReader(stream)
     self.age_gender = s.u32()
     self.type_flags = s.u32()
     self.specular = resources.get_resource(s.u32())
     self.detail_dark = resources.get_resource(s.u32())
     self.detail_light = resources.get_resource(s.u32())
     self.normal = resources.get_resource(s.u32())
     self.overlay = resources.get_resource(s.u32())
Exemple #28
0
 def read(self, stream, resource=None):
     Light.read(self, stream)
     s = StreamReader(stream)
     self.at = [s.f32() for i in range(3)]
     self.right = [s.f32() for i in range(3)]
     self.width = s.f32()
     self.height = s.f32()
     self.falloff_angle = s.f32()
     self.window_top_bottom_angle = s.f32()
Exemple #29
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.name = s.u32()
     self.properties = s.u32()
     self.decision_graph = rcol.get_block(s.u32(), DecisionGraph)
     self.transitions = [rcol.get_block(s.u32(), State) for i in range(s.i32())]
     self.awareness_overlay_level = s.u32()
Exemple #30
0
 def read(self, stream, resources=None):
     s = StreamReader(stream)
     self.version = s.u32()
     tgi = TGIList()
     tgi.begin_read(stream)
     self.shader_keys = [self.ShaderKey(self, stream, tgi) for i in range(s.i32())]
     self.sub_skin_ramp = tgi.get_resource(s.u32())
     self.tone_ramp = tgi.get_resource(s.u32())
     self.texture_keys = [self.TextureKey(self, stream, tgi) for i in range(s.i32())]
     self.dominant = bool(s.u8())
Exemple #31
0
    def read(self, stream, resources=None):
        s = StreamReader(stream)
        s.version = s.u32()
        tgi = TGIList(package=resources)
        tgi.begin_read(stream)
        self.components = [s.hash(self.component_hashes) for i in range(s.i8())]
        self.component_data = {}

        def read_component_data():
            key = s.p32()
            val = None
            t = s.i8()
            if t == 0x00:
                val = t, s.p32()
            elif t == 0x01:
                val = t, tgi.get_resource(s.i32())
            elif t == 0x02:
                val = t, tgi.get_resource(s.i32())
            elif t == 0x03:
                val = t, s.p32()
            elif t == 0x04:
                val = t, s.u32()
            self.component_data[key] = val

        for i in range(s.i8()):
            read_component_data()
        self.visible = s.u8()
        tgi.end_read(stream)
        pass
Exemple #32
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.version = s.u32()
     self.deltas = [
         self.Item(s.u32(), [s.f32() for i in range(3)],
                   [s.f32() for i in range(3)], [s.f32() for i in range(4)])
     ]
Exemple #33
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     assert s.u32() == 0x00000000
     self.children = [
         rcol.get_block(s.u32(), DecisionGraphNode.get_node_types())
         for i in range(s.i32())
     ]
     self.parents = [
         rcol.get_block(s.u32(), DecisionGraphNode.get_node_types())
         for i in range(s.i32())
     ]
     assert s.u32() == DEADBEEF
Exemple #34
0
 def read(self, stream, cdi, floats):
     assert isinstance(cdi, CurveDataInfo)
     s = StreamReader(stream)
     self.data = []
     self.frame_index = s.u16()
     flags = s.u16()
     self.flags = flags >> 4
     if cdi.flags.type == CurveDataType.VECTOR3_INDEXED:
         for floatsRead in range(cdi.float_count()):
             index = s.u16()
             val = floats[index]
             if flags & 1 << floatsRead: val *= -1
             self.data.append(Frame.unpack(val, cdi.offset, cdi.scale))
     else:
         for packedRead in range(cdi.packed_count()):
             if cdi.flags.type == CurveDataType.VECTOR3_PACKED:
                 packed = s.u32()
             elif cdi.flags.type in (CurveDataType.VECTOR4_PACKED,
                                     CurveDataType.SCALAR):
                 packed = s.u16()
             else:
                 raise Exception("Unknown packed format type")
             for packedIndex in range(
                     int(cdi.float_count() / cdi.packed_count())):
                 floatIndex = packedIndex + packedRead
                 bitsPerFloat = cdi.bits_per_float()
                 maxPackedVal = math.pow(2, bitsPerFloat) - 1.0
                 mask = int(maxPackedVal) << (packedIndex * bitsPerFloat)
                 val = ((packed & mask) >>
                        (packedIndex * bitsPerFloat)) / maxPackedVal
                 if flags & 1 << floatIndex: val *= -1.0
                 self.data.append(Frame.unpack(val, cdi.offset, cdi.scale))
     return self
Exemple #35
0
 def read(self, stream, resources):
     s = StreamReader(stream)
     self.model = resources.get_block(s.u32(), ModelLod)
     self.flags = s.u32()
     self.id = s.u16()
     self.is_sunshadow = bool(s.u16())
     self.min_z = s.f32()
     self.max_z = s.f32()
Exemple #36
0
 def read(self, stream, resource=None):
     Light.read(self, stream)
     s = StreamReader(stream)
     self.at = [s.f32() for i in range(3)]
     self.falloff_angle = s.f32()
     self.shade_light_rig_multiplier = s.f32()
     self.bottom_angle = s.f32()
     self.shade_colour = [s.f32() for i in range(3)]
Exemple #37
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.parameter_index = s.i32()
     for item_index in range(s.i32()):
         item = self.Item()
         item.value = s.u32()
         for action_index in range(s.i32()):
             item.actions.append(
                 rcol.get_block(s.u32(),
                                DecisionGraphNode.get_node_types()))
         self.items.append(item)
     assert s.u32() == DEADBEEF
     DecisionGraphNode.read(self, stream, rcol)
Exemple #38
0
 def read(self, stream, resource=None):
     Event.read(self, stream)
     s = StreamReader(stream)
     self.prop_actor_name = s.u32()
     self.object_actor_name = s.u32()
     self.slot_name = s.u32()
     self.unknown4 = s.u32()
     self.matrix = [[s.f32() for i in range(4)] for i in range(4)]
Exemple #39
0
 def read_rcol(self, stream, rcol):
     self.read_tag(stream)
     s = StreamReader(stream)
     self.version = s.u32()
     self.rig.key = s.tgi('ITG')
     self.unknown = s.f32()
     for i in range(self.RESERVED_COUNT):
         self.reserved[i] = s.u8()
     cValues = s.u32()
     self.bone_weights = [0.0] * cValues
     for i in range(cValues):
         self.bone_weights[i] = s.f32()
Exemple #40
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.version = s.u32()
     names = [s.s7(16, '>') for i in range(s.u32())]
     poses = [[[s.f32() for j in range(3)] for i in range(4)]
              for pose_index in range(s.u32())]
     self.bones = [
         self.Bone(names[i], pose) for i, pose in enumerate(poses)
     ]
Exemple #41
0
 def read(self, stream, resource=None):
     Event.read(self, stream)
     s = StreamReader(stream)
     self.unknown4 = s.u32()
     self.unknown5 = s.u32()
     self.effect_name = s.u32()
     self.actor_name = s.u32()
     self.slot_name = s.u32()
     self.unknown6 = s.u32()
Exemple #42
0
 def read(self, stream, resource=None):
     Light.read(self, stream)
     s = StreamReader(stream)
     self.at = [s.f32() for i in range(3)]
     self.right = [s.f32() for i in range(3)]
     self.width = s.f32()
     self.height = s.f32()
     self.falloff_angle = s.f32()
     self.window_top_bottom_angle = s.f32()
Exemple #43
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.parameter_index = s.i32()
     for item_index in range(s.i32()):
         item = self.Item()
         item.value = s.u32()
         for action_index in range(s.i32()):
             item.actions.append(rcol.get_block(s.u32(), DecisionGraphNode.get_node_types()))
         self.items.append(item)
     assert s.u32() == DEADBEEF
     DecisionGraphNode.read(self, stream, rcol)
Exemple #44
0
 def read_rcol(self, stream, rcol):
     self.read_tag(stream)
     s = StreamReader(stream)
     self.version = s.u32()
     name = s.hash(self.NAMES)
     value = rcol.get_block(s.u32(), (MaterialDefinition, MaterialSet))
     self.default_material = self.Element(name, value)
     self.elements = []
     cItems = s.u32()
     for i in range(cItems):
         value = rcol.get_block(s.u32(), (MaterialDefinition, MaterialSet))
         name = s.hash(self.NAMES)
         self.elements.append(self.Element(name, value))
Exemple #45
0
    def read(self, stream, resources=None):
        s = StreamReader(stream)
        self.version = s.u32()
        tgi = TGIList(package=resources)
        tgi.begin_read(stream)
        self.product_info = ProductInfo()
        self.product_info.read(stream,tgi)

        self.fireplace_width = s.i8()
        self.mantle =  tgi.get_resource(s.i32())
        self.chimney_mantle =  tgi.get_resource(s.i32())
        self.chimney_full_level =  tgi.get_resource(s.i32())
        self.chimney_ground_level =  tgi.get_resource(s.i32())
        self.chimney_body =  tgi.get_resource(s.i32())
        self.chimney_top =  tgi.get_resource(s.i32())
        self.chimney_cap =  tgi.get_resource(s.i32())
        tgi.end_read(stream)
Exemple #46
0
    def deserialize(self, stream, parent_tgi):
        def read_element(s, tgi_list):
            def read_complate_string(s):
                a = s.i8()
                if not a: return None
                if a & 0x80: return s.chars(s.i8() if a & 0x40 else a & 0x3F)
                if a & 0x40: a = (a & 0x3F) + s.i8()
                return self.complate_string_lookup[a]

            def read_typecode(s, tgi_list):
                tc = s.u8()
                if tc == 1: return read_complate_string(s)
                elif tc == 0x02: return [s.u8() for i in range(4)]
                elif tc == 0x03: return tgi_list.get_resource(s.i8())
                elif tc == 0x04: return s.f32()
                elif tc == 0x05: return [s.f32() for i in range(2)]
                elif tc == 0x06: return [s.f32() for i in range(3)]
                elif tc == 0x07: return bool(s.i8())
                else: raise Exception("Unknown typecode %02X" % tc)

            element = Preset.Element()
            element.resource = tgi_list.get_resource(s.u8())
            element.name = read_complate_string(s)
            element.variable = read_complate_string(s)

            for i in range(s.i32()):
                name = read_complate_string(s)
                value = read_typecode(s, tgi_list)
                element.values[name] = value
            element.patterns = [
                read_element(s, tgi_list) for i in range(s.i32())
            ]
            return element

        s = StreamReader(stream)
        unk = s.i16()
        preset_tgi = TGIList(use_length=True)
        preset_tgi.begin_read(stream)
        element = read_element(s, preset_tgi)
        preset_tgi.end_read(stream)
        return element
Exemple #47
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.target = rcol.get_block(s.u32(), ActorDefinition)
     self.operation = s.u32()
     self.operand = s.u32()
     for i in range(3):
         assert s.u32() == 0
     MulticastDecisionGraphNode.read(self, stream, rcol)
Exemple #48
0
 def read_rcol(self, stream, rcol):
     s = StreamReader(stream)
     self.read_tag(stream)
     self.version = s.u32()
     self.actor = rcol.get_block(s.u32(), ActorDefinition)
     self.parameter = s.u32()
     self.prop = s.tgi('ITG')
     for i in range(4):
         assert s.u32() == 0
     MulticastDecisionGraphNode.read(self, stream, rcol)
Exemple #49
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.frame_data_ptr = StreamPtr.begin_read(s)
     self.track_key = s.u32()
     self.offset = s.f32()
     self.scale = s.f32()
     self.frame_count = s.u16()
     self.flags.read(stream)
     self.type = s.u8()
     return self
Exemple #50
0
    def read(self, stream, keys):
        s = StreamReader(stream)
        tag = s.chars(4)
        if not tag == self.TAG_TEXTURES or tag == self.TAG_NO_TEXTURES:
            raise IOError(
                "Invalid data, expected %s or %s, but got %s" % (self.TAG_TEXTURES, self.TAG_NO_TEXTURES, tag))
        zero = s.u32()
        assert zero == 0

        param_len = s.u32()
        cParams = s.i32()
        items = []
        for i in range(cParams):
            item = self.Item()
            item.read_pointer(stream)
            items.append(item)
        start = stream.tell()
        for item in items:
            self.__parameters[item.name] = item.read_data(stream, keys)
        end = stream.tell()
        assert (end - start) == param_len
Exemple #51
0
        def read(self, stream, resources=None):
            s = StreamReader(stream)
            self.rcol_version = s.u32()

            item_links = [ResourceKey(group=s.u32(), instance=s.u32(), type=s.i32()) for i in range(s.i32())]
            c = s.i32()
            ids = [s.u32() for i in range(c)]
            for i in range(c):
                pass
            pass
Exemple #52
0
 def read_rcol(self, stream, rcol):
     self.read_tag(stream)
     s = StreamReader(stream)
     self.version = s.u32()
     self.rig.key = s.tgi('ITG')
     self.unknown = s.f32()
     for i in range(self.RESERVED_COUNT): self.reserved[i] = s.u8()
     cValues = s.u32()
     self.bone_weights = [0.0] * cValues
     for i in range(cValues): self.bone_weights[i] = s.f32()
Exemple #53
0
 def read(self, stream, resource=None):
     s = StreamReader(stream)
     self.bones = []
     bone_count=s.i32()
     for i in range(bone_count):
         bone=self.parent.get_bone(s.i32())
         self.bones.append(bone)
     if self.parent.version_major >= 4:
         self.info_nodes = [self.parent.get_bone(s.i32()) for i in range(11)]
     self.pole = self.parent.get_bone(s.i32())
     if self.parent.version_major >= 4:
         self.slot_info = self.parent.get_bone(s.i32())
     self.slot_offset = self.parent.get_bone(s.i32())
     self.root = self.parent.get_bone(s.i32())
Exemple #54
0
 def read(self, stream, resources):
     s = StreamReader(stream)
     self.age_gender = s.u32()
     self.edge_color = s.u32()
     self.specular_color = s.u32()
     self.specular_power = s.f32()
     self.is_genetic = bool(s.u8())
Exemple #55
0
 def read(self, stream, cdi, floats):
     assert isinstance(cdi,CurveDataInfo)
     s = StreamReader(stream)
     self.data = []
     self.frame_index = s.u16()
     flags = s.u16()
     self.flags = flags >> 4
     if  cdi.flags.type == CurveDataType.VECTOR3_INDEXED:
         for floatsRead in range(cdi.float_count()):
             index = s.u16()
             val = floats[index]
             if flags & 1 << floatsRead: val *= -1
             self.data.append(Frame.unpack(val, cdi.offset, cdi.scale))
     else:
         for packedRead in range(cdi.packed_count()):
             if cdi.flags.type == CurveDataType.VECTOR3_PACKED:
                 packed = s.u32()
             elif cdi.flags.type in ( CurveDataType.VECTOR4_PACKED, CurveDataType.SCALAR):
                 packed = s.u16()
             else:
                 raise Exception("Unknown packed format type")
             for packedIndex in range(int(cdi.float_count() / cdi.packed_count())):
                 floatIndex = packedIndex + packedRead
                 bitsPerFloat = cdi.bits_per_float()
                 maxPackedVal = math.pow(2, bitsPerFloat) - 1.0
                 mask = int(maxPackedVal) << (packedIndex * bitsPerFloat)
                 val = ( (packed & mask) >> (packedIndex * bitsPerFloat)) / maxPackedVal
                 if flags & 1 << floatIndex: val *= -1.0
                 self.data.append(Frame.unpack(val, cdi.offset, cdi.scale))
     return self
Exemple #56
0
    def deserialize(self,stream,parent_tgi):
        def read_element(s,tgi_list):
            def read_complate_string(s):
                a = s.i8()
                if not a: return None
                if a & 0x80: return s.chars(s.i8() if a & 0x40 else a &0x3F)
                if a & 0x40: a = (a & 0x3F) + s.i8()
                return self.complate_string_lookup[a]
            def read_typecode(s,tgi_list):
                tc = s.u8()
                if   tc == 1: return read_complate_string(s)
                elif tc == 0x02: return [s.u8() for i in range(4)]
                elif tc == 0x03: return tgi_list.get_resource(s.i8())
                elif tc == 0x04: return s.f32()
                elif tc == 0x05: return [s.f32() for i in range(2)]
                elif tc == 0x06: return [s.f32() for i in range(3)]
                elif tc == 0x07: return bool(s.i8())
                else: raise Exception("Unknown typecode %02X"%tc)
            element = Preset.Element()
            element.resource = tgi_list.get_resource(s.u8())
            element.name = read_complate_string(s)
            element.variable = read_complate_string(s)

            for i in range(s.i32()):
                name = read_complate_string(s)
                value = read_typecode(s,tgi_list)
                element.values[name] =value
            element.patterns = [read_element(s,tgi_list) for i in range(s.i32())]
            return element
        s = StreamReader(stream)
        unk = s.i16()
        preset_tgi = TGIList(use_length=True)
        preset_tgi.begin_read(stream)
        element = read_element(s,preset_tgi)
        preset_tgi.end_read(stream)
        complate = ComplateElement()
        complate.preset = element
        complate.priority = unk
        return complate