def write_mdx(self, stream: BinaryStream, version): stream.write_uint32(self.get_byte_length()) super().write_mdx(stream, version) stream.write(self.path) stream.skip(260 - len(self.path)) stream.write_int32(self.attachment_id) self.write_non_generic_animation_chunks(stream)
def write_mdx(self, stream: BinaryStream): stream.write(self.name) stream.skip(80 - len(self.name)) stream.write_uint32_array(self.interval) stream.write_float32(self.move_speed) stream.write_uint32(self.flags) stream.write_float32(self.rarity) stream.write_uint32(self.sync_point) self.extent.write_mdx(stream)
def write_mdx(self, stream: BinaryStream, version): stream.write_uint32(self.get_generic_byte_length()) stream.write(self.name) stream.skip(80 - len(self.name)) stream.write_int32(self.object_id) stream.write_int32(self.parent_id) stream.write_uint32(self.flags) for animation in self.each_animation(True): animation.write_mdx(stream)
def save_model_chunk(self, stream: BinaryStream): stream.write('MODL') stream.write_uint32(372) stream.write(self.name) stream.skip(80 - len(self.name)) stream.write(self.animation_file) stream.skip(260 - len(self.animation_file)) self.extent.write_mdx(stream) stream.write_uint32(self.blend_time)
def write_mdx(self, stream: BinaryStream, version): stream.write_uint32(self.get_byte_length(version=version)) stream.write(self.name) stream.skip(80 - len(self.name)) stream.write_float32_array(self.position) stream.write_float32(self.field_of_view) stream.write_float32(self.far_clipping_plane) stream.write_float32(self.near_clipping_plane) stream.write_float32_array(self.target_position) self.write_animations(stream)
def write_mdx(self, stream: BinaryStream, version: int): stream.write_uint32(self.get_byte_length(version)) stream.write_int32(self.priority_plane) stream.write_uint32(self.flags) if version > 800: stream.write(self.shader) stream.skip(80 - len(self.shader)) stream.write('LAYS') stream.write_uint32(len(self.layers)) for layer in self.layers: layer.write_mdx(stream, version)
def read_mdx(self, stream: BinaryStream, version: int): stream.read_uint32() self.priority_plane = stream.read_int32() self.flags = stream.read_uint32() if version > 800: self.shader = stream.read(80) stream.skip(4) # LAYS for i in range(stream.read_uint32()): layer = Layer() layer.read_mdx(stream, version) self.layers.append(layer)
def write_mdx(self, stream: BinaryStream, version): stream.write_int32(self.get_byte_length()) super().write_mdx(stream, version) stream.write_float32(self.emission_rate) stream.write_float32(self.gravity) stream.write_float32(self.longitude) stream.write_float32(self.latitude) stream.write(self.path) stream.skip(260 - len(self.path)) stream.write_float32(self.life_span) stream.write_float32(self.speed) self.write_non_generic_animation_chunks(stream)
def write_mdx(self, stream: BinaryStream, version: int): stream.write_uint32(self.get_byte_length(version)) stream.write('VRTX') stream.write_uint32(len(self.vertices) // 3) stream.write_float32_array(self.vertices) stream.write('NRMS') stream.write_uint32(len(self.normals) // 3) stream.write_float32_array(self.normals) stream.write('PTYP') stream.write_uint32(len(self.face_type_groups)) stream.write_uint32_array(self.face_type_groups) stream.write('PCNT') stream.write_uint32(len(self.face_groups)) stream.write_uint32_array(self.face_groups) stream.write('PVTX') stream.write_uint32(len(self.faces)) stream.write_uint16_array(self.faces) stream.write('GNDX') stream.write_uint32(len(self.vertex_groups)) stream.write_uint8_array(self.vertex_groups) stream.write('MTGC') stream.write_uint32(len(self.matrix_groups)) stream.write_uint32_array(self.matrix_groups) stream.write('MATS') stream.write_uint32(len(self.matrix_indices)) stream.write_uint32_array(self.matrix_indices) stream.write_uint32(self.material_id) stream.write_uint32(self.selection_group) stream.write_uint32(self.selection_flags) if version > 800: stream.write_int32(self.lod) stream.write(self.lod_name) stream.skip(80 - len(self.lod_name)) self.extent.write_mdx(stream) stream.write_uint32(len(self.sequence_extents)) for sequence_extent in self.sequence_extents: sequence_extent.write_mdx(stream) if version > 800: if len(self.tangents): stream.write('TANG') stream.write_uint32(len(self.tangents) // 4) stream.write_float32_array(self.tangents) if len(self.skin): stream.write('SKIN') stream.write_uint32(len(self.skin)) stream.write_uint8_array(self.skin) stream.write('UVAS') stream.write_uint32(len(self.uv_sets)) for uv_set in self.uv_sets: stream.write('UVBS') stream.write_uint32(len(uv_set) // 2) stream.write_float32_array(uv_set)
def write_mdx(self, stream: BinaryStream, version): stream.write_uint32(self.get_byte_length()) super().write_mdx(stream, version) stream.write_float32(self.life_span) stream.write_float32(self.emission_rate) stream.write_float32(self.speed) stream.write_float32_array(self.color) stream.write_float32(self.alpha) stream.write_uint32(self.replaceable_id) stream.write(self.path) stream.skip(260 - len(self.path)) stream.write(self.animation_visibility_guide) stream.skip(260 - len(self.animation_visibility_guide)) self.write_non_generic_animation_chunks(stream)
def read_mdx(self, stream: BinaryStream, version): super().read_mdx(stream, version) stream.skip(4) # KEVT TAG count = stream.read_uint32() self.global_sequence_id = stream.read_int32() self.tracks = stream.read_uint32_array(count)
def write_mdx(self, stream: BinaryStream): stream.write(self.type) stream.skip(80 - len(self.type)) stream.write(self.path) stream.skip(260 - len(self.path))
def read_mdx(self, stream: BinaryStream, version: int): stream.read_uint32() stream.skip(4) # VRTX TAG self.vertices = stream.read_float32_array(stream.read_uint32() * 3) stream.skip(4) # NRMS TAG self.normals = stream.read_float32_array(stream.read_uint32() * 3) stream.skip(4) # PTYP TAG self.face_type_groups = stream.read_uint32_array(stream.read_uint32()) stream.skip(4) # PCNT TAG self.face_groups = stream.read_uint32_array(stream.read_uint32()) stream.skip(4) # PVTX TAG self.faces = stream.read_uint16_array(stream.read_uint32()) stream.skip(4) # GNDX TAG self.vertex_groups = stream.read_uint8_array(stream.read_uint32()) stream.skip(4) # MTGC TAG self.matrix_groups = stream.read_uint32_array(stream.read_uint32()) stream.skip(4) # MATS TAG self.matrix_indices = stream.read_uint32_array(stream.read_uint32()) self.material_id = stream.read_uint32() self.selection_group = stream.read_uint32() self.selection_flags = stream.read_uint32() if version > 800: self.lod = stream.read_int32() self.lod_name = stream.read(80) self.extent.read_mdx(stream) for i in range(stream.read_uint32()): extent = Extent() extent.read_mdx(stream) self.sequence_extents.append(extent) if version > 800: if stream.peek(4) == 'TANG': stream.skip(4) self.tangents = stream.read_float32_array( stream.read_uint32() * 4) if stream.peek(4) == 'SKIN': stream.skip(4) self.skin = stream.read_uint8_array(stream.read_uint32()) stream.skip(4) for i in range(stream.read_uint32()): stream.skip(4) self.uv_sets.append( stream.read_float32_array(stream.read_uint32() * 2))
def write_mdx(self, stream: BinaryStream): stream.write_uint32(self.replaceable_id) stream.write(self.path) stream.skip(260 - len(self.path)) stream.write_uint32(self.flags)