def write(self, stream, resource=None): s = StreamWriter(stream) s.hash(self.name) s.i32(self.start_index) s.i32(self.start_vertex) s.i32(self.vertex_count) s.i32(self.index_count)
def write(self, stream, resource=None): s = StreamWriter(stream) s.chars(self.TAG) s.u32(self.version) cBlends = len(self.blends) cLods = 0 if cBlends: len(self.blends[0].lods)
def write(self, stream, resource=None): s = StreamWriter(stream) s.u32(self.vertex_size) s.u32(self.vertex_count) s.u32(self.byte_offset) assert len(self.commands) == (int(self.vertex_size / 4)) for cmd in self.commands: s.u32(cmd)
def write(self, stream, resources=None): s = StreamWriter(stream) flags = 0 flags |= (self.type << 0) if self.static: flags |= (1 << 1) flags |= (self.unknown << 4) s.u8(flags) return self
def write_rcol(self, stream, rcol): self.write_tag(stream) s = StreamWriter(stream) s.u32(self.version) cBones = len(self.bones) s.i32(cBones) for i in range(cBones): s.hash(self.bones[i].name) for bone in self.bones: s.m43(bone.inverse_bind_pose)
def write(self, stream, resources=None): s = StreamWriter(stream) s.u32(self.version) tgi = TGIList() tgi.begin_write(stream) for shader_key in self.shader_keys: shader_key.write(stream, tgi) s.u32(tgi.get_resource_index(self.sub_skin_ramp)) s.u32(tgi.get_resource_index(self.tone_ramp)) for texture_key in self.texture_keys: texture_key.write(stream, tgi) s.u8(self.is_dominant)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.i32(len(self.outcomes)) for outcome in self.outcomes: outcome.write(stream, rcol) s.u32(DEADBEEF) s.u32(self.flags) DecisionGraphNode.write(self, stream, rcol)
def write(self, stream, resource=None): s = StreamWriter(stream) s.u32(self.type) for i in range(3): s.f32(self.origin[i]) for i in range(3): s.f32(self.normal[i]) for i in range(3): s.f32(self.x_axis[i]) for i in range(3): s.f32(self.y_axis[i]) s.f32(self.pair_offset)
def serialize(self,complate,stream,resources): def write_element(s,tgi_list): def write_complate_string(string,s): if not string: s.i8(0) return if string in self.complate_string_lookup: idx = self.complate_string_lookup[string] if idx > 0x40: s.i8(0x40) s.i8(idx &0x3F) else: x = len(string) pass def write_typecode(value,s,tgi_list): if isinstance(value,str): s.i8(0x01) write_complate_string(value,s) elif isinstance(value,list): if len(value) == 4: s.i8(0x02) for e in value: s.u8(e) elif len(value) == 2: s.i8(0x05) for e in value: s.f32(e) elif len(value) == 3: s.i8(0x06) for e in value: s.f32(e) elif isinstance(value,Resource): s.i8(0x03) s.i8(tgi_list.get_resource_index(value)) elif isinstance(value,float): s.i8(0x04) s.f32(value) elif isinstance(value,bool): s.i8(0x07) s.i8(1 if value else 0) else: raise Exception ("Unable to handle typecode data %" %value) pass pass assert isinstance(complate,ComplateElement) s= StreamWriter(stream) s.i16(complate.priority) preset_tgi = TGIList(use_length=True) preset_tgi.begin_write(stream) raise NotImplementedError()
def write_rcol(self, stream, rcol): self.write_tag(stream) s = StreamWriter(stream) s.u32(self.version) s.u32(self.flags) s.u32(self.unknown) last = 0 for i in range(len(self.buffer)): cur = self.buffer[i] if Flag.is_set(self.flags, self.FLAGS.DIFFERENCED_INDICES): cur -= last last = self.buffer[i] s.i32(cur) if Flag.is_set(self.flags, self.FLAGS.INDEX_32) else s.i16(cur)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.f32(self.framerate) cFrames = len(self.frames) s.i32(cFrames) data_pos = stream.tell() + (cFrames * 4) for frame in self.frames: s.u32(data_pos) data_pos += len(frame) for frame in self.frames: stream.write(frame)
def write(self, stream, resource=None): s = StreamWriter(stream) s.u8(self.level) s.u32(self.dest_texture) s.u8(len(self.assets)) for asset in self.assets: asset.write(stream)
def write(self, stream, resource=None): s = StreamWriter(stream) for i in range(3): s.f32(self.transform[i]) for i in range(3): s.f32(self.colour[i]) s.f32(self.intensity)
def write(self, stream, resource=None): Light.write(self, stream) s = StreamWriter(stream) for i in range(3): s.f32(self.at[i]) s.f32(self.tube_length) s.f32(self.blur_scale)
def write(self, stream, resource=None): s = StreamWriter(stream) keys = self.names.keys() s.u32(len(keys)) for key in keys: s.u64(key) s.p32(self.names[key])
def write(self, stream, resource=None): Light.write(self, stream) s = StreamWriter(stream) for i in range(3): s.f32(self.at[i]) s.f32(self.falloff_angle) s.f32(self.blur_scale)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.u32(0) s.u32(rcol.get_block_index(self.swizzle_info)) self.buffer.stream.seek(0, SEEK_SET) stream.write(self.buffer.stream.read())
def write(self, stream, resource=None): Light.write(self, stream) s = StreamWriter(stream) for i in range(3): s.f32(self.at[i]) for i in range(3): s.f32(self.right[i]) s.f32(self.radius)
def write(self, stream, resources=None): s = StreamWriter(stream) for i in range(3): s.f32(self.position[i]) for i in range(3): s.f32(self.scale[i]) for i in range(4): s.f32(self.orientation[i])
def write_rcol(self, stream, rcol): s = StreamWriter(stream) s.u32(self.version) s.i32(len(self.deltas)) for hash in self.deltas: delta = self.deltas[hash] s.u32(hash) delta.write(stream)
def write_presets(cls, stream,presets, resources): s = StreamWriter(stream) s.i32(len(presets)) ce = ComplateEncoder() for preset in presets: assert isinstance(preset,cls.BuildBuyPreset) s.i8(preset.unk1) if preset.unk1 != 1: s.i32(preset.unk2) preset_ptr = StreamPtr.begin_write(s) ce.serialize(preset.complate,stream,resources) preset_ptr.end() s.u32(preset.id)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) cFootprints = len(self.footprint_polygons) s.i8(cFootprints) for footprint_index in range(cFootprints): self.footprint_polygons[footprint_index].write_rcol(stream) cSlots = len(self.routing_slot_footprint_polygons) s.i8(cSlots) for slot_index in range(cSlots): self.routing_slot_footprint_polygons[slot_index].write_rcol(stream)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) cFootprints = len(self.footprint_polygons) s.i8(cFootprints) for footprint_index in range(cFootprints): self.footprint_polygons[footprint_index].write(stream) cSlots = len(self.routing_slot_footprint_polygons) s.i8(cSlots) for slot_index in range(cSlots): self.routing_slot_footprint_polygons[slot_index].write(stream)
def write_rcol(self, stream, rcol): self.write_tag(stream) s = StreamWriter(stream) s.u32(self.version) s.i32(len(self.meshes)) for mesh in self.meshes: mesh.write(stream, rcol)
def write(self, stream, resources=None): s = StreamWriter(stream) s.u32(self.version) tgi = TGIList() tgi.begin_write(stream) if self.version >= 0x00000003: ProductBase.write_presets(stream,self.presets,tgi) self.product_info.write(stream,tgi) s.i32(tgi.get_resource_index(self.railing_4x_model)) s.i32(tgi.get_resource_index(self.railing_1x_model)) s.i32(tgi.get_resource_index(self.post_model)) tgi.end_write(stream)
def write_pointer(self, stream): self.size32 = 1 t = type(self.value) if isinstance(self.value, list): self.size32 = len(self.value) t = type(self.value[0]) if t == float: self.type_code = self.TYPE.FLOAT elif t == int: self.type_code = self.TYPE.INT elif t == ExternalResource: self.type_code = self.TYPE.TEXTURE elif t == ResourceKey: self.size32 = 4 self.type_code = self.TYPE.TEXTURE else: raise NotImplementedError( "Serialization of type %s is not supported in this format!" % t) s = StreamWriter(stream) s.hash(self.name) s.u32(self.type_code) s.u32(self.size32) self.pointer = StreamPtr.begin_write(s)
def write_pointer(self, stream): self.size32 = 1 t = type(self.value) if isinstance(self.value, list): self.size32 = len(self.value) t = type(self.value[0]) if t == float: self.type_code = self.TYPE.FLOAT elif t == int: self.type_code = self.TYPE.INT elif t == ExternalResource: self.type_code = self.TYPE.TEXTURE elif t == ResourceKey: self.size32 = 4 self.type_code = self.TYPE.TEXTURE else: raise NotImplementedError("Serialization of type %s is not supported in this format!" % t) s = StreamWriter(stream) s.hash(self.name) s.u32(self.type_code) s.u32(self.size32) self.pointer = StreamPtr.begin_write(s)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.hash(self.name) s.i32(len(self.actors)) for actor in self.actors: s.u32(rcol.get_block_index(actor, ActorDefinition)) s.i32(len(self.parameters)) for parameter in self.parameters: s.u32(rcol.get_block_index(parameter, ParameterDefinition)) s.i32(len(self.states)) for state in self.states: s.u32(rcol.get_block_index(state, State)) s.i32(len(self.namespace_map)) for actor_pair in self.namespace_map: actor_pair.write(stream) s.u32(DEADBEEF) s.u32(self.flags) s.u32(self.default_priority) s.u32(self.awareness_overlay_level) for i in range(4): s.u32(0)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) AnimationNode.write_rcol(self, stream, rcol)
def write(self, stream, resources=None): s = StreamWriter(stream) s.hash(self.filename) s.hash(self.clip_actor) s.hash(self.jazz_actor)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.u32(rcol.get_block_index(self.actor)) s.u32(self.parameter) s.tgi(self.prop, 'ITG') for i in range(4): s.u32(0) MulticastDecisionGraphNode.write(self, stream, rcol)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.u32(rcol.get_block_index(self.target)) s.u32(self.operation) s.u32(self.operand) for i in range(3): s.u32(0) MulticastDecisionGraphNode.write(self, stream, rcol)
def write(self, stream, resource=None): s = StreamWriter(stream) self.bounds.clear() s.hash(self.name) s.i8(self.priority) s.u32(self.footprint_type_flags) s.i32(len(self.points)) for point in self.points: self.bounds.add(point) s.f32(point[0]) s.f32(point[1]) s.u32(self.allow_intersection_flags) s.u32(self.surface_type_flags) s.u32(self.surface_attribute_flags) s.i8(self.level_offset) if self.ftpt.version >= Footprint.VERSION.EXTENDED: s.f32(self.elevation_offset) self.bounds.write(stream)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.u32(rcol.get_block_index(self.next_state)) DecisionGraphNode.read(self, stream, rcol)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.hash(self.name) s.u32(self.properties) s.u32(rcol.get_block_index(self.decision_graph, DecisionGraph)) s.i32(len(self.transitions)) for transition in self.transitions: s.u32(rcol.get_block_index(transition, State)) s.u32(self.awareness_overlay_level)
def write(self, stream, resources=None): s = StreamWriter(stream) s.u8(self.index) s.u8(len(self.resources)) for resource in self.resources: s.u32(resources.get_resource_index(resource))
def write(self, stream, resource=None): Light.write(self, stream) s = StreamWriter(stream) for i in range(3): s.f32(self.at[i]) s.f32(self.falloff_angle) s.f32(self.shade_light_rig_multiplier) s.f32(self.bottom_angle) for i in range(3): s.f32(self.shade_colour[i])
def write_rcol(self, stream, rcol): self.write_tag(stream) s = StreamWriter(stream) s.u32(self.version) cLights = len(self.lights) cOccluders = len(self.occluders) s.u32(4 + (cLights * 128) + (cOccluders * 14)) s.u8(cLights) s.u8(cOccluders) s.u16(cOccluders * 14) for light in self.lights: start = stream.tell() light.write_rcol(stream) end = stream.tell() size = end - start blank = 128 - size dwords = int(blank / 4) for i in range(int(dwords)): s.u32(0) for occluder in self.occluders: occluder.write_rcol(stream)
def write_rcol(self, stream, rcol): self.write_tag(stream) s = StreamWriter(stream) s.u32(self.version) tgi = TGIList() tgi.begin_write(stream) s.u8(len(self.entries)) for entry in self.entries: s.u8(entry.TYPE) entry.write(stream, tgi) s.u8(2) self.bounds.write(stream) s.u32(self.flags) if self.routing_footprint.key != ResourceKey(): s.u8(1) s.tgi(self.routing_footprint.key, 'TGI') else: s.u8(0) tgi.end_write(stream)
def write(self, stream, tgi=None): s = StreamWriter(stream) s.u32(self.index) s.u32(tgi.get_resource_index(self.resource))
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) raise NotImplementedError()
def write_rcol(self, stream, rcol): s = StreamWriter(stream) self.write_tag(stream) s.u32(self.version) s.u32(0) s.i32(len(self.children)) for child in self.children: s.u32(rcol.get_block_index(child)) s.i32(len(self.parents)) for parent in self.parents: s.u32(rcol.get_block_index(parent)) s.u32(DEADBEEF)
def write_rcol(self, stream, rcol): s = StreamWriter(stream) def write_names(slots): for slot in slots: s.hash(slot.name) def write_bones(slots): for slot in slots: s.hash(slot.bone_name) def write_transforms(slots): for slot in slots: s.m43(slot.transform) def write_offsets(slots): if any(slots): s.i32(len(list(filter(lambda slot: slot.offset != None, slots)))) for i, slot in enumerate(slots): if slot.offset != None: s.i32(i) for i in range(3): s.i32(slot.offset.position) for i in range(3): s.i32(slot.offset.rotation) self.write_tag(stream) s.u32(self.version) s.i32(len(self.routing_slots)) s.i32(len(self.container_slots)) s.i32(len(self.effect_slots)) s.i32(len(self.target_slots)) s.i32(len(self.cone_slots)) write_names(self.routing_slots) write_bones(self.routing_slots) write_transforms(self.routing_slots) write_offsets(self.routing_slots) write_names(self.container_slots) write_bones(self.container_slots) for slot in self.container_slots: s.u32(slot.flags) write_transforms(self.container_slots) write_offsets(self.container_slots) write_names(self.effect_slots) write_bones(self.effect_slots) write_transforms(self.effect_slots) write_offsets(self.effect_slots) write_names(self.target_slots) write_bones(self.target_slots) write_transforms(self.target_slots) write_offsets(self.target_slots) write_names(self.cone_slots) write_bones(self.cone_slots) write_transforms(self.cone_slots) for slot in self.cone_slots: s.f32(slot.radius) s.f32(slot.angle) write_offsets(self.cone_slots)
def write(self, stream, resource=None): Light.write(self, stream) s = StreamWriter(stream) for i in range(3): s.f32(self.at[i]) for i in range(3): s.f32(self.right[i]) s.f32(self.width) s.f32(self.height) s.f32(self.falloff_angle) s.f32(self.window_top_bottom_angle)
def write(self, stream, resources=None): s = StreamWriter(stream) for val in self.min: s.f32(val) for val in self.max: s.f32(val)