# vim:ts=4:et # ##### BEGIN GPL LICENSE BLOCK ##### # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # ##### END GPL LICENSE BLOCK ##### # from struct import unpack from pprint import pprint import bpy from bpy_extras.object_utils import object_data_add from mathutils import Vector,Matrix from . import quakepal class MDL: pass class skin: pass class stvert: pass class tri: pass class frame: pass class vert: pass def load_mdl(filepath): data = open(filepath, "rb").read() m = unpack("<4s i 3f 3f f 3f i i i i i i i", data[:76]) data = data[76:] mdl = MDL() mdl.name = filepath.split('/')[-1] mdl.name = mdl.name.split('.')[0] mdl.ident = m[0] mdl.version = m[1] mdl.scale = Vector(m[2:5]) mdl.scale_origin = Vector(m[5:8]) mdl.boundingradius = m[8] mdl.eyeposition = Vector(m[9:12]) mdl.numskins = m[12] mdl.skinwidth = m[13] mdl.skinheight = m[14] mdl.numverts = m[15] mdl.numtris = m[16] mdl.numframes = m[17] mdl.synctype = m[18] mdl.flags = 0 mdl.size = 1.0 # random number ;) if mdl.version == 6: m = (" 1 or mdl.frames[0].type: for i in range(mdl.numframes): frame = mdl.frames[i] if frame.type: for j in range(frame.numframes): make_shape_key(mdl, i, j) else: make_shape_key(mdl, i) mdl.mesh.update() bpy.context.user_preferences.edit.use_global_undo = True return 'FINISHED'