Beispiel #1
0
def load(operator, context, **keywords):
    time_main = time.time()

    filepath = keywords['filepath']

    # Get rid of all existing objects in the scene
    for obj in bpy.context.scene.objects:
        obj.select = obj.type == 'MESH' or obj.type == 'EMPTY'
    bpy.ops.object.delete()

    # Process MDL file
    if filepath != None and os.path.splitext(filepath)[1][1:].strip() == "mdl":
        mdl = MDL(filepath)
        mdl.build_blender_scene(context, keywords['use_animations'])
        mdl.print_type()
    # Process DEF file
    elif filepath != None and os.path.splitext(
            filepath)[1][1:].strip() == "def":
        mowdef = MOWDEF(filepath)
        mowdef.build_blender_scene(context, keywords['use_animations'])
        mowdef.print_type()
    else:
        print("No .DEF file found")

    time_new = time.time()

    print("finished importing: %r in %.4f sec." % (filepath,
                                                   (time_new - time_main)))
    return {'FINISHED'}
Beispiel #2
0
def main():
    (
        _,
        filename,
    ) = argv
    m = MDL()
    with open(filename, "rb") as s:
        m.unpack(s)
    print(m["keyvalue"].data)
Beispiel #3
0
def model_set_kv(s, kv):
    m = MDL()
    m.unpack(s)

    s.seek(0, SEEK_END)

    b = kv.encode("ascii") + b"\0"

    print(kv)
    print(s.tell())
    print(len(b))

    m["keyvalueindex"].data = s.tell()
    m["keyvaluesize"].data = len(b)

    s.write(b)
    s.seek(0)
    m.pack(s)
Beispiel #4
0
    def load_data(self):
        super(MOWDEF_NODE_EXTENSION, self).load_data()

        from mowdef_node_root import MOWDEF_NODE_ROOT

        filename = None

        # Get the name of the MDL file
        filename = self.data.split()[1][1:-1]

        # Build a complete filepath to the .MDL file
        filename = self.path + filename

        print(type(self).__name__ + " Loading file " + filename)

        try:
            # Create an MDL object and load the MDL file
            self.mdl = MDL(filename)
        except:
            print(sys.exc_info()[0])
Beispiel #5
0
#
#  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 #####

# Men of War MDL importer for Blender
# Script Copyright (C) by Björn Martins Paz

import argparse
import os
import struct

from mdl import MDL
from mowdef import MOWDEF

parser = argparse.ArgumentParser()
parser.add_argument('infile', nargs='?', help='Input file')
args = parser.parse_args()
infile = args.infile

# Process MDL file
if infile != None and os.path.splitext(infile)[1][1:].strip() == "mdl":
	mdl = MDL(infile)
# Process DEF file
elif infile != None and os.path.splitext(infile)[1][1:].strip() == "def":
	mowdef = MOWDEF(infile)
else:
    print("No .MDL or .DEF file found")
    parser.print_help()