def load(self): if isinstance(self.buffer, str): self.stream = TokenStream(buffer=self.buffer) self.load_mdl(self.stream) elif isinstance(self.buffer, (bytearray, bytes)): self.stream = BinaryStream(self.buffer) self.load_mdx()
def save_mdx(self): buffer = bytearray(self.get_byte_length()) stream = BinaryStream(buffer) stream.write('MDLX') self.save_version_chunk(stream) self.save_model_chunk(stream) self.save_static_object_chunk(stream, 'SEQS', self.sequences, 132) self.save_global_sequence_chunk(stream) self.save_dynamic_object_chunk(stream, 'MTLS', self.materials) self.save_static_object_chunk(stream, 'TEXS', self.textures, 268) self.save_dynamic_object_chunk(stream, 'TXAN', self.texture_animations) self.save_dynamic_object_chunk(stream, 'GEOS', self.geosets) self.save_dynamic_object_chunk(stream, 'GEOA', self.geoset_animations) self.save_dynamic_object_chunk(stream, 'BONE', self.bones) self.save_dynamic_object_chunk(stream, 'LITE', self.lights) self.save_dynamic_object_chunk(stream, 'HELP', self.helpers) self.save_dynamic_object_chunk(stream, 'ATCH', self.attachments) self.save_pivot_point_chunk(stream) self.save_dynamic_object_chunk(stream, 'PREM', self.particle_emitters) self.save_dynamic_object_chunk(stream, 'PRE2', self.particle_emitters2) if self.version > 800: self.save_dynamic_object_chunk(stream, 'CORN', self.particle_emitters_popcorn) self.save_dynamic_object_chunk(stream, 'RIBB', self.ribbon_emitters) self.save_dynamic_object_chunk(stream, 'CAMS', self.cameras) self.save_dynamic_object_chunk(stream, 'EVTS', self.event_objects) self.save_dynamic_object_chunk(stream, 'CLID', self.collision_shapes) if self.version > 800: self.save_static_object_chunk(stream, 'FAFX', self.face_effects, 340) self.save_bind_pose_chunk(stream) for chunk in self.unknown_chunks: chunk.write_mdx(stream) return stream.buffer_array