# -*- coding: utf-8 -*- ''' ZeroEngine .msh model format. Refer to schlechtwetterfront.github.io/ze_filetypes/msh.html for more information regarding the file format. ''' import msh2_crc reload(msh2_crc) import itertools import struct import math import logging import json import os MODEL_TYPES = {'null': 0, 'geodynamic': 1, 'cloth': 2, 'bone': 3, 'geobone': 3, 'geostatic': 4, 'geoshadow': 6} MODEL_TYPES_INT = ['null', 'geodynamic', 'cloth', 'bone', 'geostatic', '', 'geoshadow'] class MSH2Error(Exception): def __init__(self, value): self.parameter = value def __str__(self): return repr(self.parameter) class Packer(object): def pad_string(self, string): '''Pads the given string with \x00s to fill a multiple of 4 length.''' if string == '': return '' i = 0 while len(string) >= i: i += 4 return string.ljust(i, '\x00') def null_terminate(self, string): '''Null-terminates the given string.''' return string + '\x00' def pack_long_chunk(self, header, number): '''Chunk with only one long int.''' data = [header] data.append(struct.pack('