示例#1
0
 def run(self):
     try:
         with btypes.FileStream(self.filename[0], 'wb',
                                btypes.BIG_ENDIAN) as stream:
             kcl.pack(stream, self.triangles, self.max_triangles,
                      self.min_width)
         with btypes.FileStream(
                 os.path.splitext(self.filename[0])[0] + '.pa', 'wb',
                 btypes.BIG_ENDIAN) as stream:
             kcl.SurfaceTypeList.pack(stream, self.surface_types)
     except kcl.GeometryOverflowError as error:
         self.geometryOverflow.emit(error)
示例#2
0
文件: MTE.py 项目: melodicht/files
class DrawElement(bt.Struct(
  bt.Field(bt.uint16,'material_index'),
  bt.Field(bt.uint16,'shape_index'))): pass

#------------------------------------------------------------------------------

parser = argparse.ArgumentParser(description='Extract/Inject images into MDL files')
parser.add_argument('inout',metavar='i/o')
parser.add_argument('ifile',metavar='input.mdl')
parser.add_argument('img',nargs='?',metavar='image')
parser.add_argument('texnum',nargs='?',metavar='"texture number"', type=int)
arguments = parser.parse_args()

rootname = os.path.splitext(arguments.ifile)[0]

stream = bt.FileStream(arguments.ifile,'rb',bt.BE)
header = stream >> Header

stream.seek(header.material_offset)
materials = [stream >> Material for i in range(header.num_materials)]

stream.seek(header.texobj_offset)
texobjs = [stream >> TexObj for i in range(header.num_texobjs)]

stream.seek(header.shape_offset)
shapes = [stream >> Shape for i in range(header.num_shapes)]

stream.seek(header.draw_element_offset)
draw_elements = [stream >> DrawElement for i in range(header.num_draw_elements)]

stream.seek(header.shape_packet_offset)