def pack(self, writer: BinaryWriter, color_is_argb: bool): """Nothing to reserve.""" if color_is_argb: color = (self.color.alpha, self.color.red, self.color.green, self.color.blue) else: color = (self.color.blue, self.color.green, self.color.red, self.color.alpha) writer.pack_struct(self.STRUCT, self, __color=color)
def pack(self, writer: BinaryWriter): writer.pack_struct( self.STRUCT, self, __member_count=len(self.members), __member_offset=writer.AUTO_RESERVE, )
def pack(self, writer: BinaryWriter): writer.pack_struct( self.STRUCT, self, __size=len(self.data) + self.STRUCT.size, ) writer.append(self.data)
def pack( self, writer: BinaryWriter, dummy_count: int, material_count: int, bone_count: int, mesh_count: int, vertex_buffer_count: int, face_set_count: int, buffer_layout_count: int, texture_count: int, true_face_count: int, total_face_count: int, vertex_indices_size: int, ): """All fields are static or can be immediately updated, except the few reserved below.""" self.dummy_count = dummy_count self.material_count = material_count self.bone_count = bone_count self.mesh_count = mesh_count self.vertex_buffer_count = vertex_buffer_count self.face_set_count = face_set_count self.buffer_layout_count = buffer_layout_count self.texture_count = texture_count self.true_face_count = true_face_count self.total_face_count = total_face_count self.vertex_indices_size = vertex_indices_size writer.pack_struct( self.STRUCT, self, vertex_data_offset=writer.AUTO_RESERVE, vertex_data_size=writer.AUTO_RESERVE, )
def pack(self): writer = BinaryWriter(big_endian=self.big_endian) writer.pack_struct(self.HEADER_STRUCT, goal_count=len(self.goals)) goal_struct = self.GOAL_STRUCT_64 if self.use_struct_64 else self.GOAL_STRUCT_32 packed_strings_offset = writer.position + len( self.goals) * goal_struct.size packed_goals = b"" packed_strings = b"" encoding = self.encoding z_term = b"\0\0" if self.use_struct_64 else b"\0" for goal in self.goals: name_offset = packed_strings_offset + len(packed_strings) packed_strings += goal.goal_name.encode(encoding=encoding) + z_term goal_kwargs = goal.get_interrupt_details() logic_interrupt_name = goal_kwargs.pop("logic_interrupt_name") if logic_interrupt_name: logic_interrupt_name_offset = packed_strings_offset + len( packed_strings) packed_strings += logic_interrupt_name.encode( encoding=encoding) + z_term else: logic_interrupt_name_offset = 0 packed_goals += goal_struct.pack( goal_id=goal.goal_id, name_offset=name_offset, logic_interrupt_name_offset=logic_interrupt_name_offset, **goal_kwargs, ) writer.append(packed_goals) writer.append(packed_strings) return writer.finish()
def pack(self, writer: BinaryWriter, vertex_index_size: int): writer.pack_struct( self.STRUCT, self, __vertex_indices_count=len(self.vertex_indices), __vertex_indices_offset=writer.AUTO_RESERVE, __vertex_indices_length=len(self.vertex_indices) * vertex_index_size // 8, __vertex_index_size=vertex_index_size, )
def pack(self, writer: BinaryWriter): writer.pack_struct( self.STRUCT, self, __name__z=writer.AUTO_RESERVE, __mtd_path__z=writer.AUTO_RESERVE, _first_texture_index=writer.AUTO_RESERVE, __gx_offset=writer.AUTO_RESERVE, _texture_count=len(self.textures), )
def pack(self, writer: BinaryWriter): writer.pack_struct( self.STRUCT, self, __bounding_box_offset=writer.AUTO_RESERVE, __bone_count=len(self.bone_indices), __bone_offset=writer.AUTO_RESERVE, __face_set_count=len(self.face_sets), __face_set_offset=writer.AUTO_RESERVE, __vertex_buffer_count=len(self.vertex_buffers), __vertex_buffer_offset=writer.AUTO_RESERVE, )
def pack( self, writer: BinaryWriter, version: Version, mesh_vertex_buffer_index: int, buffer_layouts: list[BufferLayout], mesh_vertex_count: int, ): layout_size = buffer_layouts[self.layout_index].get_total_size() writer.pack_struct( self.STRUCT, self, _buffer_index=mesh_vertex_buffer_index, _vertex_size=layout_size, vertex_count=mesh_vertex_count, _buffer_length=layout_size * mesh_vertex_count if version >= 0x20005 else 0, _buffer_offset=writer.AUTO_RESERVE, )
def pack(self, writer: BinaryWriter, struct_offset: int): writer.pack_struct( self.STRUCT, self, __struct_offset=struct_offset, )